Search the Community
Showing results for tags 'Matrix'.
-
Hi everyone, There are a question about rotate a node, There is the default material in the new C++ project's scene: After rotate the material_ball about Y-axis by these code: node = Editor::get()->getNodeByName("material_ball"); Mat4 transform = node.get()->getTransform(); mat4 rot = rotateY(90.0f); node.get()->setTransform(transform * Mat4(rot)); The material_ball become this: And then I rotate it about Z-axis by these code: node = Editor::get()->getNodeByName("material_ball"); Mat4 transform = node.get()->getTransform(); mat4 rot = rotateY(90.0f); mat4 rot2 = rotateZ(-30.0f); node.get()->setTransform(transform * Mat4(rot) * Mat4(rot2)); The material_ball become this: Form the above view, I find that the rotate function is rote the node about it's own axis, How can I rotate it about the world axis ? I have tried the setWorldTransform function like this: node = Editor::get()->getNodeByName("material_ball"); Mat4 transform = node.get()->getWorldTransform(); mat4 rot = rotateY(90.0f); mat4 rot2 = rotateZ(-30.0f); node.get()->setWorldTransform(transform * Mat4(rot) * Mat4(rot2)); But it's result is the same with setTransform function.