I am have a very frustrating time trying to figure out how to make PhysX and DirectX 9 behave well together.
I have been able to make it so that I can get the position of the cubes from the PhysX system and position them with DirectX.
I have also been able to get the scale correct.
The problem is that I can't seem to figure out how to get the rotation from PhysX system and apply it to my DirectX World Matrix.
The cubes or spheres drop and bounce and expected however they are "frozen" on all axis. They don't spin/rotate as you would expect.
my code is:
PxMat44 world;
D3DXMATRIX World, mTrans, mScale, mRot;
D3DXMatrixIdentity( &World );
world = physx::PxMat44(physx::PxMat33( worldObject->dynamicActors[num]->getGlobalPose().q), worldObject->dynamicActors[num]->getGlobalPose().p) ;
PxMat44 matrix4(worldObject->dynamicActors[num]->getGlobalPose());
//D3DXVECTOR3 pos,scale, rot;
//rot.x = worldObject->dynamicActors[num]->getGlobalPose().q.x;
//rot.y = worldObject->dynamicActors[num]->getGlobalPose().q.y;
//rot.z = worldObject->dynamicActors[num]->getGlobalPose().q.z;
D3DXVECTOR3 scale;
scale.x = worldObject->WorldInstancesMatrix[num]._11;
scale.y = worldObject->WorldInstancesMatrix[num]._22;
scale.z = worldObject->WorldInstancesMatrix[num]._33;
D3DXMatrixScaling( &mScale, scale.x,scale.y,scale.z);
world.column0[0] = scale.x;
world.column1[1] = scale.y;
world.column2[2] = scale.z;
memcpy( &World, &world, 4 * 4 * sizeof(float) );
I "think" that I am getting the rotation correctly from PhysX with getGlobalPose.q ; however I'm not certain how to apply this to a Directx 9 Matrix
Any help would go a very long way.
Thank you.