Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Login

    Camera Position/Rotation to POS/DIR/UP Vectors

    Cinema 4D SDK
    r21 c++
    3
    5
    625
    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.
    • N
      neon
      last edited by

      Hello PluginCafe,
      I have been stuck on the problem of converting Camera Position / Rotation
      to position, direction and up vectors for a right handed system. It is probably really easy and I am just being brain dead right now but I have been struggling for way longer than I want to admit.

      I hope somebody can help me there,
      Florian

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        first of all - you cannot express right-handed matrices with Cinema's Matrix type, because it is explicitly left-handed. It has been discussed in a scenario similar to yours here.

        But you can of course simply compute a frame reflected on one of standard basis planes, which will give you the right handed frame for a given left-handed Cinema Matrix (or vice versa). This topic has been discussed just recently in great depth here.

        Your question is also a bit ambiguous. You state twice that you want the frame to be expressed as a position, direction and up-vectors (plural). The position would just be Matrix.off, and the direction and "up vectors" would be just the axis components of the Matrix, i.e. the attributes v1, v2, v3 of a Matrix. What is what is depends on the systems you want to convert to and you will have to consult their documentation on how to interpret the rather ambiguous up vectors.

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • N
          neon
          last edited by neon

          Hello zipit,
          thanks for your quick reply!

          I actually only need one direction, one up and one position vector. I am trying to parse a (generic) scene with the camera and everything from Cinema4D to another program/renderer which has a right handed coordinate system. And for the Camera I do need the up, position and direction vector.

          I will read through what you suggested tomorrow, thanks for the throughout reply!

          Best Regards,
          Florian

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hi,

            As zip said, in a matrix the position is stored in the Matrix.off parameter.
            It's a vector. You have to reverse the Z axis of that vector to retrieve the right hand position. ( z * -1)

            The direction vector should be the Z axis. It's represented by Matrix.v3. Same you have to reverse the z axis of that vector.
            For the Up vector, the most common is to pick the Y axis and it's represented by Matrix.v2. And again, reverse the z value of the vector

            You may also need to swap some vector around, because some engine/dcc have their Z axis pointing Up. You have to take that into account of course.

            you can also have a look at that documentation :
            Matrix Fundamentals

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • N
              neon
              last edited by

              Hello Manuel,
              thanks for your input!
              I got it working correctly with the values you mentioned.
              Reading through the docs again I feel kinda dumb for not getting it right myself.
              Thanks to both you and zipit for your great help!

              Best Regards,
              Florian

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