Forum

Camera constrained to shape?

08 January 2015 12:20
Ok, so I have a simple scene with a target camera looking at a tall object. Viewing this object from top to bottom is not ideal when the camera target location is an xyz coordinate.

Camera Target location:


Camera constrained to shape:

Is there a way to constrain the camera to a line shape (spline) like in ^this^ image. Basically so that the camera can freely rotate around the object but also translate up and down. I'm aware of the new hover move style in the camera module, which is like a camera constrained to a plane, so i don't think I can use that for this. I should also specify that I want to be able to control this with just the mouse so it easier for mobile.

Or am i just approaching this wrong? Would this be easier to do with the animation module or something else?

Thanks
08 January 2015 12:24
Woops, did not know the forum didnt support gifs… i fix

Camera Target location:
http://i.imgur.com/TGF6lNq.gif

Camera constrained to shape:
http://i.imgur.com/hvFXPwM.gif
08 January 2015 13:32
So basically you want a Target camera, but with vertical movement instead of vertical rotation, is it correct?

In the app.js addon there is a very long function called enable_camera_controls(). This function implements mouse, touch and keyboard controls for different camera types. So instead calling this function from your app, you probably want to copy relevant parts of this function to the code of your application, and make subtle modifications.

I think you might give it a try, while we will be happy to answer your further questions.
The Founder | Twitter | Facebook | Linkedin
08 January 2015 15:45
Thanks for the quick response! Im looking into it now.

Now I have a real noob question that ive been trying to figure out for longer then I'd care to admit. In the camera module, what is exactly the Camera Object ID (camobj). It's not the camera name in blender. Is it like a uuid number?

help
08 January 2015 16:31
Now I have a real noob question that ive been trying to figure out for longer then I'd care to admit. In the camera module, what is exactly the Camera Object ID (camobj). It's not the camera name in blender. Is it like a uuid number?
Well, it is a reference to camera JavaScript object, not a string ID. It can be obtained with a get_active_camera() call of the scenes module.
The Founder | Twitter | Facebook | Linkedin
08 January 2015 21:14
Gotcha, I understand. Thanks very much! Love the team's dedication and support.
09 January 2015 10:40
Our pleasure!
The Founder | Twitter | Facebook | Linkedin
12 January 2015 03:24
Alright I modified my app.js file to be able to translate the pivot point up and down in the y-axis while still being able to have rotation in the y-axis all with just left mouse clicking. (simpler for mobile and frankly end users )

I am now however having trouble limiting the y axis vertical translation.

I tried using export.apply_vertical_limits from the camera.js module But the camera controls just reset.

m_cam.apply_vertical_limits = function(obj, 0, 20, space) {
if (camera.is_target_camera(obj) || camera.is_eye_camera(obj)) {
var render = obj._render;
render.vertical_limits = {
down: 0,
up: 20
}
}
}


I also tried using the math.min and math.max functions but had no luck with them either.

I'm I approaching this right? Or is there a simpler/better way? Do you have any examples using these limits?

Thanks in advanced.
12 January 2015 11:01
Hello.
apply_vertical_limits is used to set vertical rotation limits of the target or the eye cameras.

It is better to use clamp function from util.js.

For example
exports.enable_camera_controls = function(disable_default_pivot) {
    // . . .
    var cam_pivot = m_cam.get_pivot(obj);
    // var cam_pivot = m_cam.get_pivot(obj, _vec3_tmp);
    cam_pivot[1] = m_util.clamp(cam_pivot[1], 0, 20);
    m_cam.set_pivot(obj, cam_pivot);
    // . . .
}
Blend4Web Team
kirill@blend4web.com
19 January 2015 06:59
Thanks for the help Kirill!

I still unfortunately am not getting it to work. I used the util.clamp function in my modified app.js file, but no luck.

I uploaded my app.js if it helps…
 
Please register or log in to leave a reply.