Sign in to follow this  
chillypacman

sprites in a 3D world?

Recommended Posts

I'm working on a game in which the world is 3D but populated with sprites (for trees and other such things). I'm not sure how to go about this. Should I just render the textures to a plane with alphablending? If I do it like this I'm not sure how I can render portions of a texture (for instance off a sprite sheet). Just looking for generel ideas on techniques on how to do this. Thanks in advance :)

Share this post


Link to post
Share on other sites
The technique is generally referred to as "billboarding" and is quite common, so you shouldn't have much trouble finding info on it. The gist of the technique is that you define a location which would serve as the "center" of your object. You create a textured quad (two triangles) such that it always faces the camera.

For some objects, you may want to constrain their rotation in some way. For example, trees, signs, light posts, walking baddies and other objects which are essentially anchored to the ground are usually constrained to rotate only around the vertical axis. This prevents odd-looking scenes from occuring when the camera looks at the object from a steep vertical angle in which the object might otherwise appear to be floating horizontally! For other objects, say a flying baddie, hud displays, large projectile or explosion, it might be appropriate to not constrain rotation in any way, since its reasonable to assume that it might always be facing the camera or would appear the same from any vertical angle. In general this later case applies to things that should *always* face the camera and to objects that are generally spherical in shape.

Share this post


Link to post
Share on other sites
thanks guys :)

I'm just having a small problem with the alphablending. INstead of blending the alpha regions of the texture are just going black, here's how I"m loading th etexture:

D3DXCreateTextureFromFileEx(
dev,
texdir,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DX_FROM_FILE,
D3DUSAGE_RENDERTARGET,
D3DFMT_FROM_FILE,
D3DPOOL_DEFAULT,
D3DX_FILTER_NONE,
D3DX_DEFAULT,
D3DCOLOR_XRGB(0, 0, 255),
&texinfo,
NULL,
&tex
);



It knows where the alpha region should be because whatever I change the alpha value renders as solid black but doesn't blend. So now blue regions are rendering as solid black when I run it in directx.

I've already enabeld SetRenderState(D3DRS_ALPHABLENDENABLE,true);


edit: n/m fixed :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this