[SOLVED] What kind of sprite implementation?

Started by
5 comments, last by sqpat 15 years, 8 months ago
im looking to create 2d sprites onscreen that have billboarding behavior (always face the camera) and also are NOT orthographic, i.e. they would work with xyz coordinates and and zooming in and out wouldn't leave them the same size. I'm sure textured quads can do it but the billboarding stuff was driving me mad, even working off a guide. I messed with d3dxsprite but found out that it worked orthographically. I'm looking at point sprites right now, and i'm not quite sure how they work and don't want to make the same mistake and do a whole implementation of it only to find out its not capable of this. So can point sprites give me the behavior i want? Or am I probably best off with textured quads after all? Or is there another option? [Edited by - sqpat on July 27, 2008 7:50:36 PM]
Advertisement
Just use textured quads and use a rotation matrix to orient them perpendicular to eyePoint-quadCenter.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

D3DXSprite doesnt "work orthographically", at least not with configurations I'm familiar with. You can set the world space position for each sprite and they can face that camera if you want...

I reccomend trying it again using some sample code: its the best and easiest way to render lots of textured quads. If you still have problesm post here and some can help.
Here u can find some tutorial abaut sprites:

http://www.electricstreams.com/
Quote:Original post by Matt Aufderheide
D3DXSprite doesnt "work orthographically", at least not with configurations I'm familiar with. You can set the world space position for each sprite and they can face that camera if you want...


really?? They were so easy to work with that i was disappointed that they seemed to only work with screen cooridnates. How do you do this then? Like, the Draw method seems to only work in 2d; the z argument in the vectors of the center/position arguments seem to be ignored. I'm looking at the flags and i don't see one that seems to apply either. All the tutorials i find seem to be screen space only.


i'm fairly close to getting textured quads working too, but i'd like to try both methods if they both really work so i can decide for myself which one i will stick with for the long haul.
You can use D3DXSprite to do 3d billboards. Jet set the matrix properly before drawing, and don't allow D3DXSprite to set its own ortho matrix, which it does by default (there is a "do not modify render state" flag, look in the docs).
EDIT NUMBER 2:


Okay, i think i get it. Set the objectspace flag. Scale matrix to make it smaller, looks like the position argument to draw doesnt matter with the objectspace flag, so i just apply the rotation and translation. I guess that will work.

I can't turn on the do not modify render state flag because that makes the sprite texture come up blank.
I can't turn on the billboarding flag because that makes the sprite disappear.

But if i do it the way i said, i believe it will work.


One last minor question... how do i define the alpha/transparent color for the sprite?

[Edited by - sqpat on July 27, 2008 6:27:13 PM]

This topic is closed to new replies.

Advertisement