Ответ на сообщение пользователя sdc44
Thanks i ended up using the controls you talked about. Is there anyway to make the movement not so choppy, i provided the interface to move in increments like i wanted, but i was hoping to make the camera move smoothly to the new point,
We have smoothing in the "Viewer" app for mouse actions. It's done via the "app.js" addon but we don't currently provide any API methods. Therefore some coding is needed.
You should take a look at this callback
- this is how it's done for mouse translations/rotations. The code is a bit unwieldy but the main idea is simple:
1) In this function we have "dest_x_mouse" value which means the total amount of "movement".
2) We get the amount of time elapsed since the previous frame:
var value = m_ctl.get_sensor_value(obj, id, 0);
And use it to calculate the amount of "movement" for the current frame:
var x_mouse = m_util.smooth(dest_x_mouse, 0, value, smooth_coeff_rot_trans_mouse());
dest_x_mouse -= x_mouse;
3) Then we move camera somehow according to the "x_mouse" value, for example:
(x_mouse + x_touch)
also is there a way that i can tell which way the camera is facing and than move the camera left/right/forward/back relative to that
There is the get_camera_angles
function which returns azimuth and elevation angles for the given camera. They can be used to determine the orientation in the world space.
Also you can extract the camera rotation quaternion and convert one of the camera local axes to a world space to calculate the direction of desirable moving:
var quat = transform.get_rotation(cam, _vec4_tmp);
var z_world_cam = util.quat_to_dir(quat, m_util.AXIS_Z, _vec3_tmp);
Beware! You are using the deprecated method. It also spams in the console about this.