View Full Version : Another billboarding problem
06-15-2002, 04:24 PM
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.
angle = PIUNDER180*vVec.GetAngle(VECTOR3(0,0,1.f));
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.
06-15-2002, 05:34 PM
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:
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.
06-15-2002, 05:36 PM
P.S. it looks like you rotate around z anyway, perhaps you have a z = up renderer afterall.
06-16-2002, 10:01 AM
I just keep a local copy of my camera's position and orientation and use those rather than getting the modelview matrix.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.