Results 1 to 10 of 10

Thread: Camera orientation

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Location
    Paris, France
    Posts
    17

    Camera orientation

    Hi all,

    I wonder if object orientation axis information should be given in COLLADA files.

    Let's give some explanation :
    - in 3DSMax, a camera (for exemple) looks in the -Z direction
    - in my engine, a camera looks in the Z direction

    Thus, my importer have to known which DCC exports the file to change the direction of the cameras (and lights) according to the DCCs "direction axis".

    Some information in COLLADA could say which is the Direction and Up axis for the cameras and lights ?

    Does someone have the same issue, and know how to handle it properly ?

    Thomas

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Hey Thomas, great news! Collada already has this information in the <up_axis> element. That element completely describes the coordinate system of the geometric data. This information is exported by all the DCC tools as far as I know.

    If you look in the <asset> documentation in the schema it describes in more detail the meaning of <up_axis>. There's also a conditioner available for converting to a different coordinate system, which you can find here.

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Location
    Paris, France
    Posts
    17
    Well, that's not really what I mean.

    I known that there is a <up_axis> element which tells what is the coordinates system of the COLLADA transformations and geometric data. But take the example of 3DSMax :



    You see that the up axis of the coordinates system is Z (and is exported as <up_axis>Z_UP</upaxis> in COLLADA). But the camera is oriented toward the -Z axis. If you export this scene in COLLADA, the transformation matrix of the camera would be the identity matrix, and thus it would be oriented toward the Z axis in my engine. Thats why I have to reverse its orientation.

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    A <camera> is always looking in the -Z direction of it's local coordinate system. When you instantiate it under a <node> you can reorient the node's coordinate system, with <rotate>, <lookat>, or <matrix> elements, to have the camera look in the direction you want.

    On a side note, it sounds like your engine uses a left-handed coordinate system so you would have to transform everything from COLLADA's right-handed coordinate system into your left-handed one.

  5. #5
    Junior Member
    Join Date
    Feb 2006
    Location
    Paris, France
    Posts
    17
    Well, I already do the right-hand ?-UP to left-hand Y-UP transformation for the nodes of my scene. But it appears that in the case of target lights and cameras, the orientation is reversed (it is not the case for the other nodes).

    Lets take the following scene from 3DSMax, you can see that the camera and the character has almost the same coordinate system (same orientation, only position differs).



    If y convert it into my engine, I get the folowing scene. The character is oriented well, and the camera too. But I had to do some supplementary processing on the camera : as you can see, the character and the camera does not have the same referential, I had to rotate the camera in order to have it look down.



    I guess I miss something in referential conversion, I don't really known what I'm doing wrong.

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    Hi,

    Can you post the <visual_scene> part of the COLLADA document from this example ?

  7. #7
    Junior Member
    Join Date
    Feb 2006
    Location
    Paris, France
    Posts
    17
    Sure, here it is :

    Code :
        <visual_scene id="Slayer_max" name="Slayer_max">
          <node id="Camera01-node" name="Camera01" type="NODE">
            <translate>254.641998 48.096638 0</translate>
            <rotate sid="RotZ">0 0 1.000000 0</rotate>
            <rotate sid="RotY">0 1.000000 0 0</rotate>
            <rotate sid="RotX">1.000000 0 0 0</rotate>
            <instance_camera url="#Camera01-camera"/>
          </node>
          <node id="l_legs-node" name="l_legs" type="NODE">
            <translate>-12.865414 20.141273 27.904665</translate>
            <instance_geometry url="#l_legs-mesh">
              <bind_material>
                <technique_common>
                  <instance_material symbol="Material__7" target="#Material__7"/>
                </technique_common>
              </bind_material>
            </instance_geometry>
          </node>
        </visual_scene>

  8. #8
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    This shows that the camera coordinate system is not rotated from the model coordinate system (all the rotations have a value of 0)
    Therefore, assuming the model is in Z-UP axis (the feets and head are following the Z axis, the head Z is greater than the feet Z), and the camera is looking down, since the camera is looking toward the negative Z axis.

    So everything looks fine to me, and the extra transform you are doing on the camera is certainly because your game engine camera is using a different convention. You probably had to rotate it by PI if your camera is defined to look toward the positive Z axis, which your picture seems to indicate.

  9. #9
    Junior Member
    Join Date
    Feb 2006
    Location
    Paris, France
    Posts
    17
    Ok, so I can admit that all camera comming from COLLADA are looking toward their local -Z direction?

  10. #10
    Senior Member
    Join Date
    Jul 2004
    Location
    Santa Clara
    Posts
    356
    Yes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •