• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Camera space question

Scheduled Pinned Locked Moved Developers' Forum
18 Posts 6 Posters 1.4k Views
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 7 Feb 2008, 10:56

    How do I move in camera space with ruby? (Along cam dir, sideways and up)
    I havent found any good info.

    1 Reply Last reply Reply Quote 0
    • A Offline
      AdamB
      last edited by 8 Feb 2008, 06:26

      view.camera.xaxis
      view.camera.yaxis
      view.camera.zaxis

      give you the camera space frame. (xaxis is left/right, yaxis is up/down, zaxis is along camera dir).

      Developer of LightUp Click for website

      1 Reply Last reply Reply Quote 0
      • P Offline
        Pixero
        last edited by 8 Feb 2008, 21:49

        Thanks, I've come that far. It's how to use those that I can't figure out.

        Here is an example of what I want to do.

        I have a position (a point3d) that I want to transform a distance of x-length, y-length and z-length in the camera space coordinate system.

        How do I set it up?

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by 8 Feb 2008, 22:05

          I think you may be looking too deeply. How would you do it in model space?

          Hi

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pixero
            last edited by 8 Feb 2008, 22:13

            In "world space" I do it:

            newPos = Geom::Point3d.new(pos.x+Xdist, pos.y+Ydist, pos.z+Zdist)
            pos = newPos

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by 8 Feb 2008, 22:34

              This might work...

              
              xdist = 10
              pos = Geom;;Point3d.new(0,0,0)
              camera_axis = Sketchup.active_model.active_view.camera.xaxis
              camera_axis.length = xdist
              newPos = pos + camera_axis
              
              

              Hi

              1 Reply Last reply Reply Quote 0
              • A Offline
                AdamB
                last edited by 8 Feb 2008, 22:56

                Ah, ok. So you need to transform your x-length,y-length,z-length into world space.

                camera_space_translation = Geom::Vector3d.new(xDist,yDist,zDist)

                then

                world_space_translation = Geom::Vector3d.new(view.camera.xaxis.dot(camera_space_translation),
                view.camera.yaxis.dot(camera_space_translation),
                view.camera.zaxis.dot(camera_space_translation))

                (do whatever with world_space_translation)

                BTW This is just a long hand vector-matrix multiply.

                Developer of LightUp Click for website

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by 8 Feb 2008, 23:35

                  Adam,

                  Is your method different than using the Transformarion.axis, which is a

                  @unknownuser said:

                  method is used to create a Transformation that goes from world coordinates to an arbitrary coordinate system

                  Is the result the same? I could use a course on 3d mathematics, particularly as it applies in SketchUp.

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    AdamB
                    last edited by 9 Feb 2008, 00:02

                    No different. Just wasn't sure whether you can get the camera matrix as a whole, so thought it just as easy to do 3 dot products. (And we do just want a 3x3 tranform here).

                    Developer of LightUp Click for website

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      Pixero
                      last edited by 11 Feb 2008, 22:13

                      Added Sketchup file to further explain above problem.


                      Camspace_weirdness.skp

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        Pixero
                        last edited by 11 Feb 2008, 22:14

                        First, sorry for not getting back earlier. Its been kind of hectic here.

                        Thanks for answering but I still have problems.
                        Adam, your way gives relly weird results. Either there is something wrong with your method or (more possibly) there is something wrong with me. πŸ˜‰
                        When using your method and just translating the xDist it gets a transform also in th z axis and if I use the value 100 as xDist it gets moved a distance of 2540 mm?

                        Part of the code:

                        
                        camSpaceTranslation = Geom;;Vector3d.new(xDist, yDist, zDist)
                        worldSpaceTranslation = Geom;;Vector3d.new(camera.xaxis.dot(camSpaceTranslation), camera.yaxis.dot(camSpaceTranslation), camera.zaxis.dot(camSpaceTranslation))
                        
                        newEye = eye + worldSpaceTranslation
                        newTarget = target + worldSpaceTranslation
                        eye = newEye
                        target = newTarget
                        camera = camera.set(eye, target, up)
                        
                        

                        Once more to clearify what I'm after:
                        Moving along world axes is working but I want to numerically move the camera eye point and target point (the target shall just move the same amount as the eye) in the cameras sightline*(in/out),*left/right and up/down.
                        Any thoughts?

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          AdamB
                          last edited by 12 Feb 2008, 09:41

                          And how many millimeters in an inch (the native units of Sketchup) are there?

                          @pixero said:

                          First, sorry for not getting back earlier. Its been kind of hectic here.

                          When using your method and just translating the xDist it gets a transform also in th z axis and if I use the value 100 as xDist it gets moved a distance of 2540 mm?

                          Developer of LightUp Click for website

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            juju
                            last edited by 12 Feb 2008, 10:21

                            25.4mm to an inch.

                            Save the Earth, it's the only planet with chocolate.

                            1 Reply Last reply Reply Quote 0
                            • G Offline
                              Gaieus
                              last edited by 12 Feb 2008, 12:08

                              @adamb said:

                              And how many millimeters in an inch (the native units of Sketchup) are there?

                              πŸ˜„
                              The "native" unit of mySketchUp is centimetre.

                              Gai...

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                Jim
                                last edited by 12 Feb 2008, 23:37

                                ?

                                
                                model = Sketchup.active_model
                                c = model.active_view.camera
                                eye = c.eye
                                up = c.up
                                target = c.target
                                xaxis = c.xaxis
                                yaxis = c.yaxis
                                zaxis = c.zaxis
                                
                                model.entities.add_cpoint eye
                                model.entities.add_cpoint target
                                
                                model.entities.add_text("eye", eye)
                                model.entities.add_text("target", target)
                                
                                distance = 12
                                newEye = eye.offset(xaxis, distance)
                                model.entities.add_cpoint newEye
                                model.entities.add_text("newEye", newEye)
                                
                                newTarget = target.offset(xaxis, distance)
                                model.entities.add_cpoint newTarget
                                model.entities.add_text("newTarget", newTarget)
                                
                                c.set(newEye, newTarget, up)
                                
                                

                                Hi

                                1 Reply Last reply Reply Quote 0
                                • R Offline
                                  RickW
                                  last edited by 13 Feb 2008, 22:10

                                  Might I suggest AddPages as a reference script? It adds pages (scenes) orthographically (based on user-supplied x, y, and z offsets). If I understand the gist of the discussion, then AddPages has at its heart the transformation code in question.

                                  RickW
                                  [www.smustard.com](http://www.smustard.com)

                                  1 Reply Last reply Reply Quote 0
                                  • P Offline
                                    Pixero
                                    last edited by 15 Feb 2008, 07:22

                                    Thanks all for helping! 😍

                                    Now I got it working the way I want.
                                    I'll be back when the script is done.

                                    1 Reply Last reply Reply Quote 0
                                    • P Offline
                                      Pixero
                                      last edited by 15 Feb 2008, 19:25

                                      See this thread: http://www.sketchucation.com/forums/scf/viewtopic.php?f=153&t=1528&p=41330#p41330

                                      And once more, thanks for helping!

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

                                      Advertisement