I’m trying to Billboard some quads in a viewer that uses an orthographic projection. I’ve been through the tutorial by Antonio at Lithhouse and have tried the Cylindrical Cheat as well as True Cylinfrical methods and can’t make them work.
The cheat does keep the quads facing the camera but their position is static and won’t change as you rotate the scene.
The true method rotates the quads but their orientation doesn’t change.
Is my problem the ortho projection or does it have to do with the way my ModelView matrix is being formed?
Check where your glRotate is located in reference to your billboards. So, yes probably your modelview.
I’m not using glRotate but instead calculate a rotation matrix based on the viewing direction in the XZ plane, a tilt matrix and then multiply and load.
Too make it a bit more difficult I add in scaling and translation in local coordinates and world coordinates. I’ve eliminated them for my test data but I won’t be able to do this with real data.
If I were starting over I’d probably do it differently but its worked very well so far.
Mitch, store your billboards as a single point and a size. Dont store the actual vertices of them. After you set up the modelview matrix for your camera, you take the point, and just add the size along the x and y planes to get the vertices.
so something like this:
//Do camera transform here…
glVertex3f(point.x - 10, point.y + 10, point.z);
glVertex3f(point.x - 10, point.y - 10, point.z);
glVertex3f(point.x + 10, point.y - 10, point.z);
glVertex3f(point.x + 10, point.y + 10, point.z);
where point is the location of your billboard and 10 is the size.
Does that help?
And the grand prize winner is…IOQUAN! Thanks that worked, I knew it shouldn’t be that hard.
Multiply XYZ Coordinate by Modelview
Calculate 4 Quad vertices in XY Plane
Set Identity Matrix