Mapping rotation matrix from different coordinate system to JPCT's

Started by kkl, May 29, 2015, 05:20:04 PM

Previous topic - Next topic

kkl

Hi,

I have one rotation matrix retrieved from Blender with the following coordinate system:
+Z is up
+X is right
-Y is forward

How do we map/convert that matrix with the coordinate system to JPCT's coordinate system?

EgonOlsen

By rotating it by PI/2 around X. Or maybe -PI/2...I'm not sure right now, but one if the two.

kkl

hi egon,

I realized the coordinate system I mentioned from Blender is incorrect, it should be like this:
+Z is up
+X is right
+Y is forward

with translation vector at column 3 (which i believe column major matrix)

Apology for the mistake.

I did try with your methods, and the model rotation doesn't seem to be correct. I checked and Blender is using right hand coordinate system, and I'm guessing JPCT is using left hand coordinate system? CMIIW, converting right hand system to left hand system cannot be done by only rotation, right?

EgonOlsen

Maybe we should take a step back: What do you actually want to do? Do you really need to transform some rotation matrix or do you want to transform the mesh itself after loading?

kkl

I have an object following 2 paths. When object follows 1st path, it would have specific rotation (e.g. 90 degree x axis). When it follows the 2nd path, it should have another rotation (e.g 75 degree y axis). I created these in Blender and use the rotation matrices for the object in JPCT AE.

The rotation matrices are retrieved using the Blender Python API as suggested from http://www.blender.org/api/blender_python_api_2_57_release/bpy.types.Object.html#bpy.types.Object.matrix_local

And the reason I'm doing all these in Blender instead of JPCT AE becoz it would be tedious to create another separate UI in Android to adjust object rotation till it has the correct rotation we want.

EgonOlsen

QuoteCMIIW, converting right hand system to left hand system cannot be done by only rotation, right?
No. You might have to apply some mirror transformation matrix to it as well. Just draw both systems on paper and see what I takes to transform one into the other. Then apply these operations to your actual matrices.

kkl

hi egon,

I'm not so familiar with matrix transformation, but I did try using obj export method in Blender's source code (global matrix * object rotation matrix), where global matrix is the destination matrix which represent JPCT coordinate system and object rotation matrix obtained from Blender API. Yet, no luck on that. I wonder if you can show few guidance on the matrix tranformation, perhaps the one you mentioned, mirror transformation, or other keyword to look for in google.   

kkl

not sure if screenshot of the coordinate system from Blender would help.

The first one is the default. And the next one is the one looking from camera. I guess they are same at some sense.

EgonOlsen

Try this:


    Matrix m = new Matrix(); // your Matrix to convert
    m.rotateX((float) (Math.PI / 2d));
    Matrix mirror = new Matrix();
    mirror.set(1, 1, -1);
    m.matMul(mirror);