x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
LoadedVisObj.cpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\LoadedVisObj.cpp
Girar
Efecto
Propiedad
Historial
#include "LoadedVisObj.h" #include "GameScene.h" MyHashTable
LoadedVisObj::refNodePool = MyHashTable
(); LoadedVisObj::LoadedVisObj(const String& resourceName){ mNameSuffix = ""; if (!refNodePool.Exist(resourceName)){ //make reference //SceneNode* newRefNode = GameScene::GetSingleton()->GetSceneManager()->getRootSceneNode()->createChildSceneNode(); loadedScene = new OgreMax::OgreMaxScene(); //GameScene* tt = GameScene::GetSingleton(); try{ loadedScene->Load(resourceName+".scene",GameScene::GetSingleton()->GetRenderWindow() ,OgreMax::OgreMaxScene::NO_OPTIONS); //,GameScene::GetSingleton()->GetSceneManager(),newRefNode); }catch (...){ myassert(false);//load failed throw; } SceneNode* newRefNode = loadedScene->GetSceneManager()->getRootSceneNode(); myassert(newRefNode!=NULL); //SAFE_DELETE(myScene);//TODO: find a way to delete it, but not in destructor //newRefNode->setVisible(false); //newRefNode->getParent()->removeChild(newRefNode);//remove itself refNodePool.Put(resourceName, newRefNode); myassert(refNodePool.Exist(resourceName)==true); } //clone from reference cloneFromReference(resourceName); } LoadedVisObj::~LoadedVisObj(){ } String LoadedVisObj::getModifiedName(const String& originalName)const { return originalName+ mNameSuffix; } SceneNode* LoadedVisObj::cloneSceneNode(const SceneNode* node, SceneNode* newParent){ //NOTE: this function only work if: every node is a scene node, every attached object is an entity //clone the node SceneNode* ret = newParent->createChildSceneNode(/*node->getName()+suffix*/); if (mNameSuffix.empty()) mNameSuffix = ret->getName();//this name is generated by OGRE ret->setPosition(node->getPosition()); ret->setOrientation(node->getOrientation()); ret->setScale(node->getScale()); //clone all child nodes for (Node::ConstChildNodeIterator iter = node->getChildIterator();iter.hasMoreElements();){ SceneNode* element = (SceneNode*)iter.getNext(); cloneSceneNode(element,ret); } //clone all of its entities for (SceneNode::ConstObjectIterator iter2 = node->getAttachedObjectIterator();iter2.hasMoreElements();){ Entity* ent = (Entity*)iter2.getNext(); Entity* newEnt = ent->clone(getModifiedName(ent->getName())); //newEnt->setCastShadows(true); ret->attachObject(newEnt); //clone all bone attachments for (Entity::ChildObjectListIterator iterBone = ent->getAttachedObjectIterator();iterBone.hasMoreElements();){ Entity* attachedEntity = (Entity*)iterBone.getNext(); TagPoint* tagPoint = (TagPoint*)attachedEntity->getParentNode(); Entity* newAttachedEntity = attachedEntity->clone(getModifiedName( attachedEntity->getName() )); String boneName = tagPoint->getParent()->getName(); newEnt->attachObjectToBone(tagPoint->getParent()->getName(),newAttachedEntity,tagPoint->getOrientation(), tagPoint->getPosition()); } } return ret; } void LoadedVisObj::cloneFromReference(const String& resourceName){ myassert(refNodePool.Exist(resourceName)); SceneNode* refNode = refNodePool.Get(resourceName); mNode = cloneSceneNode(refNode,GameScene::GetSingleton()->GetSceneManager()->getRootSceneNode());// (SceneNode*)refNode->getParent()); myassert(mNode!=NULL); _initPositionOrientation(); }
LoadedVisObj.cpp
Dirección de la página
Dirección del archivo
Anterior
29/55
Siguiente
Descargar
( 3 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.