Archived

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

Fastest way to do 3D billboard rotation?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

The quickest, as in the fastest way to implement the code, or the fastest way to do the calculations?

Essentially, the most efficient and easiest way to do this would be to use rhs, which is transformed world coordinates allowing you to draw on the screen as if it was a bitmap. All you have to do is scale and transform in 2D. Which isn''t hard math, e.g.

Take distance from camera coefficient, where closest to camera near plane = 1.0f. This way you will likely have to do own effects.

For more info on implementation in DX look up D3DFVF_XYZRHW

Which is the Fixed Vertex Function for transformed vertices.

Doing it with a z buffer wouldn''t be a bad idea either, just rotate it by the inverse of the camera''s orientation (I believe) there is a demo in this.

-------
"Programming is like sex make one mistake, and you have to support it forever."
Homepage: http://students.washington.edu/andrey

Share this post


Link to post
Share on other sites
Thanks, but not really what I was looking for. I already know how to do the billboard effect, but I need the complete 3D rotation.

I thought of using the world matrix or the inverted camera view matrix, but then that will only works when the object is at the center of the view. If the object moves to the edge, it will be little angled from the camera. So, I''m thinking that maybe I need to use the object-to-camera cooridnations for all the objects. But the way I''m thinking, it will take tunes of sin & cos calculation. So, I was wondering if there''s any shortcut for this.

-Thanks

Share this post


Link to post
Share on other sites
a quite simple shortcut. look at the samples.

for the lazy (this may not be the way the samples handle this) you could create some vetors and transform them using D3DXVec3Trasnform (or something, you properly need to transform the coordinates as well with the camera/perspective matrices, look at all those lovly d3dx functions for handling this) and build the correct matrix to move the center point of the billboard. then at rendertime you use this point to create the quads for drawing. you wonder how to handle the perspective (ie size of the billboard as it goes away from the camera)? simple thats what the rhw value is for when you transform the vertices.

you could just use point sprites however (in fact the point sprite sample shows how to do billboarding as well).

Toyemann, dont say you know how to do the billboarding effect. if you did you would not be having this problem

http://nate.scuzzy.net/docs/billboard/ explains how to create the quad. thurd hit on google (the first two were more in depth). dont complain it uses opengl, the theory is the same.

Share this post


Link to post
Share on other sites
thanks for your prompted replies.

i don''t really have a problem, i just wanted to know if there was any shortcut doing one. the one that every billboards are facing the camera and not just the opposite direction of the camera. anyway, back to coding...

thanks again.

Share this post


Link to post
Share on other sites