本文整理汇总了C++中SoSeparator::getNumChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ SoSeparator::getNumChildren方法的具体用法?C++ SoSeparator::getNumChildren怎么用?C++ SoSeparator::getNumChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoSeparator
的用法示例。
在下文中一共展示了SoSeparator::getNumChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SoScale
IVElement::IVElement(string ivfile, KthReal sc) {
for(int i=0;i<3;i++){
position[i]= 0.0f;
orientation[i]=0.0f;
}
orientation[2]=1.0f;
orientation[3]=0.0f;
scale=sc;
trans= new SoTranslation;
rot = new SoRotation;
sca = new SoScale();
color = new SoMaterial;
posVec = new SoSFVec3f;
trans->translation.connectFrom(posVec);
posVec->setValue((float)position[0],(float)position[1],(float)position[2]);
rotVec = new SoSFRotation;
rotVec->setValue(SbVec3f((float)orientation[0],(float)orientation[1],
(float)orientation[2]),(float)orientation[3]);
rot->rotation.connectFrom(rotVec);
scaVec= new SoSFVec3f;
scaVec->setValue((float)scale,(float)scale,(float)scale);
sca->scaleFactor.connectFrom(scaVec);
SoInput input;
ivmodel = new SoSeparator;
ivmodel->ref();
ivmodel->addChild(sca);
if(input.openFile(ivfile.c_str()))
ivmodel->addChild(SoDB::readAll(&input));
else
{
//ivmodel->addChild(new SoSphere());
static const char *str[] = {
"#VRML V1.0 ascii\n",
"DEF pointgoal Separator {\n",
" Separator {\n",
" MaterialBinding { value PER_PART }\n",
" Coordinate3 {\n",
" point [\n",
" 0.0 0.0 0.0\n",
" ]\n",
" }\n",
" DrawStyle { pointSize 5 }\n",
" PointSet { }\n",
" }\n",
"}\n",
NULL
};
input.setStringArray(str);
SoSeparator *sep = SoDB::readAll(&input);
sep->ref();
while (sep->getNumChildren() > 0)
{
ivmodel->addChild(sep->getChild(0));
sep->removeChild(0);
}
sep->unref();
}
ivmodel->ref();
}
示例2: if
SoCamera *
SoSceneTextureCubeMapP::ensureCamera(void)
{
if (this->hasSceneChanged == FALSE) return this->cachedCamera;
this->hasSceneChanged = FALSE;
SoCamera * camera = this->findCamera();
SbBool hasCamera = (camera != NULL); // does the scene provide a camera?
if (hasCamera) {
if (this->cachedCamera != camera) {
if (this->cachedCamera) this->cachedCamera->unref();
this->cachedCamera = camera;
this->cachedCamera->ref();
}
}
else if (this->hadSceneCamera || this->cachedCamera == NULL) {
// create default camera:
static int didwarn = 0;
if (!didwarn) {
SoDebugError::postWarning("SoSceneTextureCubeMap::ensureCamera",
"The scene does not provide a camera. "
"A perspective camera at position (0,0,0) "
"will be used.");
didwarn = 1;
}
if (this->cachedCamera) this->cachedCamera->unref();
this->cachedCamera = new SoPerspectiveCamera;
this->cachedCamera->position = SbVec3f(0, 0, 0);
this->cachedCamera->nearDistance = 0.1f;
this->cachedCamera->farDistance = 100;
((SoPerspectiveCamera*)this->cachedCamera)->heightAngle =
(float) (M_PI / 2.0f);
this->cachedCamera->ref();
}
assert(this->cachedCamera);
SoNode * scene = PUBLIC(this)->scene.getValue();
if (hasCamera) {
if (scene != this->cachedScene) {
if (this->cachedScene) this->cachedScene->unref();
this->cachedScene = scene;
this->cachedScene->ref();
}
}
else if (this->cachedScene == NULL || this->hadSceneCamera) {
if (this->cachedScene) this->cachedScene->unref();
SoSeparator * root = new SoSeparator();
root->addChild(this->cachedCamera);
root->addChild(scene);
this->cachedScene = (SoNode *)root;
this->cachedScene->ref();
}
else {
assert(this->cachedScene->isOfType(SoSeparator::getClassTypeId()));
SoSeparator * root = (SoSeparator*)this->cachedScene;
assert(root->getNumChildren() == 2);
if (root->getChild(1) != scene)
((SoSeparator *)this->cachedScene)->replaceChild(1, scene);
}
this->hadSceneCamera = hasCamera;
return this->cachedCamera;
}