Jump to content
  • Advertisement
Sign in to follow this  
sqpat

[SOLVED] What kind of sprite implementation?

This topic is 3767 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

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]

Share this post


Link to post
Share on other sites
Advertisement
Just use textured quads and use a rotation matrix to orient them perpendicular to eyePoint-quadCenter.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Here u can find some tutorial abaut sprites:

http://www.electricstreams.com/

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!