Example #1
0
SoSeparator *ReadScene(const char *Dir, const char *filename) {
   FILE *filePtr = NULL;
   SoSeparator *root;
   SoInput in;

   in.addDirectoryLast(Dir);

   if (!in.openFile(filename)) {
       cerr << "Error opening file " << filename << " from Directory " << Dir 
	    << endl;
       exit(1);
   }
   
   root = SoDB::readAll(&in);
   if (root == NULL)
       cerr << "Error reading file " << filename << " from Directory " << Dir 
	    << endl;
   else {
#ifdef DEBUG
       cerr << "Scene (" << filename << ") read!\n";
#endif
       root->ref();
   }
   in.closeFile();
   return root;
}
void ViewProviderImagePlane::attach(App::DocumentObject *pcObj)
{
    ViewProviderDocumentObject::attach(pcObj);

    // NOTE: SoFCSelection node has beem removed because it led to
    // problems using the image as a construction plane with the
    // draft commands
    SoSeparator* planesep = new SoSeparator;
    planesep->addChild(pcCoords);

    SoTextureCoordinate2 *textCoord = new SoTextureCoordinate2;
    textCoord->point.set1Value(0,0,0);
    textCoord->point.set1Value(1,1,0);
    textCoord->point.set1Value(2,1,1);
    textCoord->point.set1Value(3,0,1);
    planesep->addChild(textCoord);

    // texture
    texture->model = SoTexture2::MODULATE;
    planesep->addChild(texture);

    // plane
    pcCoords->point.set1Value(0,0,0,0);
    pcCoords->point.set1Value(1,1,0,0);
    pcCoords->point.set1Value(2,1,1,0);
    pcCoords->point.set1Value(3,0,1,0);
    SoFaceSet *faceset = new SoFaceSet;
    faceset->numVertices.set1Value(0,4);
    planesep->addChild(faceset);

    addDisplayMaskMode(planesep, "ImagePlane");
}
Example #3
0
void
IfWeeder::weedMaterial(SoNode *root, IfWeederMaterialEntry *entry)
{
    // If the material affects no shapes at all, get rid of it. This
    // can happen when vertex property nodes are used.
    if (entry->shapes.getLength() == 0) {
	SoSearchAction sa;
	sa.setNode(entry->material);
	sa.setInterest(SoSearchAction::ALL);
	sa.apply(root);
	for (int i = 0; i < sa.getPaths().getLength(); i++) {
	    SoPath *path = sa.getPaths()[i];
	    SoSeparator *parent = (SoSeparator *) path->getNodeFromTail(1);
	    int index = path->getIndexFromTail(0);
	    ASSERT(parent->isOfType(SoSeparator::getClassTypeId()));
	    ASSERT(parent->getChild(index) == entry->material);
	    parent->removeChild(index);
	}
    }

    // Remove all material values from the material node that are
    // not used by any dependent shapes. Adjust the indices in the
    // dependent shapes accordingly.
    removeDuplicateMaterials(entry);

    // Now remove all material values that are not used by any
    // dependent shapes. Again, adjust the indices in the dependent
    // shapes.
    removeUnusedMaterials(entry);
}
Example #4
0
void
BaseObj::addBase(SoSeparator *sep)
{
    SoSeparator *cubeSep = new SoSeparator;

    if (_on) {
	SoTranslation *tran = new SoTranslation;
	tran->translation.setValue(0.0, _baseHeight / 2, 0.0);
	sep->addChild(tran);
	SoBaseColor *col = new SoBaseColor;
	col->rgb.setValue(_baseColor[0], _baseColor[1], _baseColor[2]);
	cubeSep->addChild(col);
	_cube = new SoCube;
	_cube->width = baseWidth();
	_cube->depth = baseDepth();
	_cube->height = _baseHeight;
	cubeSep->addChild(_cube);
    }

    _mod = new ToggleMod(cubeSep, (const char *)_label.toAscii());
    sep->addChild(_mod->root());

    if (_on) {
	SoTranslation *tran2 = new SoTranslation;
	tran2->translation.setValue(0.0, _baseHeight / 2.0, 0.0);
	sep->addChild(tran2);
    }
}
Example #5
0
void
vpSimulator::initSceneGraph()
{
  this->scene = new SoSeparator;
  this->internalRoot = new SoSeparator;
  this->externalRoot = new SoSeparator;

  this->scene->ref();
  this->internalRoot->ref();
  this->externalRoot->ref();

  // define the camera SoPerspectiveCamera
  this->internalCamera = new SoPerspectiveCamera ;
  this->externalCamera = new SoPerspectiveCamera ;
  
  
  this->internalCameraPosition = new SoTransform;
  this->internalCameraObject = createCameraObject(zoomFactor);

  internalCamera->farDistance.setValue(100);
  internalCamera->nearDistance.setValue(0.0001f);



  // link between camera and internal root
  this->internalRoot->addChild (this->internalCamera);
  this->internalRoot->addChild (this->scene);

  this->externalRoot->addChild (this->externalCamera);
  this->externalRoot->addChild (this->scene);


  SoSeparator * camera = new SoSeparator;
  camera->ref();
  camera->addChild (this->internalCameraPosition);
  camera->addChild (this->internalCameraObject);
  this->externalRoot->addChild (camera);


  //this->externalRoot->addChild (internalCameraPosition);
  //  this->externalRoot->addChild (internalCameraObject);
  SoCube *cube = new SoCube ;
  cube->width=0.01f ;
  cube->depth=0.01f ;
  cube->height=0.01f ;

  this->externalRoot->addChild (cube);

  if (realtime==NULL)
  {

    SoDB::enableRealTimeSensor(FALSE);
    SoSceneManager::enableRealTimeUpdate(FALSE);
    realtime = (SbTime *) SoDB::getGlobalField("realTime");
    realtime->setValue(0.0);

  }


}
SoSeparator* CelestialWidget::Ecliptic() const
{
	SoSeparator* ecliptic = new SoSeparator;

	SoMaterial *myMaterial = new SoMaterial;
	myMaterial->diffuseColor.setValue( 0.80f, 0.80f, 0.0f); // Olive
	ecliptic->addChild(myMaterial);

	SoDrawStyle * drawstyle = new SoDrawStyle;
	drawstyle->lineWidth = 2;
	ecliptic->addChild( drawstyle );

	float p[360][3];
	for( int fi = 0; fi<360; ++fi )
	{
		p[fi][0] = cos( gc::Ecliptic ) * sin( fi * (gc::Pi / 180) ) * sphereRadio;
		p[fi][1] = sin( gc::Ecliptic ) * sin( fi * (gc::Pi / 180) ) * sphereRadio;
		p[fi][2] = -cos( fi * (gc::Pi / 180) ) * sphereRadio;
	}

	int lines[1]={360};
	SoCoordinate3 * coord3 = new SoCoordinate3;
	coord3->point.setValues(0, 360, p);
	ecliptic->addChild(coord3);

	SoLineSet* lineset=new SoLineSet;
	lineset->numVertices.setValues(0,1,lines);
	ecliptic->addChild(lineset);

	return ecliptic;
}
Example #7
0
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;
}
Example #8
0
static SoSeparator *discGeom(void)
{
	SoSeparator *root = new SoSeparator();

	float points[NUM_POINTS][3];
	int faceIndices[NUM_POINTS+1];
	for (int i=0; i< NUM_POINTS; i++) {
		float angle = (i * 2.0 * M_PI) / NUM_POINTS;
		points[i][0] = RADIUS * cos(angle);
		points[i][1] = RADIUS * sin(angle);
		points[i][2] = 0;
		faceIndices[i] = i;
	}
	faceIndices[NUM_POINTS] = 0;

	SoCoordinate3 *coords = new SoCoordinate3();
	coords->point.setValues(0, NUM_POINTS, points);
	root->addChild(coords);

	SoIndexedFaceSet *face = new SoIndexedFaceSet();
	face->coordIndex.setValues(0, NUM_POINTS+1, faceIndices);
	root->addChild(face);

	return root;
}
Example #9
0
/*!
 * Reads the scene saved on the file with given \a filename and return a pointer to the scene.
 *
 * Returns null on any error.
 */
TSceneKit* Document::GetSceneKitFromFile( const QString& fileName )
{
    SoInput sceneInput;
	if ( !sceneInput.openFile( fileName.toLatin1().constData() ) )
	{
		QString message = QString( "Cannot open file %1." ).arg( fileName );
		emit Warning( message );

		return 0;
	}

	if( !sceneInput.isValidFile() )
	{
		QString message = QString( "Error reading file %1.\n" ).arg( fileName );
		emit Warning( message );

		return 0;
	}

	SoSeparator* graphSeparator = SoDB::readAll( &sceneInput );
	sceneInput.closeFile();

	if ( !graphSeparator )
	{
		QString message = QString( "Error reading file %1.\n" ).arg( fileName );
		emit Warning( message );

		return 0;
	}

   return static_cast< TSceneKit* >( graphSeparator->getChild(0) );
	return 0;
}
TSeparatorKit* ComponentHeliostatField::OpenHeliostatComponent( QString fileName )
{
	if ( fileName.isEmpty() ) return 0;

	SoInput componentInput;
	if ( !componentInput.openFile( fileName.toLatin1().constData() ) )
	{
        QMessageBox::warning( 0, QString( "Scene Graph Structure" ),
        		QString( "Cannot open file %1:\n." ).arg( fileName ) );
		return 0;
	}

	SoSeparator* componentSeparator = SoDB::readAll( &componentInput );
	componentInput.closeFile();

	if ( !componentSeparator )
	{
        QMessageBox::warning( 0, QString( "Scene Graph Structure" ),
        		QString( "Error reading file %1:\n%2." )
                             .arg( fileName ) );
		return 0;
	}

	TSeparatorKit* componentRoot = static_cast< TSeparatorKit* >( componentSeparator->getChild(0) );
	componentRoot->ref();


   return componentRoot;

}
Example #11
0
int QilexDoc::doc_new_kinematic_hand(ct_new_kinematic_chain *data)
{
   int error = 0;
   int tipus = 0;
   void * buffer ; //char *buffer;
   char *buftemp = (char*)malloc(1024);

   SoOutput out;

   size_t sizeModel = 0;

   SoSeparator *kinechain = new SoSeparator;
   SoSeparator *kinetest = new SoSeparator;

   Rchain_hand *kineengine = new Rchain_hand();

   SoTransform *pos_rot = new SoTransform;
   SbVec3f joinax;

   joinax.setValue(SbVec3f(data->x,data->y,data->z));
   pos_rot->translation.setValue(joinax);
   pos_rot->rotation.setValue(SbVec3f(data->axeX, data->axeY, data->axeZ), (float) rad((double) data->angle));

   kinechain = readFile(data->QsModelFile.latin1(), tipus);

   if (kinechain == NULL) // no object read
   { return 1; }
   else  // ok, there's no object with the same name
   {
      error = kineengine->init_dat(data->QsDatFile.latin1()); //

      if (error == 0)
      {
         kinechain->ref();
         kinetest = (SoSeparator*)SoNode::getByName(data->QsName.latin1());

         if (kinetest==NULL)
         {
            //we need to put it in a buffer to write the xml file
            // if is Ok
            SoOutput out;
            out.setBuffer(buftemp, 1024, reallocCB);

            SoWriteAction wa1(&out);
            wa1.apply(kinechain);

            out.getBuffer(buffer, sizeModel);

            kinechain->insertChild(pos_rot, 0);
         }
         error = doc_insert_kinematic_hand(kineengine, kinechain);
      }
   }

   if (error==0)
   {
      writeXML_kineelement((char *)buffer, sizeModel, tipus, data, kineengine);
   }
   return error;
}
Example #12
0
void ViewProviderLine::attach ( App::DocumentObject *obj ) {
    ViewProviderOriginFeature::attach ( obj );

    static const float size = ViewProviderOrigin::defaultSize ();

    static const SbVec3f verts[2] = { SbVec3f(size, 0, 0),   SbVec3f ( -size, 0, 0 ) };

    // indexes used to create the edges
    static const int32_t lines[4] = { 0, 1, -1 };

    SoSeparator *sep = getOriginFeatureRoot ();

    SoCoordinate3 *pCoords = new SoCoordinate3 ();
    pCoords->point.setNum (2);
    pCoords->point.setValues ( 0, 2, verts );
    sep->addChild ( pCoords );

    SoIndexedLineSet *pLines  = new SoIndexedLineSet ();
    pLines->ref();
    pLines->coordIndex.setNum(3);
    pLines->coordIndex.setValues(0, 3, lines);
    sep->addChild ( pLines );

    SoTranslation *textTranslation = new SoTranslation ();
    textTranslation->ref ();
    textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) );
    sep->addChild ( textTranslation );

    sep->addChild ( getLabel () );
}
Example #13
0
bool SimoxRobotViewer::showVector( const std::string &vecName, const Eigen::Vector3f &pos, const Eigen::Vector3f &ori, float scaling )
{
	removeVector(vecName);

	lock();
	SoSeparator* sep = new SoSeparator();
	sep->addChild(CoinVisualizationFactory::CreateVertexVisualization(pos,5,0,1,0,0));
	if (ori.norm()>1e-9 && scaling>0)
	{
		SoTranslation* t = new SoTranslation();
		//cout << "ori:\n" << ori << endl;
		t->translation.setValue(pos[0],pos[1],pos[2]);
		sep->addChild(t);
		SoSeparator* sepA = CoinVisualizationFactory::CreateArrow(ori,50.0f*scaling,2.0f*scaling,VirtualRobot::VisualizationFactory::Color::Blue());
		sep->addChild(sepA);
	}

	SoSeparator* sText = CoinVisualizationFactory::CreateText(vecName);
	if (sText)
		sep->addChild(sText);
	vectors[vecName] = sep;

	// add visu
	sceneSep->addChild(sep);

	unlock();
	return true;
}
Example #14
0
void SimDynamicsWindow::updateComVisu()
{
    if (!robot)
    {
        return;
    }

    std::vector<RobotNodePtr> n = robot->getRobotNodes();
    std::map< VirtualRobot::RobotNodePtr, SoSeparator* >::iterator i = comVisuMap.begin();

    while (i != comVisuMap.end())
    {
        SoSeparator* sep = i->second;
        SoMatrixTransform* m = dynamic_cast<SoMatrixTransform*>(sep->getChild(0));

        if (m)
        {
            Eigen::Matrix4f ma = dynamicsRobot->getComGlobal(i->first);
            ma.block(0, 3, 3, 1) *= 0.001f;
            m->matrix.setValue(CoinVisualizationFactory::getSbMatrix(ma));
        }

        i++;
    }
}
Example #15
0
 ~Private()
 {
     picksepLeft->unref();
     picksepRight->unref();
     delete sensorCam1;
     delete sensorCam2;
 }
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;
}
Example #17
0
SoSeparator* HorizontalWidget::Horizon() const
{
	float p[360][3];
	for( int fi = 0; fi<360; ++fi )
	{
		p[fi][0] = -sin( fi * (gc::Pi / 180) ) * sphereRadio ;
    	p[fi][1] =  0.0;
    	p[fi][2] = -cos( fi * (gc::Pi / 180) ) * sphereRadio ;

	}

	int lines[1]={360};
	SoCoordinate3 * coord3 = new SoCoordinate3;
  	coord3->point.setValues(0, 360, p);
  	SoSeparator* ecuador = new SoSeparator;
  	ecuador->addChild(coord3);

  	SoLineSet* lineset=new SoLineSet;
  	lineset->numVertices.setValues(0,1,lines);
  	ecuador->addChild(lineset);

	return ecuador;


}
Example #18
0
void SimDynamicsWindow::comVisu()
{
    if (!robot)
    {
        return;
    }

    comSep->removeAllChildren();
    comVisuMap.clear();
    bool visuCom = UI.checkBoxCom->checkState() == Qt::Checked;

    if (visuCom)
    {
        std::vector<RobotNodePtr> n = robot->getRobotNodes();

        for (size_t i = 0; i < n.size(); i++)
        {
            SoSeparator* sep = new SoSeparator;
            comSep->addChild(sep);
            Eigen::Matrix4f cp = dynamicsRobot->getComGlobal(n[i]);
            sep->addChild(CoinVisualizationFactory::getMatrixTransformScaleMM2M(cp));
            sep->addChild(CoinVisualizationFactory::CreateCoordSystemVisualization(5.0f));
            comVisuMap[n[i]] = sep;
        }
    }
}
Example #19
0
SoSeparator* trf::DrawPhotonMapPoints( const TPhotonMap& map )
{

	SoSeparator* drawpoints = new SoSeparator;
	SoCoordinate3* points = new SoCoordinate3;
	std::vector< Photon* > photonsList = map.GetAllPhotons();
    unsigned int numRays=0;

	for( unsigned int i = 0; i < photonsList.size(); i++)
	{
		Point3D photon = photonsList[i]->pos;
		points->point.set1Value( numRays, photon.x, photon.y, photon.z );
		numRays++;
	}

	SoMaterial* myMaterial = new SoMaterial;
	myMaterial->diffuseColor.setValue(1.0, 1.0, 0.0);
	drawpoints->addChild(myMaterial);
	drawpoints->addChild(points);

	SoDrawStyle* drawstyle = new SoDrawStyle;
	drawstyle->pointSize = 3;
	drawpoints->addChild(drawstyle);

	SoPointSet* pointset = new SoPointSet;
	drawpoints->addChild(pointset);

	return drawpoints;

}
Example #20
0
SoSeparator* HorizontalWidget::Ejes() const
{
  	SoSeparator* ejes = new SoSeparator;

  	SoMaterial *myMaterial = new SoMaterial;
  	myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);   // Red
  	ejes->addChild(myMaterial);

	float p[6][3]={{0.0, 0.0, 0.0},
	 				{ float( sphereRadio+20 ), 0.0, 0.0},
					{0.0, 0.0, 0.0},
					{0.0, float( sphereRadio+20 ), 0.0},
					{0.0, 0.0, 0.0},
					{0.0, 0.0, float( sphereRadio+20 )}};

  	SoCoordinate3* coord3 = new SoCoordinate3;
  	coord3->point.setValues(0, 6, p);
  	ejes->addChild(coord3);

  	int lines[3]={2,2, 2};
  	SoLineSet* lineset=new SoLineSet;
  	lineset->numVertices.setValues(0,3,lines);
  	ejes->addChild(lineset);

  	return ejes;

}
Example #21
0
// the MAIN function
int main(int argc, char ** argv)
{
  Widget mainWindow = SoXt::init(argv[0]);
  if (mainWindow == NULL) exit(1);

  SoSeparator *root;

  root = new SoSeparator;
  root->ref();

  player.camera = new SoPerspectiveCamera;
  root->addChild(player.camera);
  root->addChild(createScene()) ;

  //player.camera->viewAll(root, myRenderArea->getViewportRegion());
  player.camera->position=SbVec3f(0, 5, 20);
  player.camera->orientation=SbRotation(-0.1, 0, 0, 1);
  player.camera->nearDistance=1;
  player.camera->farDistance=150;
  player.camera->heightAngle=0.5;

  //view the whole scene

  // initialize scenemanager instance
  SoXtRenderArea *myRenderArea = new SoXtRenderArea(mainWindow);
  myRenderArea->setSceneGraph(root);
  myRenderArea->setTitle("Bouncing Ball");
  myRenderArea->show();
  
  SoXt::show(mainWindow);
  SoXt::mainLoop();
  
  return 0;
}
    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;
    }
void ViewProviderMeshDuplicatedPoints::attach(App::DocumentObject* pcFeat)
{
    ViewProviderDocumentObject::attach( pcFeat );

    SoGroup* pcPointRoot = new SoGroup();
    pcDrawStyle->pointSize = 3;
    pcPointRoot->addChild(pcDrawStyle);

    // Draw points
    SoSeparator* pointsep = new SoSeparator;
    SoBaseColor * basecol = new SoBaseColor;
    basecol->rgb.setValue( 1.0f, 0.5f, 0.0f );
    pointsep->addChild(basecol);
    pointsep->addChild(pcCoords);
    pointsep->addChild(pcPoints);
    pcPointRoot->addChild(pointsep);

    // Draw markers
    SoBaseColor * markcol = new SoBaseColor;
    markcol->rgb.setValue( 1.0f, 1.0f, 0.0f );
    SoMarkerSet* marker = new SoMarkerSet;
    marker->markerIndex=SoMarkerSet::PLUS_7_7;
    pointsep->addChild(markcol);
    pointsep->addChild(marker);

    addDisplayMaskMode(pcPointRoot, "Point");
}
Example #24
0
SoRegPoint::SoRegPoint()
{
    SO_NODE_CONSTRUCTOR(SoRegPoint);

    SO_NODE_ADD_FIELD(base, (SbVec3f(0,0,0)));
    SO_NODE_ADD_FIELD(normal, (SbVec3f(1,1,1)));
    SO_NODE_ADD_FIELD(length, (3.0));
    SO_NODE_ADD_FIELD(color, (1.0f, 0.447059f, 0.337255f));
    SO_NODE_ADD_FIELD(text, (""));

    root = new SoSeparator();
    root->ref();

    // translation
    SoTranslation* move = new SoTranslation();
    move->translation.setValue(base.getValue() + normal.getValue() * length.getValue());
    root->addChild(move);

    // sub-group
    SoBaseColor* col = new SoBaseColor();
    col->rgb.setValue(this->color.getValue());

    SoFontStyle* font = new SoFontStyle;
    font->size = 14;

    SoSeparator* sub = new SoSeparator();
    sub->addChild(col);
    sub->addChild(font);
    sub->addChild(new SoText2());
    root->addChild(sub);
}
Example #25
0
SoSeparator *
makescene(void)
{
  SoSeparator * root = new SoSeparator;
  root->addChild(material = new SoMaterial);
  root->addChild(new SoCube);
  return root;
}
Example #26
0
 Private() 
   : sensorCam1(0), sensorCam2(0)
 {
     // left view
     picksepLeft = new SoSeparator;
     picksepLeft->ref();
     // right view
     picksepRight = new SoSeparator;
     picksepRight->ref();
 }
Example #27
0
SoSeparator *glowBranch(SoSeparator *geomHolder, SoMaterial *glowMat)
{
	SoSeparator *root = new SoSeparator();

	SoCallback *stFore = new SoCallback();
	stFore->setCallback(stencilCBfore);
	root->addChild(stFore);

	root->addChild(geomHolder); // 1st / normal instance

	// glow / background
	root->addChild(glowMat);

	SoDrawStyle *glowStyle = new SoDrawStyle();
	glowStyle->style = SoDrawStyle::LINES;
	glowStyle->lineWidth = 4;
	root->addChild(glowStyle);

	SoLightModel *lm = new SoLightModel();
	lm->model = SoLightModel::BASE_COLOR;
	root->addChild(lm);

	SoCallback *stBack = new SoCallback();
	stBack->setCallback(stencilCBback);
	root->addChild(stBack);

	root->addChild(geomHolder); // 2nd / glow instance

	SoCallback *stEnd = new SoCallback();
	stEnd->setCallback(stencilCBend);
	root->addChild(stEnd);

	return root;
}
Example #28
0
SoSeparator * HandObjectState::copyHandStateIV(){
  SoSeparator * graspIVRoot = new SoSeparator();
  //FIXME -- is this necesary?
  graspIVRoot->ref();
  SoNode * handIVRoot = mHand->getIVRoot()->copy(1);
  SoNode * objectIVRoot = mTargetObject->getIVRoot()->copy(1);
  graspIVRoot->addChild(handIVRoot);
  graspIVRoot->addChild(objectIVRoot);

  return graspIVRoot;
} 
Example #29
0
int main()
{
   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, 0.0, 0.0);
   root->addChild(myMaterial);
   root->addChild(new SoCone);
}
Example #30
0
void
callback(void * closure, SoAction * action)
{
  if ( action->isOfType(SoHandleEventAction::getClassTypeId()) ) {
    SoHandleEventAction * heaction =
      (SoHandleEventAction *) action;
    if ( heaction->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId()) ) {
      SoSeparator * sep = (SoSeparator *) closure;
      sep->addChild(NULL); // trigger assert inside Coin
    }
  }
}