Forum

Rotate camera around axis

21 October 2016 02:05 #12896
Hello again:

I've been trying to rotate a STATIC type camera along the y-axis, the front axis, with the new way to call it. (up-down, x-axis, left-right, z-axis). Well, I wanted to rotate around and I have found is imposible, at least to me.
I have tried via a quaternion and the transform api:
                var _cam_quat = m_trans.get_rotation(_cam, _vec4_tmp2);
		m_quat.rotateY(_cam_quat, _my_rot_y, _cam_quat);
		m_trans.set_rotation_v(_cam, _cam_quat);

If I use the other axis it works ok, but with the y axis doesn't work. Is this a limitation of the camera or I am doing something wrong?
21 October 2016 16:05 #12929
ello again:

I've been trying to rotate a STATIC type camera along the y-axis, the front axis, with the new way to call it. (up-down, x-axis, left-right, z-axis). Well, I wanted to rotate around and I have found is imposible, at least to me.
I have tried via a quaternion and the transform api:
var _cam_quat = m_trans.get_rotation(_cam, _vec4_tmp2);
m_quat.rotateY(_cam_quat, _my_rot_y, _cam_quat);
m_trans.set_rotation_v(_cam, _cam_quat);

If I use the other axis it works ok, but with the y axis doesn't work. Is this a limitation of the camera or I am doing something wrong?
Hello!

Your code snippet looks correct. But if I understand you right, you want roll rotation (wiki), which is rotation around z axis in camera's local coordinate space.

Also make sure that the camera is really STATIC, roll rotation isn't supported for all camera types. Do you change camera type dynamically?

You as well may rotate camera with m_transform.rotate_z_local method, which performs almost the same routine.
Blend4Web Team - developer
21 October 2016 20:45 #12946
Hi:
But if I understand you right, you want roll rotation (wiki), which is rotation around z axis in camera's local coordinate space.

Yes, it is roll rotation. Along the local z axis of the camera. What I've found is that when I use the y parent rotation and add it to the quaternion via rotateAxis if I use any of the other axis works and the camera rotate but in the wrong direction.

I keep trying…
24 October 2016 09:56 #12978
What is your b4w engine version?
Blend4Web Team - developer
24 October 2016 21:17 #13037
It is 16.09.2. I've been trying a little more and it is strange, if I apply the rotation to the other axis it works ok and as I roll the ship the camera rotates up and down or left and right depending on the axis I apply the rotation to but not to the Z axis…
24 October 2016 21:29 #13039
You can download the file at this link
If you press 9 or H you get the keys assignment.
Hope it works…
 
Please register or log in to leave a reply.