x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
LoadedPhysObj.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\LoadedPhysObj.cpp
旋转
特效
属性
历史版本
#include "LoadedPhysObj.h" #include "GameScene.h" #include "RecordReplay.h" MyHashTable
LoadedPhysObj::physCollectionPool = MyHashTable
(); LoadedPhysObj::LoadedPhysObj(VisualObject* visualObject):PhysicalObject(visualObject){ //empty } LoadedPhysObj::LoadedPhysObj(const String& resourceName,VisualObject* visualObject): PhysicalObject(visualObject), mPhysCollection(NULL){ initializing(resourceName); } void LoadedPhysObj::initializing(const String& resourceName){ //load physical objects if (physCollectionPool.Exist(resourceName)){ mPhysCollection = physCollectionPool.Get(resourceName); }else{ mPhysCollection = loadCollection((".\\media\\"+resourceName+".xml").c_str(),NXU_FileType::FT_XML); myassert(mPhysCollection!=NULL); physCollectionPool.Put(resourceName, mPhysCollection); } NxMat34 instanceFrame(true); myassert(instanceFrame.isIdentity()); instanceFrame.t = NxVec3(0, 0, 0); //instanceFrame.t = mVisualObject->GetPosition(); instantiateCollection(mPhysCollection, *(GameScene::GetSingleton()->GetPhysicsSDK()), GameScene::GetSingleton()->GetPhysicsScnene(), &instanceFrame,this); tempNum = 0; } void LoadedPhysObj::NXU_notifyActor(NxActor *actor, const char *userProperties){ actorPool.Put(actor); } LoadedPhysObj::~LoadedPhysObj(){ //for (list
::iterator iter = physObjPool.GetPool().begin();iter!=physObjPool.GetPool().end();iter++){ // SAFE_DELETE(*iter); //} //physObjPool->Clear(); for (list
::iterator iter = actorPool.GetPool().begin();iter!=actorPool.GetPool().end();iter++){ NxActor* actor = *iter; GameScene::GetSingleton()->GetPhysicsScnene()->releaseActor(**iter); } actorPool.Clear(); } void LoadedPhysObj::SetCollisionEnable(bool enabled, const Vec3& direction){ //Vec3 dieDirection(Vec3((randomGenerator->Rand()%100)/10.0f-5.0f,(randomGenerator->Rand()%100)/10.0f-5.0f,2.0f)); for (list
::iterator iter = actorPool.GetPool().begin();iter!=actorPool.GetPool().end();iter++){ NxActor* actor = *iter; if (enabled){ tempNum--; //actor->wakeUp(); actor->clearActorFlag(NX_AF_DISABLE_COLLISION); actor->clearActorFlag(NX_AF_DISABLE_RESPONSE); actor->clearBodyFlag(NX_BF_DISABLE_GRAVITY); actor->clearBodyFlag(NX_BF_KINEMATIC); actor->setLinearVelocity(direction); actor->setAngularVelocity(Vec3(0,0,0)); actor->wakeUp(); //actor->setGroup(0); }else{ tempNum++; //actor->setGroup(10); actor->raiseActorFlag(NX_AF_DISABLE_COLLISION); actor->raiseActorFlag(NX_AF_DISABLE_RESPONSE); actor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY); actor->setLinearVelocity(Vec3(0,0,0)); actor->setAngularVelocity(Vec3(0,0,0)); actor->raiseBodyFlag(NX_BF_KINEMATIC);//set velocity to zero actor->putToSleep();//put to inactive state to save CPU } } if (enabled){ if (tempNum!=0){ int aaaa=0; } } }
LoadedPhysObj.cpp
网页地址
文件地址
上一页
27/55
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.