本文整理汇总了C++中SoSeparator::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSeparator::setName方法的具体用法?C++ SoSeparator::setName怎么用?C++ SoSeparator::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSeparator
的用法示例。
在下文中一共展示了SoSeparator::setName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildFirstInstance
void RDragger::buildFirstInstance()
{
SoGroup *geometryGroup = buildGeometry();
SoSeparator *localRotator = new SoSeparator();
localRotator->setName("CSysDynamics_RDragger_Rotator");
localRotator->addChild(geometryGroup);
SoFCDB::getStorage()->addChild(localRotator);
SoSeparator *localRotatorActive = new SoSeparator();
localRotatorActive->setName("CSysDynamics_RDragger_RotatorActive");
SoBaseColor *colorActive = new SoBaseColor();
colorActive->rgb.setValue(1.0, 1.0, 0.0);
localRotatorActive->addChild(colorActive);
localRotatorActive->addChild(geometryGroup);
SoFCDB::getStorage()->addChild(localRotatorActive);
}
示例2: getChildByName
SoSeparator * Renderer::getOrAddSeparator(SoSeparator * ivRoot, SbName & childName)
{
SoNodeList children = getChildByName(ivRoot, childName);
if(children.getLength())
return static_cast<SoSeparator *>(children[0]);
else
{
SoSeparator * newChild = new SoSeparator();
newChild->setName(childName);
ivRoot->addChild(newChild);
return newChild;
}
}
示例3:
// This is a helper function for debugging purposes: it sets up a
// small scene graph that shows the geometry of the SbXfBox3f input
// argument, with the identity tag at it's corner.
static SoSeparator *
make_scene_graph(const SbXfBox3f & xfbox, const char * tag)
{
SoSeparator * root = new SoSeparator;
root->setName(tag);
// Add the geometry for the projected SbXfBox3f.
const SbBox3f projbox = xfbox.project();
SoCoordinate3 * coord3;
SoIndexedLineSet * ils;
make_scene_graph(projbox, coord3, ils);
root->addChild(coord3);
root->addChild(ils);
// Add the geometry for the non-projected SbXfBox3f.
SoBaseColor * basecol = new SoBaseColor;
basecol->rgb.setValue(SbColor(1, 1, 0));
root->addChild(basecol);
SoMatrixTransform * transform = new SoMatrixTransform;
transform->matrix = xfbox.getTransform();
root->addChild(transform);
const SbBox3f & box3f = static_cast<const SbBox3f &>(xfbox);
SoCoordinate3 * xfcoord3;
SoIndexedLineSet * xfils;
make_scene_graph(box3f, xfcoord3, xfils);
root->addChild(xfcoord3);
root->addChild(xfils);
SoSeparator * tagsep = new SoSeparator;
root->addChild(tagsep);
SoBaseColor * textcol = new SoBaseColor;
textcol->rgb.setValue(SbColor(1, 0, 0));
tagsep->addChild(textcol);
SoTranslation * translation = new SoTranslation;
translation->translation = xfcoord3->point[0];
tagsep->addChild(translation);
SoText2 * tagtext = new SoText2;
tagtext->string = tag;
tagsep->addChild(tagtext);
return root;
}
示例4: getIvScene
SoSeparator* IVWorkSpace::getIvScene(bool bounding){
if(scene == NULL){
if(robots.size() != 0){
scene = new SoSeparator();
//scene->addChild(SoUnits::MILLIMETERS);
for(unsigned int i=0; i<robots.size(); i++)
scene->addChild((SoSeparator*)robots[i]->getModel());
for(unsigned int i=0; i<obstacles.size(); i++){
SoSeparator* sep = (SoSeparator*)obstacles[i]->getModel();
char str[20];
sprintf(str,"obstacle%d",i);
sep->setName(str);
scene->addChild(sep);
//scene->addChild((SoSeparator*)obstacles[i]->getModel());
}
for(unsigned int i=0; i<_mobileObstacle.size(); i++)
scene->addChild((SoSeparator*)_mobileObstacle[i]->getModel());
scene->ref();
}
}
/* The following does not work properly when cildren should be accesseb by labels.
The scene pointer should be returned instead.*/
/*
SoSeparator* temp = new SoSeparator();
temp->addChild(scene);
temp->ref();
if(bounding)
temp->addChild(calculateBoundingBox(scene));
return temp;
*/
//comporvacio
//SoNode *sepgrid = scene->getByName("obstacle1");
//int c = scene->findChild(sepgrid);
//scene->removeChild(sepgrid);
if(bounding)
scene->addChild(calculateBoundingBox(scene));
return scene;
}
示例5: doc_insert_geometric_object
int QilexDoc::doc_insert_geometric_object(QDomElement geom_element)
{
int error = 0;
const char * buffer;
SbVec3f joinax;
SoTransform *pos_rot = new SoTransform;
float joinangle;
float pos_x, pos_y, pos_z, pos_rx, pos_ry, pos_rz;
QString data, name;
QDomNode node;
QDomElement element;
QDomNodeList list;
SoSeparator *geomelement = new SoSeparator;
SoSeparator *geomtest = new SoSeparator;
name = geom_element.attribute ("name", QString::null);
data = geom_element.attribute ("pos_x", QString::null);
pos_x = data.toFloat();
data = geom_element.attribute ("pos_y", QString::null);
pos_y = data.toFloat();
data = geom_element.attribute ("pos_z", QString::null);
pos_z = data.toFloat();
data = geom_element.attribute ("pos_rx", QString::null);
pos_rx = data.toFloat();
data = geom_element.attribute ("pos_ry", QString::null);
pos_ry = data.toFloat();
data = geom_element.attribute ("pos_rz", QString::null);
pos_rz = data.toFloat();
data = geom_element.attribute ("pos_angle", QString::null);
joinangle = data.toFloat();
joinax.setValue(SbVec3f( pos_x, pos_y, pos_z));
pos_rot->translation.setValue(joinax);
pos_rot->rotation.setValue(SbVec3f(pos_rx, pos_ry, pos_rz), (float) rad((double)joinangle));
list = geom_element.elementsByTagName ("model3d");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
data = element.attribute ("format", QString::null);
// some stuff to take care about the format
data = element.attribute ("size", QString::null);
size_t size = (size_t)data.toULong(0,10);
buffer = new char[size];
data = element.text();
buffer = data.ascii();
SoInput input;
input.setBuffer((void*) buffer, size);
if (input.isValidBuffer())
{
geomelement = SoDB::readAll(&input);
if (geomelement == NULL)
error = 10;
}
else
{error = 8;} // assigno un nombre diferent de 0
}
else
{ error =9; }// assigno un nombre diferent de 0
if (error == 0)
{
geomelement->ref();
geomtest = (SoSeparator*)SoNode::getByName(name.latin1());
if (geomtest==NULL)
{
//we need to put it in a buffer to write the xml file
// if is Ok
geomelement->insertChild(pos_rot, 0);
geomelement->setName(name.latin1());
view->addObjectCell(geomelement);
}
}
return error;
}
示例6: doc_insert_kinematic_chain
//.........这里部分代码省略.........
QDomNode node;
QDomElement element;
name = kine_element.attribute ("name", QString::null);
data = kine_element.attribute ("kineengine", QString::null);
// here put some stuff to select the kinechain engine
data = kine_element.attribute ("pos_x", QString::null);
pos_x = data.toFloat();
data = kine_element.attribute ("pos_y", QString::null);
pos_y = data.toFloat();
data = kine_element.attribute ("pos_z", QString::null);
pos_z = data.toFloat();
data = kine_element.attribute ("pos_rx", QString::null);
pos_rx = data.toFloat();
data = kine_element.attribute ("pos_ry", QString::null);
pos_ry = data.toFloat();
data = kine_element.attribute ("pos_rz", QString::null);
pos_rz = data.toFloat();
data = kine_element.attribute ("pos_angle", QString::null);
joinangle = data.toFloat();
joinax.setValue(SbVec3f( pos_x, pos_y, pos_z));
pos_rot->translation.setValue(joinax);
pos_rot->rotation.setValue(SbVec3f(pos_rx, pos_ry, pos_rz), (float) rad((double)joinangle));
list = kine_element.elementsByTagName ("kinechain");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
error = kineengine->read_element_xml (element);
}
else
{ error =4;} // assigno un nombre diferrent de 0
list = kine_element.elementsByTagName ("model3d");
if (list.length() == 1)
{
node = list.item(0);
element = node.toElement();
data = element.attribute ("format", QString::null);
// some stuff to take care about the format
data = element.attribute ("size", QString::null);
size_t size = (size_t)data.toULong(0,10);
buffer = new char[size];
data = element.text();
buffer = data.ascii();
/* char *buffer2 = new char[size];
for(unsigned i=0;i<size;i++)
buffer2[i] = buffer[i];
*/
SoInput input;
input.setBuffer((void *)buffer, size);
if (input.isValidBuffer())
{
kinechain = SoDB::readAll(&input);
if (kinechain == NULL)
error = 10;
}
else
{error = 8;} // assigno un nombre diferent de 0
}
else
{ error =9; }// assigno un nombre diferent de 0
if (error == 0)
{
kinechain->ref();
kinetest = (SoSeparator*)SoNode::getByName(name.latin1());
if (kinetest==NULL)
{
//we need to put it in a buffer to write the xml file
// if is Ok
kinechain->insertChild(pos_rot, 0);
kinechain->setName(name.latin1());
error = doc_insert_kinematic_chain(kineengine, kinechain);
}
}
else {error = 5;}
return error;
}
示例7: doc_new_grasping_object
//.........这里部分代码省略.........
SoTransform *grasp_transf0 = new SoTransform;
SoSeparator *text0 = new SoSeparator;
SoText2 *label_text0 = new SoText2;
SoSeparator *grasp_sep1 = new SoSeparator;
SoTransform *grasp_transf1 = new SoTransform;
SoSeparator *text1 = new SoSeparator;
SoText2 *label_text1 = new SoText2;
SoSeparator *grasp_sep2 = new SoSeparator;
SoTransform *grasp_transf2 = new SoTransform;
SoSeparator *text2 = new SoSeparator;
SoText2 *label_text2 = new SoText2;
SoSeparator *grasp_sep3 = new SoSeparator;
SoTransform *grasp_transf3 = new SoTransform;
SoSeparator *text3 = new SoSeparator;
SoText2 *label_text3 = new SoText2;
//for (int i=0;i<data->num_point;i++)
//{
joingrasp0.setValue(SbVec3f(data->grasp_points[0].px,data->grasp_points[0].py,data->grasp_points[0].pz));
grasp_transf0->translation.setValue(joingrasp0);
grasp_transf0->recenter(joingrasp0);
label_text0->string=" 1";
text0->addChild(font);
text0->addChild(label_text0);
grasp_sep0->addChild(bronze);
grasp_sep0->addChild(grasp_transf0);
grasp_sep0->addChild(grasp_sphere);
grasp_sep0->addChild(text0);
//grasp_sep0->addChild(line0);
joingrasp1.setValue(SbVec3f(data->grasp_points[1].px,data->grasp_points[1].py,data->grasp_points[1].pz));
grasp_transf1->translation.setValue(joingrasp1);
grasp_transf1->recenter(joingrasp1);
label_text1->string=" 2";
text1->addChild(font);
text1->addChild(label_text1);
grasp_sep1->addChild(bronze);
grasp_sep1->addChild(grasp_transf1);
grasp_sep1->addChild(grasp_sphere);
grasp_sep1->addChild(text1);
joingrasp2.setValue(SbVec3f(data->grasp_points[2].px,data->grasp_points[2].py,data->grasp_points[2].pz));
grasp_transf2->translation.setValue(joingrasp2);
grasp_transf2->recenter(joingrasp2);
label_text2->string=" 3";
text2->addChild(font);
text2->addChild(label_text2);
grasp_sep2->addChild(bronze);
grasp_sep2->addChild(grasp_transf2);
grasp_sep2->addChild(grasp_sphere);
grasp_sep2->addChild(text2);
joingrasp3.setValue(SbVec3f(data->grasp_points[3].px,data->grasp_points[3].py,data->grasp_points[3].pz));
grasp_transf3->translation.setValue(joingrasp3);
grasp_transf3->recenter(joingrasp3);
label_text3->string=" 4";
text3->addChild(font);
text3->addChild(label_text3);
grasp_sep3->addChild(bronze);
grasp_sep3->addChild(grasp_transf3);
grasp_sep3->addChild(grasp_sphere);
grasp_sep3->addChild(text3);
//object->addChild(grasp_sep);
//}
if (error == 0)
{
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());
//grasp_object->addChild(model_object);
object->addChild(grasp_sep0);
object->addChild(grasp_sep1);
object->addChild(grasp_sep2);
object->addChild(grasp_sep3);
object->insertChild(pos_rot, 0);
view->addObjectCell(object);
error = 0;
//writeXML_geomelement((char *)buffer, sizeModel, tipus, data);
//S'ha de canviar!!!!!
}
else
{
object->unref();
error = 3;
}
}
}
return error;
}
示例8: 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;
}
示例9: startUpScene
// Forward Declarations
SoSeparator* startUpScene(SoNode* avatar)
{
//**************************************************************
// ================ STARTING WORLD STRUCTURE ==================
// Separator (root0)
// |
// Selection Node (root)__ ----> selection_callback
// |______________ ----> un_select_callback
// |
// Camera Node
// |
// World Skeleton & Floor
// from external files
// |
// Avatar ( Separator )
// |
// Event Callback Node (for keyboard) -->kbd_callback function
// |
// One Shot sensor ( repeat keyboard status check )
// _____________________|_________________________________
// | | | |
// Separator Separator Separator Separator
//(sciences area) (bioSciences) (Arts Area) (Unassigned area)
// | | | |
// Translation Translation Translation Translation
//
//**************************************************************
// callbacks for selecting objects
SoSelection* root = new SoSelection;
selection = root;
root->ref();
root->addSelectionCallback( made_selection, (void *)1L );
root->addDeselectionCallback( made_selection, (void *)0L );
root->policy = SoSelection::TOGGLE;
//CAMERA
camera = new SoPerspectiveCamera();
camera->nearDistance = 4;
camera->farDistance = 4096;
root->addChild( camera );
root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/world.wrl") );
root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/grass.wrl") );
root->addChild( avatar );
////////// move camera and avatar with directional keys
// keyboard handling
SoEventCallback *cb = new SoEventCallback;
cb->addEventCallback(SoKeyboardEvent::getClassTypeId(), keyboardEvent_cb, NULL);
root->insertChild(cb, 0);
// sensor for infinite processing of simulationStep
SoOneShotSensor *sensor = new SoOneShotSensor(simulationStep, NULL);
sensor->schedule();
SoSeparator* scienceArea = new SoSeparator;
SoTranslation* sciTransl = new SoTranslation;
sciTransl->translation.setValue(150, 0 ,150 );
scienceArea->setName(VRML_UTILS_SCIENCES_AREA_NAME);
root->addChild( scienceArea );
scienceArea->addChild( sciTransl );
scienceArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_sci.wrl") );
SoSeparator* bioArea = new SoSeparator;
SoTranslation* bioTransl = new SoTranslation;
bioTransl->translation.setValue(-150, 0 ,150 );
bioArea->setName(VRML_UTILS_BIO_AREA_NAME);
root->addChild( bioArea );
bioArea->addChild( bioTransl );
bioArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_bio.wrl") );
SoSeparator* artsArea = new SoSeparator;
SoTranslation* artsTransl = new SoTranslation;
artsTransl->translation.setValue(150, 0 ,-150 );
artsArea->setName(VRML_UTILS_ARTS_AREA_NAME);
root->addChild( artsArea );
artsArea->addChild( artsTransl );
artsArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_arts.wrl") );
SoSeparator* freeArea = new SoSeparator;
SoTranslation* freeTransl = new SoTranslation;
freeTransl->translation.setValue(-150, 0 ,-150 );
freeArea->setName(VRML_UTILS_FREE_AREA_NAME);
root->addChild( freeArea );
freeArea->addChild( freeTransl );
freeArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_free.wrl") );
// load resources from server
root->unrefNoDelete();
return root;
}