#### Archived

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

# 3DS Max coordinate system

This topic is 5907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Another question about max export plugins ... (thanks simon for the web site you indicate to me in your las post) I would like to transform matrix and vertex information from max coordinate system to a right handed system in order to have the object at the right place and with the right orientation. for the vertex I do this : vertices[adjIndiceVertex].x = maxMesh->verts[indiceVertex].x; vertices[adjIndiceVertex].y = maxMesh->verts[indiceVertex].z; vertices[adjIndiceVertex].z = -maxMesh->verts[indiceVertex].y; and for the matrices : vect = objectOffsetTM.GetRow(0); resObjectOffsetTM.m[0][0] = vect.x; resObjectOffsetTM.m[0][1] = vect.z; resObjectOffsetTM.m[0][2] = -vect.y; resObjectOffsetTM.m[0][3] = 0.0f; vect = objectOffsetTM.GetRow(2); resObjectOffsetTM.m[1][0] = vect.x; resObjectOffsetTM.m[1][1] = vect.z; resObjectOffsetTM.m[1][2] = -vect.y; resObjectOffsetTM.m[1][3] = 0.0f; vect = objectOffsetTM.GetRow(1); resObjectOffsetTM.m[2][0] = vect.x; resObjectOffsetTM.m[2][1] = vect.z; resObjectOffsetTM.m[2][2] = -vect.y; resObjectOffsetTM.m[2][3] = 0.0f; vect = objectOffsetTM.GetTrans(); resObjectOffsetTM.m[3][0] = vect.x; resObjectOffsetTM.m[3][1] = vect.z; resObjectOffsetTM.m[3][2] = -vect.y; resObjectOffsetTM.m[3][3] = 1.0f; But it doesn''t work very well... Is someone already made this sort of thing ? Thanx Jerome

##### Share on other sites
You''re flipping vectors correctly (or at least in a way which works fine for us here at CA).

Matrices are really just a collection of vectors. You need to flip the Y and Z of those vectors, and the Y and Z vectors themselves. Here''s a snippet of code from our exporter which saves a matrix to a file:

void writeMatrix( FILE* file, const Matrix3& mat ){    Point3 row  = mat.GetRow( 0 );    fwrite( &row.x, sizeof(float), 1, file );    fwrite( &row.z, sizeof(float), 1, file );    fwrite( &row.y, sizeof(float), 1, file );    row = mat.GetRow( 2 );    fwrite( &row.x, sizeof(float), 1, file );    fwrite( &row.z, sizeof(float), 1, file );    fwrite( &row.y, sizeof(float), 1, file );    row = mat.GetRow( 1 );    fwrite( &row.x, sizeof(float), 1, file );    fwrite( &row.z, sizeof(float), 1, file );    fwrite( &row.y, sizeof(float), 1, file );    row = mat.GetRow( 3 );    fwrite( &row.x, sizeof(float), 1, file );    fwrite( &row.z, sizeof(float), 1, file );    fwrite( &row.y, sizeof(float), 1, file );}

Note the z and y of each vector flipped AND the z and y rows flipped.

Remember to perform the change from the Max coordinate system to your own exactly ONCE for any given value. ALL work inside our exporter is done in the Max coord system until we absolutely need to convert. That''s why we perform the flip as we''re writing to the file rather than earlier.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
and thanks to "Rectilinear Cat" on flipcode who point me on a old thread who help me a lot

For those who are interested :

Simon, the code in your reply is for a left handed coordinate system I think ? In right handed I''have also to flip the X or Z axis, so it''s a bit more difficult and with my method I added an incorect negative scale in the matrix
(resObjectOffsetTM.m[2][2] = -vect.y; )

But now, I reverse X axis instead of Z and with the code on the flipcode thread it''s works perfectly.

Now I have to built a bones animation system and export all of this from max... hemhem ....

Jerome

##### Share on other sites
quote:
Simon, the code in your reply is for a left handed coordinate system I think ?

Oops, yep - our engine is D3D therefore we export left handed.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
11

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007711
• ### Who's Online (See full list)

There are no registered users currently online

×