• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Look around tool in ruby?

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 3 Posters 1.4k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    Pixero
    last edited by 1 Dec 2007, 07:30

    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?

    1 Reply Last reply Reply Quote 0
    • T Offline
      todd burch
      last edited by 1 Dec 2007, 07:32

      With Camera.direction and Camera.up.

      Todd

      1 Reply Last reply Reply Quote 0
      • P Offline
        Pixero
        last edited by 1 Dec 2007, 07:32

        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" ?

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by 1 Dec 2007, 07:33

          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

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pixero
            last edited by 1 Dec 2007, 07:33

            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
            
            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by 1 Dec 2007, 07:34

              camera.set takes 3 arguments: the eye (Point3d), the target (Point3d) and the up direction (Vector3d).

              camera.set(eye, target, up)

              Hi

              1 Reply Last reply Reply Quote 0
              • P Offline
                Pixero
                last edited by 1 Dec 2007, 07:35

                @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?

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by 1 Dec 2007, 07:35

                  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
                  
                  

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  1 / 1
                  • First post
                    1/8
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement