Look around tool in ruby?
-
How does the look around tool work in ruby?
The rotate view rotates around a target point
but the look around tool rotates around the position of the "camera".
How is that done in ruby? -
With Camera.direction and Camera.up.
Todd
-
I tried that and also "camera.set eye, target, up" but can't get camera to rotate.
What's the right syntax? Is there a "camera.set eye, direction, up" ? -
I should have said "with camera.set by changing the direction and tilt", but I think you understood.
You say "why doesn't my code work, because I am doing that".
Now, I have to say, I need to see your code to tell you why your code does not work, intead of trying to guess what you are doing wrong. There are a couple ways to approach this. It's too brain-racking to try and guess.
Todd
-
Here is some testcode I use.
I get: <ArgumentError: Eye, Target and Up are required> when using camera.set direction
I also tried with: direction.set!(@rx, @ry, @rz); but nothing...# Testing code # Name; jsCameraTool # Author; Jan Sandstrom www.pixero.com # Description; Position and rotate the camera numericly. require 'sketchup.rb' def jsCameraTool model = Sketchup.active_model view = model.active_view camera = view.camera eye = camera.eye direction = camera.direction target = camera.target up = camera.up length = camera.focal_length fov = camera.fov ### Dialog @px = eye.x @py = eye.y @pz = eye.z @rx = direction.x @ry = direction.y @rz = direction.z #@tx = target.x #@ty = target.y #@tz = target.z prompts = ["Position X", "Position Y", "Position Z", "Rotation X", "Rotation Y", "Rotation Z"] values = [@px, @py, @pz, @rx, @ry, @rz] results = inputbox(prompts, values, "JS CameraTool") px, py, pz, rx, ry, rz = results @px, @py, @pz, @rx, @ry, @rz = px, py, pz, rx, ry, rz # New position camera.eye.x = @px; camera.eye.y = @py; camera.eye.z = @pz; camera.direction.x = @rx; camera.direction.y = @ry; camera.direction.z = @rz; #target.x = @tx; #target.y = @ty; #target.z = @tz; #up.set!(0.0, 0.0, 1.0); #camera.set eye, target, up; camera.set direction; end # end of jsCameraTool if( not file_loaded?("jsCameraTool.rb") ) UI.menu("Plugins").add_item("JS CameraTool") { jsCameraTool } end -
camera.set takes 3 arguments: the eye (Point3d), the target (Point3d) and the up direction (Vector3d).
camera.set(eye, target, up)
-
@unknownuser said:
camera.set takes 3 arguments: the eye (Point3d), the target (Point3d) and the up direction (Vector3d).
camera.set(eye, target, up)Thats just it.
How do I set the camera.direction? -
You need to use camera.set. The vector from the target to the eye is the direction.
m=Sketchup.active_model view=m.active_view camera=view.camera v1 = (camera.target - camera.eye).normalize v2 = camera.direction.normalize p v1 == v2
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement