Camera Position/Rotation to POS/DIR/UP Vectors



  • 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



  • 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



  • 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



  • 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



  • 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



  • 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


Log in to reply