This is not really related to Ogre, but I though you guys had encountered this before.
I'm trying to make 3DS importer at the moment. I now read all the necessary information, but it looks like I have not anough brain to use it.
The problem is the following (quite common, I think, but was not able to find a solution for quite a while):
1. 3DS has tree-like structure of model parts for animation. Each part (object) has its own Local Coordinate system which is basically 3 Axis Vectors and and Origin.
2. Suppose I have just two objects and the second one is a child of the first one, so when the first one is rotated/translated/scaled the second one should be rotated/translated/scaled as well (as far as I understand).
Now I just do not know what to do with those Local Coordinate systems to display the whole model correctly.
I was trying different approaches, but none of them proved to be right.
One of them is:
// world coordinate system is identity
D3DXMATRIX mWorld;
D3DXMatrixIdentity(&mWorld);
// Create a matrix 4x4 using LCS info:
D3DXMATRIX mLocal(
pObj->sLCS.sAxis1.x, pObj->sLCS.sAxis2.x, pObj->sLCS.sAxis3.x, 0,
pObj->sLCS.sAxis1.y, pObj->sLCS.sAxis2.y, pObj->sLCS.sAxis3.y, 0,
pObj->sLCS.sAxis1.z, pObj->sLCS.sAxis2.z, pObj->sLCS.sAxis3.z, 0,
0, 0, 0, 1);
// Then invert it:
D3DXMATRIX mLocalInv;
D3DXMatrixInverse(&mLocalInv, NULL, &mLocal);
// Calculate the coordinate system transition matrix
D3DXMATRIX mRot = mWorld * mLocalInv;
// Then I transformed vertices
D3DXVec3TransformCoordArray(...)
The result is even worse than not transforming them at all.
The questions are:
1. What is wrong and where do I fit the LCS's Origin?
2. What do I do with parent-child relation? Should I apply parents transformation matrix to the child first and then apply child's transformation matrix? Or should I do something else entirely.
Thank you in advance for any hints. This stuff drives me crazy.
