View Full Version : Billboarding???
I was wondering how to use the billboarding effect (where a certain poly always faces the viewer), i am using the LookAt function. So i dont really know the roation values...so does anybody know how to make a certain polygon always face the viewer, while using the LookAt function?
P.S. any code would be greatly appreciated http://www.opengl.org/discussion_boards/ubb/biggrin.gif
First I would suggest that you post that question in the beginner or advanced forum http://www.opengl.org/discussion_boards/ubb/smile.gif
It's just simple trigonometry.
In glulookat, the 3(eyex,eyey,eyez) first point are the position of the camera. The other 3(centerx,centery,centerz) are the point where the eye look at. The 3 last or the position of the up-vector.
So, the "looking" direction vector is :
(centerx - eyex, centery - eyey, centerz - eyez).
Let's say you only want the billboarding to happen when there is a y rotation(there is billboarding when you are horizontaly moving around the object)
Now let's say that your billboarded polygon was on the x axis first at (X1,0,0) for center. you calculate the X angle between that point and the vector:
Xangle = atan (X1 / (centerx - eyex)
Rotangle = 90 - Xangle;
this is just one case. depending if you are in wich quadrant around the object. I'm sure you can easely figure it out by taking a sheet of paper and doing some tests.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.