Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Another billboarding problem

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2001
    Location
    Bend,No,No
    Posts
    9

    Another billboarding problem

    I am sorry to ask just because it has been asked so many times, but my question is this. I want to billboard a quad using a cylindrical way, but i don't want to get the modelview matrix becuase i hate round-trip calls because they are slow and suck. Here is what i have i use the gluLookat because i like have a view and position vector.

    Code :
    VECTOR3 vVec(mPlayer.View-mPlayer.Pos);
    angle = PIUNDER180*vVec.GetAngle(VECTOR3(0,0,1.f));
    VECTOR3 axis(0,1.f,0);
     
     
    glRotatef(angle,axis.x, axis.y, axis.z);

    now it works great until i get to a certain spot then it eats it and stops billboarding, Is it because of the gimbal lock because i have no f'n idea what or how to fix it.


    Dan
    --
    Dan
    (average joe)

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Another billboarding problem

    Your code is not entirely clear to me.

    You need to rotate the object to point to the viewer, so the orientation vector for the billboard should be player_position - billboard_position. Given that vector you just rotate the object using the computed angle, what could be simpler. Using something like atan2f could give you the angle, watch your component signs and quadrants.

    Given that you already have the vector to the object you could normalize and then you have the unit length multipliers you can transpose to directly rotate the billboard. That vector can directly be applied to the axis aligned geometry to orient it correctly without computing the angle.

    I have a few tips here:
    http://www.dorbie.com/billboard.html

    On the bottom of that you will find:

    In addition to these optimizations the trigonometry of the problem is exploited in that the billboarding is at right angles to the viewing vector, this allows us to perform the billboarding using a simple 90 decree rotation of the normalized viewing vector terms for x and y so x = width * vy and y = width * -vx, this means that our billboarding costs just a few multiplications and a square root per tree, if each tree were of unit dimension the cost of computation would be further reduced, if surface normals calculations were used in the example then their computation would be almost free.
    Note that x and y in the above quote are the equivalent of OpenGL x and z axes.

  3. #3
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Another billboarding problem

    P.S. it looks like you rotate around z anyway, perhaps you have a z = up renderer afterall.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    224

    Re: Another billboarding problem

    I just keep a local copy of my camera's position and orientation and use those rather than getting the modelview matrix.

Posting Permissions

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