x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
LoadedVisObj.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\LoadedVisObj.cpp
旋转
特效
属性
历史版本
#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
网页地址
文件地址
上一页
29/55
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.