Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Transpose Matrix

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 524 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.
    • H Offline
      Helper
      last edited by

      On 02/07/2017 at 10:40, xxxxxxxx wrote:

      Hello,

      How can I transpose a matrix in C4D ? Is it possible ?

      It seems that le C4D matrix are 4x4 but the first line can't be changed (always 0,0,0,1) ?

      My goal is to get or calculate the normalMatrix, but not in a shader context.

      Thanks

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 02/07/2017 at 12:04, xxxxxxxx wrote:

        Ok, it seems that we don't care beause the first will line will be the offset matrix component :

          
        1     0     0     0
        v0.x  v1.x  v2.x  v3.x
        v0.y  v1.y  v2.y  v3.y
        v0.z  v1.z  v2.z  v3.z
          
        Transposed :
          
        1    v0.x  v0.y  v0.z
        0    v1.x  v1.y  v1.z
        0    v2.x  v2.y  v2.z
        0    v3.x  v3.y  v3.z
          
        

        So with an offset v0 of (0,0,0), we will still get the first line correct.

            def TransposeMatrix(m) :
                
                v1 = Vector(m.v1.x, m.v2.x, m.v3.x)
                v2 = Vector(m.v1.y, m.v2.y, m.v3.y)
                v3 = Vector(m.v1.z, m.v2.z, m.v3.z)
                
                m.v1 = v1
                m.v2 = v2
                m.v3 = v3
                m.off = Vector()
        

        Can you confirm me ? 🙂

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 03/07/2017 at 06:44, xxxxxxxx wrote:

          Hi César,

          unfortunately I can only confirm that there is no function to transpose a matrix in our Python SDK.
          To me, your transposed matrix in the last post looks ok.

          Maybe you can tell us a bit more detail about what you are trying to achieve in the end, so we could ask our development for ideas?

          Or you use something like numpy, I think Niklas once posted, that he has prepared packages for use with C4D.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 05/07/2017 at 14:44, xxxxxxxx wrote:

            Thanks for the info.

            Well, it's for create a Spherical Environment UV projection, for very specific baking process.

            According to the shader :
            https://www.clicktorelease.com/blog/creating-spherical-environment-mapping-shader/

            I needed to get the normalMatrix wich is the inverse transpose of the modelViewMatrix.

            For anyone who search more infos about it :

            modelViewMatrix = ~(camera.GetMg()) * op.GetMg()
            normalMatrix = ~(modelViewMatrix)
            TransposeMatrix(normalMatrix)

            It work nice !

            1 Reply Last reply Reply Quote 0
            • First post
              Last post