本文整理汇总了C++中SoSeparator类的典型用法代码示例。如果您正苦于以下问题:C++ SoSeparator类的具体用法?C++ SoSeparator怎么用?C++ SoSeparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoSeparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exit
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;
}
示例2: attach
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");
}
示例3: ASSERT
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);
}
示例4: baseWidth
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);
}
}
示例5: createCameraObject
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);
}
}
示例6: Ecliptic
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;
}
示例7: 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;
}
示例8: SoSeparator
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;
}
示例9: QString
/*!
* 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;
}
示例10: QString
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;
}
示例11: Rchain_hand
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;
}
示例12: SbVec3f
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 () );
}
示例13: removeVector
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;
}
示例14: while
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++;
}
}
示例15: 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;
}