//! //! Creates a copy of the given scene node. //! //! \param sceneNode The scene node to copy. //! \param name The name to use for the copied scene node. //! \param sceneManager The scene manager to use for creating the scene node. //! \return A copy of the given scene node. //! Ogre::SceneNode * OgreTools::copySceneNode ( Ogre::SceneNode *sceneNode, const QString &name, Ogre::SceneManager *sceneManager /* = 0 */ ) { // make sure the given scene node is valid if (!sceneNode) { Log::error("The given scene node is invalid.", "OgreTools::copySceneNode"); return 0; } // make sure a valid scene manager is available if (!sceneManager) sceneManager = sceneNode->getCreator(); if (!sceneManager) { Log::error("No valid scene manager available.", "OgreTools::copySceneNode"); return 0; } // check if a scene node of the given name already exists if (sceneManager->hasSceneNode(name.toStdString())) { Log::error(QString("The scene manager already contains a scene node named \"%1\".").arg(name), "OgreTools::copySceneNode"); return 0; } // create the scene node copy Ogre::SceneNode *sceneNodeCopy = sceneManager->createSceneNode(name.toStdString()); if (!sceneNodeCopy) { Log::error("The scene node copy could not be created.", "OgreTools::copySceneNode"); return 0; } // create a container for the scene node copy OgreContainer *sceneNodeCopyContainer = new OgreContainer(sceneNodeCopy); sceneNodeCopy->setUserAny(Ogre::Any(sceneNodeCopyContainer)); const Ogre::Any &userAny = sceneNode->getUserAny(); userAny.isEmpty(); if (!sceneNode->getUserAny().isEmpty()) { OgreContainer *sceneNodeContainer = Ogre::any_cast<OgreContainer *>(sceneNode->getUserAny()); if (sceneNodeContainer) QObject::connect(sceneNodeContainer, SIGNAL(sceneNodeUpdated()), sceneNodeCopyContainer, SLOT(updateSceneNode())); } // copy parameters from scene node to scene node copy //sceneNodeCopy->setAutoTracking(...); //sceneNodeCopy->setCustomParameter(...); //sceneNodeCopy->setDebugDisplayEnabled(...); //sceneNodeCopy->setDirection(...); //sceneNodeCopy->setFixedYawAxis(...); sceneNodeCopy->setInheritOrientation(sceneNode->getInheritOrientation()); sceneNodeCopy->setInheritScale(sceneNode->getInheritScale()); //sceneNodeCopy->setInitialState(...); //sceneNodeCopy->setInSceneGraph(...); sceneNodeCopy->setListener(sceneNode->getListener()); sceneNodeCopy->setOrientation(sceneNode->getOrientation()); //sceneNodeCopy->setParent(...); sceneNodeCopy->setPolygonModeOverrideable(sceneNode->getPolygonModeOverrideable()); sceneNodeCopy->setPosition(sceneNode->getPosition()); //sceneNodeCopy->setRenderSystemData(...); sceneNodeCopy->setScale(sceneNode->getScale()); sceneNodeCopy->setUseIdentityProjection(sceneNode->getUseIdentityProjection()); sceneNodeCopy->setUseIdentityView(sceneNode->getUseIdentityView()); //sceneNodeCopy->getUserAny(...); //sceneNodeCopy->setVisible(...); return sceneNodeCopy; }