This topic is now archived and is closed to further replies.


Theory on rotating with billboards....

Recommended Posts

Hey, im trying to create a billboard, but havent been able to get it working. Like what i tried doing was find the angles from the billboard to the camera point. eg x -axis, y axis z axis like i worked the angles like this xAxis=getbearing(bz,by,cz,cy) yAcis=getbearing(bx,bz,cx,cz) etc get bearing was just a function i made to work out the angle between 2 points on a graph. bx etc is for billboard and c etc is for camera point when i ran this code it worked sometimes but if you got the camera 2 close to it, it would flip over and look a little bit silly. Any ideas on how to do it properly? Thanks

Share this post

Link to post
Share on other sites
simply use the inverted camera-matrix
like this:

D3DXMATRIX mTransform;
D3DXVECTOR3 vPosition; // the position vektor
mTransform._m41 = vPosition.x;
mTransform._m42 = vPosition.y;
mTransform._m43 = vPosition.z;
// drawing goes here

Share this post

Link to post
Share on other sites

float GetBearing(float a, float b, float a2, float b2)
float offA= abs(a-a2);
float offB= abs(b-b2);
float answer;

if (a2>a && b2<b) answer= atan(offB/offA);
if (a2<=a && b2>b) answer= atan(offA/offB)+(D3DX_PI/2);
if (a2<a && b2<=b) answer= atan(offB/offA)+D3DX_PI;
if (a2>=a && b2<b) answer= atan(offA/offB)+(3*D3DX_PI/2);

return answer;

ill try your suggestions

and i don''t know of any traditional matrix solution...

Share this post

Link to post
Share on other sites