NVIDIAGameWorks / FleX

Other
650 stars 100 forks source link

How to make FleX rotate the objects the same way as Blender/Unity etc? #63

Closed Amir-Arsalan closed 5 years ago

Amir-Arsalan commented 5 years ago

I rotate some objects in FleX, export them and render them in Blender. I realized that the rotations I apply to the objects in FleX does not rotate the objects in the same way that Blender does. If I'm getting it right, I learned that FleX uses a transform matrix to rotate the objects but Blender does not [necessarily] do that. I also talked with someone who is using the FleX plugin in Unity and he said he has the faces similar issues. This is the case for both Euler angles or Quaternions. Below is the piece of code that I use to rotate the objects in FleX. I'm pretty new to FleX and I don't know which functions I should use so that I can get the same rotations as I get in Blender, without unnecessary transformations. Can someone help me with this?

For rotating with Euler angles:

obj->Transform(RotationMatrix(rx, Vec3(1.0f, 0.0f, 0.0f)));
obj->Transform(RotationMatrix(ry, Vec3(0.0f, 1.0f, 0.0f)));
obj->Transform(RotationMatrix(rz, Vec3(0.0f, 0.0f, 1.0f)));

For rotating with Quaternions:

auto x = rx;
auto y = ry;
auto z = rz;
auto w = rw;
obj->Transform(RotationMatrix(Quat(x, y, z, w)));
Amir-Arsalan commented 5 years ago

This happens due to different interpretation for the axes in Blender and Flex. [x, y, z] in Blender is interpreted as [-y, z, x] in FleX.