Results 1 to 3 of 3

Thread: Collada camera

  1. #1
    Junior Member Newbie
    Join Date
    May 2018

    Collada camera

    Hello everybody,

    How to add collada camera in OpenGL. I have create the look_at matrix by using camera translation data as camera position and look at position as (0,0,0) and up vector as (0,1,0), It renders fine as what i see in collada imported blender. But i dont have any idea about how to add rotate?

    <node id="Camera" name="Camera" type="NODE">
    <translate sid="location">-0.9681758 -0.03152037 20.65355</translate>
    <rotate sid="rotationZ">0 0 1 0</rotate>
    <rotate sid="rotationY">0 1 0 0</rotate>
    <rotate sid="rotationX">1 0 0 0</rotate>
    <scale sid="scale">1 1 0.9999999</scale>
    <instance_camera url="#Camera-camera"/>

    For this node, i am using
    glm::lookAt(glm::vec3(-0.9681758,-0.03152037,20.65), glm::vec3(0,0,0), glm::vec3(0,1,0))

    It gives the correct camera view. But how to add rotation??? Anyone have any idea about this?

  2. #2
    Member Contributor
    Join Date
    Dec 2015
    I guess you have MVP matrix in shader and you need these matrices

    1. [M] Model transform comes from node element
    2. [V] Camera transform comes from node element. View matrix is inverse of this.
    3. [P] Projection matrix comes from camera element

    But how to add rotation???
    This is same as how to add rotation to model matrix. You can construct a matrix using those individual transforms like this:

    Pseudo Codes:

    mat4 matrix = GLM_MAT4_IDENTITY_INIT; // Node local transform
    while (transform) {
    switch (transform->type) {
    glm_translate(matrix, ((Translate)transform)->translate);
    case TRANS_ROTATE:
    glm_rotate(matrix, ((Rotate)transform)->rotate, ((Rotate)transform)->angle);

    transform = transform->next;

    View matrix is inverse of the camera's world transform. After built matrix like above then the VIEW matrix is inverse of that matrix. You don't need to lookat except if it appears in a node instead of other transforms.

    This is local transform (relative to its parent) if you need to world transform (relative to origin) you need to multiply it with parent recursively
    Last edited by recp; 07-24-2018 at 02:12 AM.

  3. #3
    Junior Member Newbie
    Join Date
    May 2018
    Thanks for your reply recp. It's working.

Similar Threads

  1. COLLADA 1.5 Camera Orientation
    By recp in forum COLLADA
    Replies: 3
    Last Post: 11-06-2016, 01:01 AM
  2. Replies: 4
    Last Post: 02-21-2011, 09:15 PM
  3. Replies: 1
    Last Post: 11-10-2010, 03:00 AM
  4. KML, COLLADA, Goolge Earth: using spline tag in COLLADA
    By imported_sphere in forum COLLADA
    Replies: 1
    Last Post: 01-04-2010, 12:50 PM
  5. Replies: 1
    Last Post: 11-02-2005, 02:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean