本文整理汇总了C++中SoGroup::replaceChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SoGroup::replaceChild方法的具体用法?C++ SoGroup::replaceChild怎么用?C++ SoGroup::replaceChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoGroup
的用法示例。
在下文中一共展示了SoGroup::replaceChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMaterialForPath
void
IfReplacer::replaceMaterials(SoNode *sceneRoot, const SoType &typeToReplace)
{
// Find all nodes of the given type
SoSearchAction sa;
sa.setType(typeToReplace);
sa.setInterest(SoSearchAction::ALL);
sa.apply(sceneRoot);
// Replace the tail of each path with a material. To do this, we
// need to apply an SoCallbackAction to the path to gather the
// material components.
for (int i = 0; i < sa.getPaths().getLength(); i++) {
// Cast the path to a full path, just in case
SoFullPath *path = (SoFullPath *) sa.getPaths()[i];
ASSERT(path->getTail()->isOfType(typeToReplace));
// The path better have at least one group above the material
if (path->getLength() < 2 ||
! path->getNodeFromTail(1)->isOfType(SoGroup::getClassTypeId()))
continue;
// Create a material node that represents the material in
// effect at the tail of the path
SoMaterial *newMaterial = createMaterialForPath(path);
newMaterial->ref();
// Replace the tail node with that material
SoGroup *parent = (SoGroup *) path->getNodeFromTail(1);
parent->replaceChild(path->getTail(), newMaterial);
newMaterial->unref();
}
}
示例2: getSoRenderManager
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::setCameraType(SoType type)
{
if(!getSoRenderManager()->getCamera()->isOfType(SoPerspectiveCamera::getClassTypeId()) &&
!getSoRenderManager()->getCamera()->isOfType(SoOrthographicCamera::getClassTypeId())) {
Base::Console().Warning("Quarter::setCameraType",
"Only SoPerspectiveCamera and SoOrthographicCamera is supported.");
return;
}
SoType perspectivetype = SoPerspectiveCamera::getClassTypeId();
SbBool oldisperspective = getSoRenderManager()->getCamera()->getTypeId().isDerivedFrom(perspectivetype);
SbBool newisperspective = type.isDerivedFrom(perspectivetype);
if((oldisperspective && newisperspective) ||
(!oldisperspective && !newisperspective)) // Same old, same old..
return;
SoCamera* currentcam = getSoRenderManager()->getCamera();
SoCamera* newcamera = (SoCamera*)type.createInstance();
// Transfer and convert values from one camera type to the other.
if(newisperspective) {
convertOrtho2Perspective((SoOrthographicCamera*)currentcam,
(SoPerspectiveCamera*)newcamera);
}
else {
convertPerspective2Ortho((SoPerspectiveCamera*)currentcam,
(SoOrthographicCamera*)newcamera);
}
getSoRenderManager()->setCamera(newcamera);
getSoEventManager()->setCamera(newcamera);
//if the superscene has a camera we need to replace it too
SoSeparator* superscene = (SoSeparator*) getSoRenderManager()->getSceneGraph();
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setType(SoCamera::getClassTypeId());
sa.apply(superscene);
if(sa.getPath()) {
SoNode* node = sa.getPath()->getTail();
SoGroup* parent = (SoGroup*) sa.getPath()->getNodeFromTail(1);
if(node && node->isOfType(SoCamera::getClassTypeId())) {
parent->replaceChild(node, newcamera);
}
}
};