sketchucation logo sketchucation
    • Login
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here

    CALLING ALL MATRIX GURUS, HELP! , please :)

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 1.1k Views 5 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.
    • M Offline
      MarcioAB
      last edited by

      The 16-elements matrix you show up, have Origin, Axis, Scale data relative to a parent coordinate system (can be the Global system but can also be the coordinate system of it's parent component).

      The first line has the x,y,z projections (in the parent's coordinate system) of vector X of the axis. Then the scale in this direction.
      The same for the other 2 lines regard vector Y and Z of the axis.
      The last line has the axis' coordinates x,y,z (in the parent's coordinate system). And the last number is the overall scale.

      You can create a TRANSFORMATION directly with this 16-elements matrix and apply it to an object that accepts transformation method, BUT ... Camera does not accept transformation method.

      Instead, Camera has it's own "transformation" method that is called SET. The SET method is based on:

      • Target: a 3Dpoint where the Camera is looking for.
      • Eye: a 3Dpoint where the Camera is.
      • Top: a 3Dvector indicating the rotation of the camera regard the direction Eye-Target. Normally it's the Z-direction, to make the camera stand up.

      This is what the "on-line" manual says for Camera Class
      Please take a look in CameraOOT

      Regards
      Marcio

      1 Reply Last reply Reply Quote 0
      • M Offline
        MarcioAB
        last edited by

        2nd thought ... based on your data:

        target => 3Dpoint of [0.999938,0.001129,-0.011103]
        eye => 3Dpoint of [1.054297,1.571880,-8.966838]
        up => 3Dvector of [-0.011108,0.005189,-0.999925]

        Can not test because not have a working system here ...

        Regards
        Marcio

        1 Reply Last reply Reply Quote 0
        • J Offline
          jessejames
          last edited by

          Many thanks my friend, I had almost given up hope.

          I am 99% sure this is referring to world coordinates.I will try your suggestions and post back if this does not work. Stay tuned πŸ˜„

          Always sleep with a loaded gun under your pillow!

          1 Reply Last reply Reply Quote 0
          • J Offline
            jessejames
            last edited by

            OK, i tried the suggestion...

            
            target => 3Dpoint of [0.999938,0.001129,-0.011103]
            eye => 3Dpoint of [1.054297,1.571880,-8.966838]
            up => 3Dvector of [-0.011108,0.005189,-0.999925]
            
            

            but it is not correct, i will continue to play around with the values to see if i can fiqure this out. If you have any more thoughts feel free to post them.
            Thanks

            Always sleep with a loaded gun under your pillow!

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              It is hard to know what the matrix values mean. You say they are from a source outside of SketchUp, but what application? If you are exporting coordinates from another program, make the position of the exported object more extreme so you can see some values in the matrix that are extreme.

              Hi

              1 Reply Last reply Reply Quote 0
              • J Offline
                jessejames
                last edited by

                OK Guys,
                The program i am getting this data from is Blender via a python script.

                I have some information that may help you to help me πŸ˜‰. I created a new camera in Blender and played with the rotation a bit. here is an output from that session. Note: that after each Rotation i reset the camera to it's original position. So first i rotated 90deg on X axis, printed the matrix, then i reset the camera... and so on.

                I applied some rotations and deduced the following data(eye,target,up) by looking at the actual camera. my visual data is between the "<" and ">" . Luckily in Blender the camera is actually visible.

                <camera at Loc(0,0,0). target(0,0,-1), up(0,1,0)>
                [1.000000, 0.000000, 0.000000, 0.000000]
                [0.000000, 1.000000, 0.000000, 0.000000]
                [0.000000, 0.000000, 1.000000, 0.000000]
                [0.000000, 0.000000, 0.000000, 1.000000]

                after RotX += 90
                <Loc(0,0,0) target(0,1,0) up(0,0,-1)>
                [1.000000, 0.000000, 0.000000, 0.000000]
                [0.000000, -0.000000, 1.000000, 0.000000]
                [0.000000, -1.000000, -0.000000, 0.000000]
                [0.000000, 0.000000, 0.000000, 1.000000]
                #reset camera

                after RotY += 90
                <Loc(0,0,0) target(-1,0,0) up(0,1,0)>
                [-0.000000, 0.000000, 1.000000, 0.000000]
                [-0.000000, 1.000000, -0.000000, 0.000000]
                [-1.000000, -0.000000, -0.000000, 0.000000]
                [0.000000, 0.000000, 0.000000, 1.000000]
                #reset camera

                after RotZ += 90
                <Loc(0,0,0) target(0,0,-1) up(-1,0,0)>
                [-0.000000, 1.000000, 0.000000, 0.000000]
                [-1.000000, -0.000000, 0.000000, 0.000000]
                [0.000000, -0.000000, 1.000000, 0.000000]
                [0.000000, 0.000000, 0.000000, 1.000000]

                Maybe from this data some one can figure out the matrix? It still does not make any sense, i cannot find the values within the matrix in a form that makes any sense??

                If you can make anything of this data i will give you a big kiss, tongue, no tongue your choice πŸ˜†. I really need to figure out the target(point) and up(vector) so i can use this data in SU. the eye is M[-1] i know that already. Thanks so much for any help you can give.

                Always sleep with a loaded gun under your pillow!

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

                  I've written a MentalRay shader that has many different matrixes like scale, transform, shear, scale, rotation order and more.
                  You can download the zip with the source code and take a look.
                  Hope this helps.

                  http://www.pixero.com/files/JS_Place3dTexture.zip

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jessejames
                    last edited by

                    Thanks Pixero,
                    I will look into this right now.

                    Always sleep with a loaded gun under your pillow!

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jzer7
                      last edited by

                      Not a matrix person, but my 2 cents... From Indigo's exporter in the Blender wiki (look for "Process Camera", it looks like:

                      
                      up = matrix[1]
                      forwards = matrix[2]
                      pos = matrix[3]
                      
                      

                      So, up should be the second row, forwards the third and pos the fourth.

                      Good luck πŸ˜‰


                      Juan

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jessejames
                        last edited by

                        jzer7,
                        Thanks so much, but no luck.

                        I going to post a section of the script i am parsing this data from, maybe it will help...

                        
                        
                        import Blender
                        from Blender import Camera, Object, Scene, NMesh
                        from Blender import Mathutils
                        from Blender.Mathutils import *
                        cur = Scene.getCurrent()
                        
                        #Camera Parameters
                        c0001 = Camera.New('persp')
                        c0001.lens = 49.739047
                        o0001 = Object.New('Camera')
                        o0001.name = "voodoo_cam1"
                        o0001.setMatrix(Mathutils.Matrix([0.999938,0.001129,-0.011103,0.000000], [0.001072,-0.999986,-0.005202,0.000000], [-0.011108,0.005189,-0.999925,0.000000], [1.054297,1.571880,-8.966838,1.000000])) 
                        o0001.link(c0001)
                        cur.link(o0001)
                        
                        c0002 = Camera.New('persp')
                        c0002.lens = 49.739047
                        o0002 = Object.New('Camera')
                        o0002.name = "voodoo_cam2"
                        o0002.setMatrix(Mathutils.Matrix([0.999943,0.001132,-0.010635,0.000000], [0.001076,-0.999985,-0.005294,0.000000], [-0.010641,0.005282,-0.999929,0.000000], [1.071295,1.559580,-8.822482,1.000000])) 
                        o0002.link(c0002)
                        cur.link(o0002)
                        
                        
                        ##################################################
                        # [snip]
                        # many, many more cams are created and then comes 
                        # some IPO curve data
                        #################################################
                        
                        
                        #Render camera animated with IpoCurves
                        crender = Camera.New('persp')
                        crender.lens = 35.0
                        crender.setDrawSize(1.0)
                        orender = Object.New('Camera')
                        orender.name = "voodoo_render_cam"
                        orender.link(crender)
                        cur.link(orender)
                        cur.setCurrentCamera(orender)
                        ipo = Blender.Ipo.New('Object','render_cam_objipo')
                        orender.setIpo(ipo)
                        locx = ipo.addCurve('LocX')
                        locx.setInterpolation('Linear')
                        locy = ipo.addCurve('LocY')
                        locy.setInterpolation('Linear')
                        locz = ipo.addCurve('LocZ')
                        locz.setInterpolation('Linear')
                        rotx = ipo.addCurve('RotX')
                        rotx.setInterpolation('Linear')
                        roty = ipo.addCurve('RotY')
                        roty.setInterpolation('Linear')
                        rotz = ipo.addCurve('RotZ')
                        rotz.setInterpolation('Linear')
                        camipo = Blender.Ipo.New('Camera','render_cam_camipo')
                        crender.setIpo(camipo)
                        lenscurve = camipo.addCurve('Lens')
                        lenscurve.setInterpolation('Linear')
                        
                        locx.addBezier((1,o0001.LocX))
                        locy.addBezier((1,o0001.LocY))
                        locz.addBezier((1,o0001.LocZ))
                        rotx.addBezier((1,o0001.RotX*18/3.141593))
                        roty.addBezier((1,o0001.RotY*18/3.141593))
                        rotz.addBezier((1,o0001.RotZ*18/3.141593))
                        lenscurve.addBezier((1,c0001.lens))
                        
                        locx.addBezier((2,o0002.LocX))
                        locy.addBezier((2,o0002.LocY))
                        locz.addBezier((2,o0002.LocZ))
                        rotx.addBezier((2,o0002.RotX*18/3.141593))
                        roty.addBezier((2,o0002.RotY*18/3.141593))
                        rotz.addBezier((2,o0002.RotZ*18/3.141593))
                        lenscurve.addBezier((2,c0002.lens))
                        
                        ############################################
                        # [snip]
                        # many more lines of IPO
                        # the only thing left is "point cloud" data 
                        # which i am leaving out. 
                        # The last thing in the script is this...
                        ###########################################
                        
                        # Scene Helper Object
                        scene_dummy= Object.New('Empty','voodoo_scene')
                        scene_dummy.setLocation(0.0,0.0,0.0) 
                        cur.link(scene_dummy)
                        scene_dummy.makeParent([orender,ob])
                        
                        scene_dummy.setEuler((-3.141593/2, 0.0, 0.0))
                        scene_dummy.SizeX=0.2
                        scene_dummy.SizeY=0.2
                        scene_dummy.SizeZ=0.2
                        
                        

                        Maybe this helps, maybe not ?? the lines don't wrap correctly in the code tags so it mucks up the code a bit πŸ˜•

                        Always sleep with a loaded gun under your pillow!

                        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