sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Camera space question

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 6 Posters 1.4k Views 6 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.
    • J Offline
      Jim
      last edited by

      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
      • AdamBA Offline
        AdamB
        last edited by

        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

          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
          • AdamBA Offline
            AdamB
            last edited by

            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
            • PixeroP Offline
              Pixero
              last edited by

              Added Sketchup file to further explain above problem.


              Camspace_weirdness.skp

              1 Reply Last reply Reply Quote 0
              • PixeroP Offline
                Pixero
                last edited by

                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
                • AdamBA Offline
                  AdamB
                  last edited by

                  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
                  • jujuJ Offline
                    juju
                    last edited by

                    25.4mm to an inch.

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

                    1 Reply Last reply Reply Quote 0
                    • GaieusG Offline
                      Gaieus
                      last edited by

                      @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

                        ?

                        
                        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

                          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
                          • PixeroP Offline
                            Pixero
                            last edited by

                            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
                            • PixeroP Offline
                              Pixero
                              last edited by

                              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
                              • First post
                                Last post
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement