Setting up camera/scene using Ruby
-
I want to export from Rhino to SU. Unfortunately Rhino's exporter for SU doesn't export cameras so that they end up being scenes in SU. So I wrote a script that gets the camera's data from Rhino and generates a Ruby script that I can then just paste in SU. Here is my camera in Rhino:
And that's the script generated:
` eye = [0.0,-25.0,2.0];
target = [0.0,0.0,2.0];
up = [0.0,0.0,1.0];camera = Sketchup::Camera.new eye, target, up;
camera.focal_length = 50.0;view = Sketchup.active_model.active_view;
view.camera = camera;page = Sketchup.active_model.pages.add('Perspective')`
And here are the two views:
Unfortunately the latter box is a tiny bit closer. Can someone perhaps tell me what I need to do here to get the exact same views?
-
I'd guess that the focal length sets the horizontal FOV in one case, and vertical FOV in the other case.
-
Thank you!
I am not 100% sure yet, because documentation on both sides is rather vague, but right now it looks like this is always(?) working:
camera.focal_length = lens_length_in_Rhino * 1.5;
-
SU's FOV is by default the vertical (height) axes. Which is something that always tripped me up. Use the camera.fov_is_heigh? to determin if fov is vertical or horizontal: http://ruby.sketchup.com/Sketchup/Camera.html#fov_is_height%3F-instance_method
You might have to take into account the aspect ratio of the SU viewport and your target viewport.
Advertisement