本文整理汇总了C++中SoSeparator::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSeparator::unref方法的具体用法?C++ SoSeparator::unref怎么用?C++ SoSeparator::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSeparator
的用法示例。
在下文中一共展示了SoSeparator::unref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
~Private()
{
picksepLeft->unref();
picksepRight->unref();
delete sensorCam1;
delete sensorCam2;
}
示例2: isVisibleFace
bool isVisibleFace(int faceIndex, const SbVec2f& pos, Gui::View3DInventorViewer* viewer)
{
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(vp->getRoot());
SoSearchAction searchAction;
searchAction.setType(PartGui::SoBrepFaceSet::getClassTypeId());
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.apply(root);
SoPath* selectionPath = searchAction.getPath();
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setNormalizedPoint(pos);
rp.apply(selectionPath);
root->unref();
SoPickedPoint* pick = rp.getPickedPoint();
if (pick) {
const SoDetail* detail = pick->getDetail();
if (detail && detail->isOfType(SoFaceDetail::getClassTypeId())) {
int index = static_cast<const SoFaceDetail*>(detail)->getPartIndex();
if (faceIndex != index)
return false;
SbVec3f dir = viewer->getViewDirection();
const SbVec3f& nor = pick->getNormal();
if (dir.dot(nor) > 0)
return false; // bottom side points to user
return true;
}
}
return false;
}
示例3: main
int main(int, char **argv)
{
// Initialize Inventor. This returns a main window to use.
// If unsuccessful, exit.
HWND myWindow = SoWin::init("A red cone."); // pass the app name
if (myWindow == NULL) exit(1);
// Make a scene containing a red cone
SoSeparator *root = new SoSeparator;
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoMaterial *myMaterial = new SoMaterial;
root->ref();
root->addChild(myCamera);
root->addChild(new SoDirectionalLight);
myMaterial->diffuseColor.setValue(1.0, 1.0, 0.0); // Red
root->addChild(myMaterial);
root->addChild(new SoCone);
// Create a renderArea in which to see our scene graph.
// The render area will appear within the main window.
SoWinExaminerViewer *myRenderArea = new SoWinExaminerViewer(myWindow);
// Make myCamera see everything.
myCamera->viewAll(root, myRenderArea->getViewportRegion());
// Put our scene in myRenderArea, change the title
myRenderArea->setSceneGraph(root);
myRenderArea->setTitle("A red cone");
myRenderArea->show();
SoWin::show(myWindow); // Display main window
SoWin::mainLoop(); // Main Inventor event loop
delete myRenderArea;
root->unref();
return 0;
}
示例4: main
int main(int, char **argv)
{
// Initialize Inventor. This returns a main window to use.
// If unsuccessful, exit.
HWND myWindow = SoWin::init("A red cone."); // pass the app name
if (myWindow == NULL) exit(1);
// Make a scene containing a red cone
SoSeparator *root = new SoSeparator;
root->ref();
SoMaterial *myMaterial = new SoMaterial;
myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);
root->addChild(myMaterial);
root->addChild(new SoCone);
// Set up viewer:
SoWinExaminerViewer *myViewer =new SoWinExaminerViewer(myWindow);
myViewer->setSceneGraph(root);
myViewer->setTitle("Examiner Viewer");
myViewer->show();
SoWin::show(myWindow); // Display main window
SoWin::mainLoop(); // Main Inventor event loop
root->unref();
return 0;
}
示例5: getPointOnRay
SoPickedPoint* ViewProvider::getPointOnRay(const SbVec2s& pos, const View3DInventorViewer* viewer) const
{
//first get the path to this node and calculate the current transformation
SoSearchAction sa;
sa.setNode(pcRoot);
sa.setSearchingAll(true);
sa.apply(viewer->getSoRenderManager()->getSceneGraph());
if (!sa.getPath())
return nullptr;
SoGetMatrixAction gm(viewer->getSoRenderManager()->getViewportRegion());
gm.apply(sa.getPath());
SoTransform* trans = new SoTransform;
trans->setMatrix(gm.getMatrix());
trans->ref();
// build a temporary scenegraph only keeping this viewproviders nodes and the accumulated
// transformation
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(trans);
root->addChild(pcRoot);
//get the picked point
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setPoint(pos);
rp.setRadius(viewer->getPickRadius());
rp.apply(root);
root->unref();
trans->unref();
SoPickedPoint* pick = rp.getPickedPoint();
return (pick ? new SoPickedPoint(*pick) : 0);
}
示例6: main
int main(int argc, char** argv)
{
QWidget* mainwin = SoQt::init(argc, argv, argv[0]);
SoSeparator* root = new SoSeparator;
root->ref();
InventorRobot robot(root);
if (argc == 1){
//robot.parse("../RobotEditorArmar4.dae");
//robot.parse("/media/sf_host/manikin_creo_4.dae");
std::cout << "Usage collada <collada file> [<inventor export>]" <<std::endl;
return 1;
}
else {
robot.parse(argv[1]);
if (argc==3){
SoWriteAction writeAction;
writeAction.getOutput()->openFile(argv[2]);
writeAction.apply(root);
}
}
SoQtExaminerViewer* viewer = new SoQtExaminerViewer(mainwin);
viewer->setSceneGraph(root);
viewer->show();
// Pop up the main window.
SoQt::show(mainwin);
// Loop until exit.
SoQt::mainLoop();
root->unref();
return 1;
}
示例7: title
int
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow)
{
#else // UNIX
int
main(int argc, char ** argv)
{
#endif
// initialize Coin and glut libraries
SoDB::init();
#ifdef _WIN32
int argc = 1;
char * argv[] = { "glutiv.exe", (char *) NULL };
glutInit(&argc, argv);
#else
glutInit(&argc, argv);
#endif
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
SoSeparator * root;
root = new SoSeparator;
root->ref();
SoPerspectiveCamera * camera = new SoPerspectiveCamera;
root->addChild(camera);
root->addChild(new SoDirectionalLight);
root->addChild(createScenegraph());
scenemanager = new SoSceneManager;
scenemanager->setRenderCallback(redraw_cb, (void *)1);
scenemanager->setBackgroundColor(SbColor(0.2f, 0.2f, 0.2f));
scenemanager->activate();
camera->viewAll(root, scenemanager->getViewportRegion());
scenemanager->setSceneGraph(root);
glutInitWindowSize(512, 400);
SbString title("Offscreen Rendering");
glutwin = glutCreateWindow(title.getString());
glutDisplayFunc(expose_cb);
glutReshapeFunc(reshape_cb);
// start main loop processing (with an idle callback)
glutIdleFunc(idle_cb);
glutMainLoop();
root->unref();
delete scenemanager;
return 0;
}
示例8: addConfiguration
bool CoinRrtWorkspaceVisualization::addConfiguration( const Eigen::VectorXf &c, CoinRrtWorkspaceVisualization::ColorSet colorSet, float nodeSizeFactor )
{
if (c.rows() != robotNodeSet->getSize())
{
VR_ERROR << " Dimensions do not match: " << c.rows() <<"!="<< robotNodeSet->getSize() << endl;
return false;
}
if (!TCPNode)
return false;
float nodeSolutionSize = pathNodeSize*nodeSizeFactor;//15.0;//1.0f
SoMaterial *materialNodeSolution = new SoMaterial();
materialNodeSolution->ambientColor.setValue(colors[colorSet].nodeR,colors[colorSet].nodeG,colors[colorSet].nodeB);
materialNodeSolution->diffuseColor.setValue(colors[colorSet].nodeR,colors[colorSet].nodeG,colors[colorSet].nodeB);
SoSphere *sphereNodeSolution = new SoSphere();
sphereNodeSolution->radius.setValue(nodeSolutionSize);
Eigen::VectorXf actConfig;
float x,y,z;
float x2 = 0.0f,y2 = 0.0f,z2 = 0.0f;
SoSeparator *sep = new SoSeparator();
sep->ref();
SoUnits *u = new SoUnits;
u->units = SoUnits::MILLIMETERS;
sep->addChild(u);
// create 3D model for nodes
SoSeparator *s = new SoSeparator();
s->addChild(materialNodeSolution);
SoTranslation *t = new SoTranslation();
// get tcp coords:
robot->setJointValues(robotNodeSet,c);
Eigen::Matrix4f m;
m = TCPNode->getGlobalPose();
x = m(0,3);
y = m(1,3);
z = m(2,3);
t->translation.setValue(x,y,z);
s->addChild(t);
// display a solution node different
s->addChild(sphereNodeSolution);
sep->addChild(s);
visualization->addChild(sep);
sep->unref();
return true;
}
示例9: getPointOnRay
SoPickedPoint* ViewProvider::getPointOnRay(const SbVec2s& pos, const View3DInventorViewer* viewer) const
{
// for convenience make a pick ray action to get the (potentially) picked entity in the provider
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getSoRenderManager()->getCamera());
root->addChild(pcRoot);
SoRayPickAction rp(viewer->getSoRenderManager()->getViewportRegion());
rp.setPoint(pos);
rp.apply(root);
root->unref();
SoPickedPoint* pick = rp.getPickedPoint();
return (pick ? new SoPickedPoint(*pick) : 0);
}
示例10: app
int
main(int argc, char ** argv)
{
QApplication app(argc, argv);
// Initializes Quarter (and implicitly also Coin and Qt
Quarter::init();
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
root->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
root->addChild(col);
root->addChild(new SoCone);
// Create a QuarterWidget for displaying a Coin scene graph
QuarterWidget * viewer = new QuarterWidget;
//set default navigation mode file
viewer->setNavigationModeFile();
viewer->setSceneGraph(root);
// Add some background text
SoSeparator * background = create_background();
(void)viewer->getSoRenderManager()->addSuperimposition(background,
SoRenderManager::Superimposition::BACKGROUND);
// Add some super imposed text
SoSeparator * superimposed = create_superimposition();
(void)viewer->getSoRenderManager()->addSuperimposition(superimposed);
// Pop up the QuarterWidget
viewer->show();
// Loop until exit.
app.exec();
// Clean up resources.
root->unref();
delete viewer;
Quarter::clean();
return 0;
}
示例11: getPickedPoint
SoPickedPoint* ViewProviderFace::getPickedPoint(const SbVec2s& pos, const SoQtViewer* viewer) const
{
SoSeparator* root = new SoSeparator;
root->ref();
root->addChild(viewer->getHeadlight());
root->addChild(viewer->getCamera());
root->addChild(this->pcMeshPick);
SoRayPickAction rp(viewer->getViewportRegion());
rp.setPoint(pos);
rp.apply(root);
root->unref();
// returns a copy of the point
SoPickedPoint* pick = rp.getPickedPoint();
//return (pick ? pick->copy() : 0); // needs the same instance of CRT under MS Windows
return (pick ? new SoPickedPoint(*pick) : 0);
}
示例12: main
int main(int, char ** argv)
{
HWND window = SoWin::init("Oil Well");
if (window == NULL) exit(1);
SoWinExaminerViewer * viewer = new SoWinExaminerViewer(window);
viewer->setDecoration(false);
viewer->setSize(SbVec2s(800, 600));
SoSeparator *root = new SoSeparator;
root->ref();
SoSeparator *obelisk = new SoSeparator();
// Define the normals used:
SoNormal *myNormals = new SoNormal;
myNormals->vector.setValues(0, 8, norms);
obelisk->addChild(myNormals);
SoNormalBinding *myNormalBinding = new SoNormalBinding;
myNormalBinding->value = SoNormalBinding::PER_FACE;
obelisk->addChild(myNormalBinding);
// Define material for obelisk
SoMaterial *myMaterial = new SoMaterial;
myMaterial->diffuseColor.setValue(.4, .4, .4);
obelisk->addChild(myMaterial);
// Define coordinates for vertices
SoCoordinate3 *myCoords = new SoCoordinate3;
myCoords->point.setValues(0, 28, vertices);
obelisk->addChild(myCoords);
// Define the FaceSet
SoFaceSet *myFaceSet = new SoFaceSet;
myFaceSet->numVertices.setValues(0, 8, numvertices);
obelisk->addChild(myFaceSet);
root->addChild(obelisk);
viewer->setSceneGraph(root);
viewer->setTitle("Oil Well");
viewer->show();
SoWin::show(window);
SoWin::mainLoop();
delete viewer;
root->unref();
return 0;
}
示例13: app
int
main(int argc, char ** argv)
{
QApplication app(argc, argv);
// Initializes Quarter library (and implicitly also the Coin and Qt
// libraries).
Quarter::init();
// Make a dead simple scene graph by using the Coin library, only
// containing a single yellow cone under the scenegraph root.
SoSeparator * root = new SoSeparator;
root->ref();
SoBaseColor * col = new SoBaseColor;
col->rgb = SbColor(1, 1, 0);
root->addChild(col);
root->addChild(new SoCone);
// Create a QuarterWidget for displaying a Coin scene graph
QuarterWidget * viewer = new QuarterWidget;
viewer->setSceneGraph(root);
// make the viewer react to input events similar to the good old
// ExaminerViewer
viewer->setNavigationModeFile(QUrl("coin:///scxml/navigation/examiner.xml"));
// Pop up the QuarterWidget
viewer->show();
// Loop until exit.
app.exec();
// Clean up resources.
root->unref();
delete viewer;
Quarter::clean();
return 0;
}
示例14: strlen
SoSeparator *
createScenegraph(void)
{
SoSeparator * texroot = new SoSeparator;
texroot->ref();
SoInput in;
in.setBuffer(red_cone_iv, strlen(red_cone_iv));
SoSeparator * result = SoDB::readAll(&in);
if (result == NULL) { exit(1); }
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoRotationXYZ *rot = new SoRotationXYZ;
rot->axis = SoRotationXYZ::X;
rot->angle = M_PI_2;
myCamera->position.setValue(SbVec3f(-0.2, -0.2, 2.0));
myCamera->scaleHeight(0.4);
texroot->addChild(myCamera);
texroot->addChild(new SoDirectionalLight);
texroot->addChild(rot);
texroot->addChild(result);
myCamera->viewAll(texroot, SbViewportRegion());
// Generate the texture map
SoTexture2 *texture = new SoTexture2;
texture->ref();
if (generateTextureMap(texroot, texture, 128, 128))
printf ("Successfully generated texture map\n");
else
printf ("Could not generate texture map\n");
texroot->unref();
// Make a scene with a cube and apply the texture to it
SoSeparator * root = new SoSeparator;
root->addChild(texture);
root->addChild(new SoCube);
return root;
}
示例15: doc_new_geometric_object
int QilexDoc::doc_new_geometric_object(ct_new_geometric_object *data)
{
int error = 0;
int tipus = 0;
void *buffer; //char *buffer;
char *buftemp = (char*)malloc(1024);
size_t sizeModel = 0;;
SoSeparator *object = new SoSeparator;
SoSeparator *objecttest = new SoSeparator;
SoTransform *pos_rot = new SoTransform;
SbVec3f joinax;
joinax.setValue(SbVec3f(data->x,data->y,data->z));
pos_rot->translation.setValue(joinax);
pos_rot->recenter(joinax);
pos_rot->rotation.setValue(SbVec3f(data->axeX, data->axeY, data->axeZ), (float) rad((double) data->angle));
object = readFile(data->QsModelFile.latin1(), tipus);
if (object == NULL) // no object read
{
error = 1 ;
}
else // ok, there's no object with the same name
{
object->ref();
objecttest = (SoSeparator*)SoNode::getByName(data->QsName.latin1());
if (objecttest==NULL)
{
SoOutput out;
out.setBuffer(buftemp, 1024, reallocCB);
SoWriteAction wa1(&out);
wa1.apply(object);
out.getBuffer(buffer, sizeModel);
object->setName(data->QsName.latin1());
object->insertChild(pos_rot, 0);
view->addObjectCell(object);
error = 0;
writeXML_geomelement((char *)buffer, sizeModel, tipus, data);
}
else
{
object->unref();
error = 3;
}
}
return error;
}