calsmurf2904
21-02-2009 12:57:06
Hi,
Since you guys are the PhysX experts with Ogre I wanted to ask you some stuff.
I'm using plain PhysX code...so no NxOgre code (srry).
I have a question about how you did it.
I'm trying to convert a OgreMesh to NxTriangleMesh by using this code:
It does create the NxTriangleMesh without errors but it gives a error when using it.
I don't know whats causing it....when I use a NxBoxShapeDesc it works correctly.
Could someone help me please?
(BTW:If this is not allowed in this forum then please delete this topic.)
Since you guys are the PhysX experts with Ogre I wanted to ask you some stuff.
I'm using plain PhysX code...so no NxOgre code (srry).
I have a question about how you did it.
I'm trying to convert a OgreMesh to NxTriangleMesh by using this code:
void PhysicsObject::addOgreSceneNode(Ogre::SceneNode* mNode,float Mass)
{
NxActorDesc mActorBase;
for(int i = 0;i<mNode->numChildren();i++)
{
Ogre::SceneNode* mSceneNode = static_cast<Ogre::SceneNode*>(mNode->getChild(i));
Ogre::Entity* mEntity = static_cast<Ogre::Entity*>(mSceneNode->getAttachedObject(0));
Ogre::Mesh* mMesh = mEntity->getMesh().getPointer();
size_t mVerticesCount,mIndicesCount;
Ogre::Vector3* mVertices;
unsigned long* mIndices;
getMeshInformation(mMesh,mVerticesCount,mVertices,mIndicesCount,mIndices,Ogre::Vector3::ZERO,Ogre::Quaternion::IDENTITY,Ogre::Vector3::UNIT_SCALE);
NxTriangleMeshDesc mMeshDesc;
mMeshDesc.setToDefault();
mMeshDesc.numTriangles = mIndicesCount/3;
mMeshDesc.numVertices = mVerticesCount;
mMeshDesc.points = mVertices;
mMeshDesc.pointStrideBytes = sizeof(Ogre::Vector3);
mMeshDesc.triangles = mIndices;
mMeshDesc.triangleStrideBytes = sizeof(unsigned long)*3;
NxBuffer mBuffer;
NxGetCookingLib(NX_PHYSICS_SDK_VERSION)->NxCookTriangleMesh(mMeshDesc,mBuffer);
NxTriangleMesh* mTriangleMesh = mSDK->createTriangleMesh(mBuffer);
NxTriangleMeshShapeDesc mShapeDesc;
mShapeDesc.meshData = mTriangleMesh;
mShapeDesc.localPose.t = NxVec3(mSceneNode->getPosition().x,mSceneNode->getPosition().y,mSceneNode->getPosition().z);
mActorBase.shapes.push_back(&mShapeDesc);
};
NxBodyDesc mBodyDesc;
mActorBase.body = &mBodyDesc;
NxActor* mActor = mScene->createActor(mActorBase);
if(mActor == NULL)
{
throw Ogre::Exception(0,"Failed to create NxActor.",__FUNCTION__);
};
mActors[mNode->getName().c_str()] = std::pair< std::pair< Ogre::Vector3, Ogre::SceneNode*>, std::pair< NxVec3, NxActor*>>(std::pair< Ogre::Vector3, Ogre::SceneNode*>(mNode->getPosition(),mNode),std::pair< NxVec3, NxActor*>(mActorBase.globalPose.t,mActor));
};
It does create the NxTriangleMesh without errors but it gives a error when using it.
I don't know whats causing it....when I use a NxBoxShapeDesc it works correctly.
Could someone help me please?
(BTW:If this is not allowed in this forum then please delete this topic.)