0
101 Jul 22, 2006 at 03:46

Is there a way I can convert a model exported from 3ds max (positive X to the right, positive Y into the distance, and positive Z up) to a standard right-handed model (positive X to the right, positive Y up, and positive Z towards the camera) using a matrix?

I know how to do this by manipulating each vertex manually, but how can I do it with a matrix?

Thanks a lot!

#### 8 Replies

0
165 Jul 22, 2006 at 04:47

It’s easy. You’ll want to multiply each vertex by a 3x3 matrix. Now the rule for matrices is that when you multiply one by the vector <1, 0, 0> you get a vector equal to the first column of the matrix; multiplying by <0, 1, 0> gives you the second column; and multiplying by <0, 0, 1> gives you the third column. So all you have to do is figure out what you want those three vectors (in the 3DS Max coordinate system) to come out as in your coordinate system. Then constructing the appropriate matrix is easy. In this case:

<1, 0, 0> (in 3DS Max) –> <1, 0, 0> in your coordinates
<0, 1, 0> –> <0, 0, -1>
<0, 0, 1> –> <0, 1, 0>

So the appropriate matrix would be
[ 1 0 0 ]
[ 0 0 1 ]
[ 0 -1 0 ]

0
101 Jul 23, 2006 at 04:25

[ 1 0 0 ]
[ 0 0 1 ]
[ 0 1 0 ]

and reverse the cull order, but it works great! Thanks!

0
101 Jul 24, 2006 at 17:41

3dsmax coordinate system is already right handed, so you shouldn’t have to reverse the face vertex order. You just have to do a 90 degree rotation around the x axis to convert your objects. The matrix Reedbeta gave you does this rotation.

The matrix you are using is not good. It will just interchange y and z, which is not good (it’s a reflection, and that’s why you had to reverse the face vertex order)

And by the way, the usual standard is: x axis points left, y axis points up, z points forward.

0
165 Jul 24, 2006 at 22:37

@Faelenor

the usual standard is: x axis points left, y axis points up, z points forward.

That doesn’t sound like the standard coordinate system to me…I think SnprBob86 has it right. x -> right, y -> up, z -> backward for OpenGL (the camera points along the negative z axis in eye space). Direct3D uses a left-handed system that has x -> right, y -> up, and z -> forward.

So, SnprBob86’s matrix is correct for D3D, as long as he hasn’t set up D3D’s projection matrix to flip the Z axis (as some people do, to get a right-handed system in D3D).

0
101 Jul 25, 2006 at 14:27

@Reedbeta

That doesn’t sound like the standard coordinate system to me…I think SnprBob86 has it right. x -> right, y -> up, z -> backward for OpenGL (the camera points along the negative z axis in eye space). Direct3D uses a left-handed system that has x -> right, y -> up, and z -> forward.

Well, it depends. From the camera’s point of view, you are right. But usualy, objects, especially characters, are modeled with their z axis pointing towards. That was the case everywhere I worked. You just have to take the z axis of the object to know in which direction it’s facing. But well, maybe that’s not the standard, but it’s probably more convenient for AI.
@Reedbeta

So, SnprBob86’s matrix is correct for D3D, as long as he hasn’t set up D3D’s projection matrix to flip the Z axis (as some people do, to get a right-handed system in D3D).

He explicitely wanted a right handed system, so he’s obviously wrong!

0
101 Nov 21, 2008 at 01:16

@Faelenor

3dsmax coordinate system is already right handed, so you shouldn’t have to reverse the face vertex order.

That is true for the UI and for MaxScript. But you need to be careful about how you are accessing the values. This is taken from MaxScript Help Doc:

<node>.transform : Matrix3 – node’s main transformation matrix
Rotation in the internal transformation matrices is left-handed in contradiction to the 3ds Max user interface and MAXScript. Take care when mixing rotation derived from these matrices and rotation used in rotation-related functions or from rotation properties.

0
165 Nov 21, 2008 at 01:40

Thanks pha3z, but this thread is over two years old. ;)

0
101 Nov 21, 2008 at 02:32

Hey Reed,

These threads come up on google searches. I won’t be the last person to visit them. ;) I’ll leave a trail for those who come after me.

BTW, Here’s an awesome page that demistifies all the confusion between the way matrices are stored and translated in OpenGL vs. DirectX.