Custom 2D Sprite (like billlboard) help

Started by
2 comments, last by necreia 19 years, 1 month ago
I've had lots of questions lately, hopefully this is last one for a while: I've been working on a custom 2D sprite class that functions much like Billboard in DirectX9 (just needed some special elements to it that billboard did not offer). The only problem I run into now, is keeping the image always 'facing' the camera on the y/z (not x). So if you 'went around the image' it always faced you (unless you went from top/bottom you would eventually see a line/nothing because it doesn't conform to that angle). My first method for doing this was attemping to note the rate of change of the right vector of the camera, then apply the change scaled on the image... but couldn't get it to work properly and was somewhat too heavy to do such tests. My next idea is try to make the 'camera_vector to camera_right_vector' line segment to be parelell to the 'sprite_left_vector to sprite_right_vector' line segment. But I don't know exactly what kind of equasion I need to go about this. Is there an obvious solution that I am missing? (I am using DirectX8.1 atm, not 9) - Thanks
Advertisement
i havent done this yet, but i think this may help

your billboarded texture needs one point where its located and a width and a height, now you have the direction your cam is pointing to, make this the normal vector of the billboarded texture plain and now you can use some simple trigonometrics to calculate the points of this plain (note: cam and plain are building a simple pyramid)

i hope this helps, but the math stuff is up to you

--------------------------------------------------------------------------------
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
-------------------------------------------------------------------"Debugging is twice as hard as writing the code in the first place.Therefore, if you write the code as cleverly as possible, you are,by definition, not smart enough to debug it." - Brian W. Kernighan
Hmm... right.

I was over complicating it a little, thanks!
If anyone else has this problem, which was for a billboard constrant quad, was:

X = <Py - Cy,Cx - Px,0>

Q1 = P + (w/2)(X/|X|) + <0,0,h/2>
Q2 = P - (w/2)(X/|X|) + <0,0,h/2>
Q3 = P - (w/2)(X/|X|) - <0,0,h/2>
Q4 = P + (w/2)(X/|X|) - <0,0,h/2>

Q1-Q4 = the four face verticies
C = Camera world space point
P = Quad center point
X = X used for caculation
w = Width of the quad
h = Height of the quad

(obtained from "Mathematics for 3D Game Programming & Computer Graphics"... I really suggest this book to anyone who needs math help, it has been a godsin. GDev sells it here http://www.gamedev.net/columns/books/bookdetails.asp?productid=160)

This topic is closed to new replies.

Advertisement