Archived

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

Theory on rotating with billboards....

This topic is 5581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
simply use the inverted camera-matrix
like this:

D3DXMATRIX mCamera;
D3DXMATRIX mTransform;
D3DXVECTOR3 vPosition; // the position vektor
g_pDirect3DDevice->GetTransform(D3DTS_VIEW,&mCamera);
D3DXMatrixInvert(&mTransform,&mCamera);
mTransform._m41 = vPosition.x;
mTransform._m42 = vPosition.y;
mTransform._m43 = vPosition.z;
g_pDirect3DDevice->SetTransform(D3DTS_WORLD,&mTransform);
// drawing goes here

Share on other sites
Can you show your getbearing function? And why not use the tradional matrix solution?

.lick

Share on other sites
How would you use the inverted camera matrix to rotate only about the Y axis?

pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

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;		}

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

Share on other sites
Why not try to get the view matrix, and then extract the Y rotation out of it? THe above tutorial shows you how, IIRC!

.lick

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 14
• 18
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633360
• Total Posts
3011516
• Who's Online (See full list)

There are no registered users currently online

×