Loaded scene form COLLADA is inverted in DirectX

Started by
12 comments, last by iskatsu 11 years ago

Hello,

I use COLLADA to load mesh data to my engine and I use my own converter. I know that matrix from COLLADA for each mesh should be transposed for using in DirectX, I also do this, but I faced with the following problem: scene or single object that I load to my engine after conversion to binary file is inverted along Z and Y axis. I multiply one value from each mesh matrix to -1 during transposition and after that position along Y axis is correct, but not along Z axis. I don`t understand how to translate mesh matrices that all of meshes in scene display correctly. For more details please look to attach screen shots from 3ds max and my engine.








outputMatrixValues[12] = (float)matrixValues[3] ;
outputMatrixValues[13] = (float)matrixValues[7];
outputMatrixValues[14] = (float)matrixValues[11] * (-1);
outputMatrixValues[15] = (float)matrixValues[15] ;

On screen shot you can see that scene in 3ds mas is in front position, so the position of both cameras (in my engine and 3ds) is correct. I completely confused with this problem. Help me please.

Advertisement

DirectX uses a left handed coordinate system.

Yes, I know it, Thats why I transpose each mesh matrix before loading the model.

In 3DS, is Y your "up" axis, or is "Z" up?

You probably shouldn't be multiplying individual components of the matrix by -1, but should be scaling an entire axis of the matrix by (-1,-1,-1,-1).

DirectX uses whatever handedness you choose to use. You can use it with left handed or right handed matrices.

Transposing a matrix does not convert between handedness; it converts between column-major storage and row-major storage. D3D's HLSL and GL's GLSL both operate on column-major storage by default, though fixed-function D3D, and the D3DX helpers often use row-major storage.

It also converts matrices that are designed to operate on row-vectors to ones that will work on column-vectors, and vice versa.

Whether you're using row-vectors or column-vectors depends on whether you write vector * matrix, or matrix * vector in your shader code.

Hodgman

So, if I undertand you correctly, I must multiply meshmatrix to XMFLOAT4(-1, -1, -1, -1)? Am I right?

Not the whole matrix, just the axis you want to flip.

e.g. if the Y axis is stored in matrix row #1, then multiply all the cells in row #1 by -1.

I think this is the same as if I will multiply each value in the concrete row during transposition. Unfortunately it not works because all meshes became turned inside out and start to rotate when I move camera.

Does someone know how to flip axis and coordinate system from 3ds max to DirectX? I think this is the root of the problem

To convert right hand coordinate system to left hand you have to only scale z axis by -1. scale vector will be Vector3(1,1,-1).

If in 3ds max z is up axis (i don't remember if thats the case) you have to swap z and y values. There should be an option in 3ds max collada exporter ??

Similar option is there for x files and fbx file exporters. Otherwise you can do it at your engine side while loading.

My Game Development Blog : chetanjags.wordpress.com

So simple? I cannot believe.

For Y_UP scaling works great . I want to make my engine and converter very flexible, so I want to learn them to load any variant of exported collada model or models form 3ds max/maya and blender.

Regards to Z_UP - there is not enough to swap y and z vertices coordinates or you mean not vertices but values in the matrix?

This topic is closed to new replies.

Advertisement