wraith
01072009 09:58:15
I'm trying to rotate an OGRE3DBody according to its local zaxis, but the only orientation methods that seem to be available are relative to global axes, such as setGlobalPose() and setGlobalOrientation(). I feel like I must be overlooking something really simple, but I just can't figure out what. Obviously I can't do this by accessing the SceneNode, so does NxOgre have some functionality to allow it?
gecko386
01072009 12:04:04
Your problem is not a Ogre nor NxOgre problem, it's a Physx Actor problem. In Physx there aren't parent's relationship so all Actors have only their global transformation matrix. The way to obtain the matrix you are looking for is this:
1apply the local transformation to the matrix.
2obtain the global matrix:
to do this you have to do a lefttoright matrix products from the first parent to your actor following the inheritance:
for example:
p1
/\
p2 p3

a
If you want to know what is the global matrix of 'a' you have to multiply LM(p1)*LM(p2)*LM(a), where LM(X) is the local matrix of the node X
It is easy to implement but if there is a large hirearchy this could be inneficient. If you have a hirearchy of n nodes you have to do n matrix products. A better way is to save in each node the global and local matrix. If you want to update one local matrix first apply the local transformation an them update their global matrix using the global matrix of the parent node:
So now GM(a)=GM(p2)*LM(a) where GM(x) is the gloabal matrix of the node x.
It should be more efficient because a hirarchy of n elements allow you to obtain a global matrix with only a matrix product, now the probelm is to ensure the global matrices are always updated.
I think is a bad idea to provide a getLocalPose,..etc family of methods because these methos are easy to implement and lets programmers to choice what is more suitable for their projects.