Archived

This topic is now archived and is closed to further replies.

ByteMe95

object's local axis?

Recommended Posts

Anyone know what an object''s local axis/center of the object is and what should be done with it? I''m still working on my 3ds laoder and just realized that getting the local axis of the object is necessary for it to look right, but I dont know what to do with the info. Can I simply rotate the object after I load it by a certain amount to compensate? Does anyone know what im talking about? ByteMe95::~ByteMe95() Cerebrum Software

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The term ''objects local axis'' is somewhat incomplete. 2 possibilities:

a) An object has a local coordinate system, that is the original x,y,z coordinate frame (the object''s refrence frame) scaled, rotated and translated by the amounts that you transformed the object within 3DStudio. In reality, 3dsmax multiplies the objects vertices by a local transformation matrix, that represent all the above mentioned transforms. You can see the local coordinate system by selecting the ''local axis'' mode in 3dsmax.
I don''t know about the 3ds format, but 3dsmax typically exports this information as the objects transformation matrix, a 4*3 matrix. If your exporter doesn''t convert the objects vertices into worldspace before exporting, then you will need this matrix
to reposition/scale/rotate your object

2) The object''s local rotation axis and it''s pivot. This is only used for animation and determines the axis of rotation and the rotation origin of the object. You don''t need it, if you don''t animate your object.

Hope it helps

- AH

Share this post


Link to post
Share on other sites
this is the info I have on this chunk of info:
Chunk # : 0x4160
Name : Local coordinate system
Level : 4
Size : 48
Father : 0x4100 (Triangular mesh)
Format :

vector X1
vector X2
vector X3
vector O

X1, X2 and X3 represent the axes, O the origin.

So I can read that in but don''t really understand what it is/what to do with it. CAn I set up a transformation matrix out of that maybe?

ByteMe95::~ByteMe95()
Cerebrum Software

Share this post


Link to post
Share on other sites
AP, theres also possibility
C) objects principal axes. Provided we have a rigid body, principal axes origin point is in the center of mass and its orientation is such that objects mass matrix (inertia tensor ) is diagonal.

But this has probably nothing to do with 3dstudio and ByteMe''s question

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
no way:

> C) objects principal axes. Provided we have a rigid body, principal axes origin point is in the center of mass and its orientation is such that objects mass matrix (inertia tensor ) is diagonal.
Not always, since the inertia tensor is an integration over the object volume (or the sum of inifinite points of inertia integrated over the volume), the orientation of it''s matrix is not always stable. Eg. a perfect sphere, the orientation of the intertia tensor can be arbitrary, even if the sphere''s local coordinate system is still defined.

But you''re right, this has most probably nothing to do with his question

Oh, and I forgot possibility:

d) The coordinate frame of the best fit OBB around the object is sometimes referred as it''s local axes.

ByteMe:
As you can see, ''local axis'' is a widely used term... I honestly have no idea about the 3DS format, but I strongly suspect it to be the transformation matrix of the object (possibility a). And yes, you can get the transformation matrix from the 3 major axes and origin of the local coordinate system.

- AH

Share this post


Link to post
Share on other sites
To my knowledge this is the local coordinate system of the mesh that you currently use (as it is also discribed). If you want to make a transformation matrix from this thing, you just put the vertices x1,x2,x3 and O together to a matrix, where you use 0 as the fourth coordinate of x1, x2 and x3 and 1 as the fourth coordinate of o. Whether you see the vertices as rows or as columns depends on the api you use (I think with D3D you would use them as row vectors, and with ogl you would use them as column vectors... even though I am probably wrong here).
This way you will so to say get the canonical coordinate system transformation matrix.
Maybe I should mention that in 3DS the y vector is not the up vector (I think it is z)... you might have to change the order of x1, x2 and x3 to get correct results... But hell, just try all possibilities ;-)
I hope this helps you in any way...

Share this post


Link to post
Share on other sites
Alright the chunk you mentioned 0x4160 has 12 floats within it.

They specify the local coords in some way.

case OBJECT_MESH_MATRIX:
{
FILE* dbgFile;
dbgFile = fopen("../data/vertex_info.txt", "awt");

// Read the mesh matrix array -- consists of 12 floats 3X4 matrix
float MeshMatrix;
fprintf(dbgFile, "Local Coords: ");

for(int i=0; i<12; i++)
{
m_CurrentChunk->bytesRead += fread(&MeshMatrix, 1, sizeof(float), m_FilePointer);

fprintf(dbgFile, "%f ", MeshMatrix);
}

fprintf(dbgFile, "\n");

fclose(dbgFile);
}
break;

Share this post


Link to post
Share on other sites