Forum

Camera auto-rotation

08 February 2017 07:50
I was reading the code of the dairy plant project and I was a little comfused about this function:
// auto-rotate camera
function rotate_camera() {
    m_camera_anim.auto_rotate(AUTO_ROT_CAM_SPEED);
}

// stop camera auto-rotate
function stop_cam_auto_rotate() {
    if (m_camera_anim.is_auto_rotate())
        rotate_camera();
}


How come stop_cam_auto_rotate is calling rotate_camera? Isn't it supposed to stop it?
08 February 2017 10:21
This is another question not related to camera.
In the same document, there was a variable defined like this:
var timeout = m_nla.is_play() ? 1000: 1;

m_nla.is_play returns true or false, so what would the timeout will be?

Thank you in advance!
08 February 2017 11:19
Hello

Isn't it supposed to stop it?

Here is the description of this method:
Switch auto-rotation of the TARGET or HOVER camera around its pivot, or auto-rotating of the EYE camera around itself. When it is called for the first time, auto-rotation is enabled while the next call will disable auto-rotation.

It works like a trigger. In this case the "rotate_camera" method can be named "change_cam_auto_rotate_mod"
08 February 2017 11:23
m_nla.is_play returns true or false, so what would the timeout will be?

It's a conditional operator. You can read about it here
08 February 2017 21:33
Reply to post of user Roman Sementsov
It works like a trigger. In this case the "rotate_camera" method can be named "change_cam_auto_rotate_mod"

I see. I should have read the API description more carefully. Thank you very much
08 February 2017 21:59
Reply to post of user Roman Sementsov
It's a conditional operator. You can read about it here

Thanks for the link. But I still don't fully understand why you need a timeout here:
function view_stage() {
    var cur_stage       = _products[_product_index]["stages"][_cur_stage - 1];
    var start_frame     = m_scs.marker_frame(cur_stage["start_frame"]);
    var end_frame       = m_scs.marker_frame(cur_stage["end_frame"]);
    var start_cam_point = m_scs.get_object_by_dupli_name("camera_stages",
                                                 cur_stage["start_cam_empty"]);

    var timeout = m_nla.is_play() ? 1000: 1;

    m_nla.stop();
    m_nla.set_range(start_frame, end_frame);

    move_rot_camera_to_point(start_cam_point, function() {
        m_nla.set_frame(start_frame);

        m_time.set_timeout(function() {
            m_nla.play(function() {
                play_outline(cur_stage);

                _cur_substage = 1;

                animate_substage(cur_stage);
            })
        }, timeout)
    })
}


Do you mind explaining it to me? Dose move_rot_camera_to_point immediately calls the cb function or it calls it when the camera is finished moving?
Thank you!
09 February 2017 10:19
Hello,

It's called when the camera finished the animation. The timeout is used for the outlining animation delay.
09 February 2017 11:03
var timeout = m_nla.is_play() ? 1000: 1;

Besides the animation outlining delay it is needed to improve visual appeal and to distinct current and next animations.
If current animation is interrupted, the camera moves quickly to the next animation start point and waits for one second to begin the next animation.
Anyway, you can remove that timeout or change timeout value and look for the result.
10 February 2017 09:37
Reply to post of user Roman Sementsov
Hello,

It's called when the camera finished the animation. The timeout is used for the outlining animation delay.
Thank you so much Roman.
 
Please register or log in to leave a reply.