Vertical Translation Limits TARGET camera
23 October 2015 11:50
Hey,
I have been searching for this quite a while, but I can't seem to find a way to do this.
Is there a way to limit the Z translation position of the TARGET camera type in panning mode?
I have tried to use the limit_object_position function from the furniture demo to limit the camera OBJECT3D, but that didn't work.
Thanks.
I have been searching for this quite a while, but I can't seem to find a way to do this.
Is there a way to limit the Z translation position of the TARGET camera type in panning mode?
I have tried to use the limit_object_position function from the furniture demo to limit the camera OBJECT3D, but that didn't work.
Thanks.
23 October 2015 14:23
Hi.
Take a look at this example.
For the z-axis limitations, you should replace the following lines:
by:
Take a look at this example.
For the z-axis limitations, you should replace the following lines:
if (m_vec3.length(cam_pos) >= LIMIT_RAD) {
m_cam.set_trans_pivot(cam_obj, _prev_position, _prev_targ);
} else
by:
if (cam_pos[1] >= LIMIT_RAD || cam_pos[1] <= - LIMIT_RAD) {
m_cam.set_trans_pivot(cam_obj, _prev_position, _prev_targ);
} else
23 October 2015 17:01
Dear Roman,
Thank you for the explanation and example.
I tried your example, but to me it seems like the target can move past the translation limit and then jumps back. This is better then before but not exacly what I need.
What I needed was a realtime version of that, so that you can never ever look under a certain plane.
I have combined your example together with what I already had. This works for me:
It seems that all I needed was a good update function (I'm used to the Unity's update method).
I am not completely sure if this is the best way to do it and if it has a performance impact. I'm on a very fast pc, so I can't test the performance impact.
Thank you for the explanation and example.
I tried your example, but to me it seems like the target can move past the translation limit and then jumps back. This is better then before but not exacly what I need.
What I needed was a realtime version of that, so that you can never ever look under a certain plane.
I have combined your example together with what I already had. This works for me:
start_limit_check() ;
function start_limit_check() {
var cam_obj = m_scenes.get_active_camera();
var e_sensor = m_controls.create_elapsed_sensor();
var logic_func = function(s) {
return true;
};
var update = function(cam_obj, id, pulse) {
if(m_cam.is_hover_camera(cam_obj) == false && m_cam.is_eye_camera(cam_obj) == false){
var cam_target = m_cam.get_pivot(cam_obj);
var new_vec3 = m_vec3.fromValues(cam_target[0], 10, cam_target[2]);
if (cam_target[1] <= 10) {
m_cam.set_pivot(cam_obj,new_vec3);
console.log(new_vec3);
}
}
};
m_controls.create_sensor_manifold(cam_obj, "random", m_controls.CT_CONTINUOUS, [e_sensor], logic_func, update);
}
It seems that all I needed was a good update function (I'm used to the Unity's update method).
I am not completely sure if this is the best way to do it and if it has a performance impact. I'm on a very fast pc, so I can't test the performance impact.
23 October 2015 17:57
I have combined your example together with what I already had. This works for me
Glad to hear it
I am not completely sure if this is the best way to do it and if it has a performance impact. I'm on a very fast pc, so I can't test the performance impact.
I think, it isn't laborious way to limit the camera position.