Forum

Getting the rotation of camera in Euler Angles

29 February 2016 12:41 #7871
To get the rotation of my camera, I've been using :

cam_rotation = m_trans.get_rotation(cam);


This is returning a quaternion. However, I need this rotation value back into blender to set the rotation of a new camera. Is there a simple way for me to do this?
29 February 2016 18:37 #7881
This is returning a quaternion. However, I need this rotation value back into blender to set the rotation of a new camera.

You can still use it in Blender. Just set the rotation mode and the rotation quaternion on the camera as follows:

camera.rotation_mode = "QUATERNION"
camera.rotation_quaternion = new_quat


Also, the Quat can be converted to Euler by using this method. It depends on the angles' order which rotation mode should be set before applying the rotation in Eulers.

However, b4w quaternion should be prepared first, because of different order of its components. Let's assume that it has the following order: [x,y,z,w]. Then in Blender you should use it like this [w,x,-z,y]:

new_quat = mathutils.Quaternion((b4w_quat[3], b4w_quat[0], -b4w_quat[2], b4w_quat[1]))

Blend4Web Team
02 March 2016 09:05 #7926
Ok, great! I will try to implement what you suggested. Thank you
 
Please register or log in to leave a reply.