if (m_NxActor)
{
NxMat33 mat;
float A = cos(rot.X);
float B = sin(rot.X);
float C = cos(rot.Y);
float D = sin(rot.Y);
float E = cos(rot.Z);
float F = sin(rot.Z);
float AD = A * D;
float BD = B * D;
mat.setRow(0,NxVec3(C * E, -C * F, D));
mat.setRow(1,NxVec3(BD * E + A * F, -BD * F + A * E, -B * C));
mat.setRow(2,NxVec3(-AD * E + B * F, AD * F + B * E, A * C));
m_NxActor->setGlobalOrientation(mat);
}
No problem. For anyone else stumbling on troubles integrating irrlicht with Physx and getting the correct way to convert vectors, matrices and rotations etc between the two SDKs then feel free to check out IrrPhysx. It's got some good conversion functions in there which you're free to steal if you don't want to actually use IrrPhysx
You said it creates a static object, so how can I create a dynamic object? Any suggestion for that? Because I am load my node from a .X file and want to create a dynamic actor for it.
Well what is the object? What do you want to do with it? Check out the examples and you'll see some various things you could do. You could create a convex mesh object from it, like the letter models in the mesh example or you could create a box/sphere/capsule object for it. Or you could create an object which is built up from various boxes/spheres/capsules to create a more complicated shape which might wrap nicely around your model.
Is it a model which will just be a non-moving object that would like be possible to knock over but not actually move by itself, only if hit by something? Or is it a character/enemy in your game which you want to have moved around?
Thx JP for your reply, yeah it's a model that I load from a .x file. I put the model's verticies and indices into a triangle mesh but then it became static, even though I set property for body to be dynamic.
So I should build up various shapes just to cover up my entire model? Is there any easy way of doing it? Is it I must first get the skeleton of the model? Sorry but I have no clue on how to do it that's why I cooked the mesh in the triangle mesh.
Or any thread that post this problem will be helpful.
I will look at your wrapper again tomorrow, hopefully can find lots of clues from it.
Triangle meshes in Physx are always static, you can't make them dynamic, I guess that may be for performance reasons or something...
So this is an animated character in your game? In that case i would suggest a ragdoll approach, so basically make up a ragdoll in Physx and attach it to the model's skeleton, then you should basically have shapes around all the body parts of your model for collision. Then what you'd do is let the animation drive the transformation of the ragdoll body parts when your character is walking around and then if you want your character to die and crumple into a heap then you just flip the process on its head and instead let the ragdoll physics objects dictate where the model's bones should be. This is something i'm planning for (probably) the next version of IrrPhysx but i don't know when that will be released, can't make any promises! If you do any of this stuff yourself i'd love to hear how it goes and what problems you may or may not run into!