Sign in to follow this  
vgmtech

D3DXSprite

Recommended Posts

Not 100% clear on what you are asking here. Normally object space refers to the space a 3D model is created in and is normally centred on 0,0,0. A sprite is a 2D image only and hence has no such thing. Probably I have misunderstood the question?

Share this post


Link to post
Share on other sites
not sure what your trying to do but this may help you understand

sprite->SetWorldViewLH(world, view);
sprite->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_BILLBOARD | D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_DEPTH_BACKTOFRONT);

sprite->Draw(texture, NULL, &D3DXVECTOR3(pos->x+w, pos->y+h, 0.0f), pos, D3DCOLOR_RGBA(255, 255, 255, 255));

sprite->End();

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by vgmtech
Can i "move" the sprite in 3D space? or use buffers?

Sprites use an ortho projection and work on the screen space. To get a perpective effect when moving the "sprite" in Z direction, you can use PointSprites or a texture mapped on a 3D plane (two triangles).

Share this post


Link to post
Share on other sites
I believe that you're looking for:

Sprite->Begin(D3DXSPRITE_OBJECTSPACE);
/*
D3DXSPRITE_OBJECTSPACE:
The world, view, and projection transforms are not modified. The transforms currently set to the device are used to transform the sprites when the batched sprites are drawn (when ID3DXSprite::Flush or ID3DXSprite::End is called). If this flag is not specified, then world, view, and projection transforms are modified so that sprites are drawn in screen-space coordinates.
*/


D3DXMATRIX SRTMatrix;
// Scale here
// Rotate here
// Translate here
Sprite->SetTransform(&SRTMatrix);
Sprite->Draw(pTexture, &Rect, &Center, &Position);




I haven't tried this code, but I believe that is how it is done (I read a tutorial about 2 months ago.)

Hope that helps!

Edit:
You might need to call Sprite->SetWorldViewLH() in there somewhere, I don't know (I've just begun using 3D graphics.)

Share this post


Link to post
Share on other sites
Programmer16, That what i'm looking for!
Think you.
What tutorial did you readed.
But i'm not sure how to setup the matrix?

Share this post


Link to post
Share on other sites
I didn't read a tutorial I look at the documents and figured it out. I knew that transform(ation) is manipulation of 3D objects and I knew that they had to be in object space.

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