Author Topic: Mapping rotation matrix from different coordinate system to JPCT's  (Read 2014 times)

kkl

• float
• Posts: 291
Mapping rotation matrix from different coordinate system to JPCT's
« on: May 29, 2015, 05:20:04 pm »
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

• Posts: 12066
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #1 on: May 29, 2015, 05:35:28 pm »
By rotating it by PI/2 around X. Or maybe -PI/2...I'm not sure right now, but one if the two.

kkl

• float
• Posts: 291
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #2 on: May 31, 2015, 05:58:13 am »
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?
« Last Edit: May 31, 2015, 08:33:55 am by kkl »

EgonOlsen

• Posts: 12066
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #3 on: May 31, 2015, 11:30:32 am »
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

• float
• Posts: 291
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #4 on: May 31, 2015, 11:54:02 am »
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

• Posts: 12066
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #5 on: June 04, 2015, 07:35:31 am »
Quote
CMIIW, 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

• float
• Posts: 291
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #6 on: June 08, 2015, 03:50:04 pm »
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

• float
• Posts: 291
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #7 on: June 08, 2015, 05:12:34 pm »
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

• Posts: 12066
Re: Mapping rotation matrix from different coordinate system to JPCT's
« Reply #8 on: June 09, 2015, 07:54:41 am »
Try this:

Code: [Select]
`    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);`