YuanCheng's Blog

C++博客 联系 聚合 管理
  1 Posts :: 5 Stories :: 0 Comments :: 0 Trackbacks
整合Ogre和Physx方法:

(1):将Physx的NxActor的userData指针指向Ogre的SceneNode:

frameStarted():

NxScene* PhScene;

PhScene
->simulate(elapsedTime);
        PhScene
->flushStream();
        PhScene
->fetchResults(NX_RIGID_BODY_FINISHED,false);
        


        NxU32 nb
=PhScene->getNbActors();
        NxActor
** actors=PhScene->getActors();


        
while(nb--)
        
{

            NxActor
* actor=*actors++;

            
if(!actor->isDynamic()) continue;
            
if(actor->isSleeping()) continue;
            
if(!actor->userData) continue;
            
            Ogre::SceneNode 
* node=(Ogre::SceneNode*)actor->userData;
            

            NxMat34 nm
=actor->getGlobalPose();
            NxVec3 pos(nm.t);
            NxQuat quat(nm.M);
            node
->setPosition(pos.x,pos.y,pos.z);
            node
->setOrientation(quat.w,quat.x,quat.y,quat.z);

                    
            
        }


(2):建立一个SceneNode和NxActor的对应表
//code.....
posted on 2007-12-11 19:50 YuanCheng 阅读(1881) 评论(0)  编辑 收藏 引用 所属分类: Computer

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理