D3DXSprite

Started by
7 comments, last by Programmer16 18 years, 10 months ago
How can i put d3dxsprite into object space? D3DXSPRITE_OBJECTSPACE? and i could need a example.
Advertisement
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?
------------------------See my games programming site at: www.toymaker.info
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();
Can i "move" the sprite in 3D space? or use buffers?
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).
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 hereSprite->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.)
Programmer16, That what i'm looking for!
Think you.
What tutorial did you readed.
But i'm not sure how to setup the matrix?
The only good D3DXSprite is for gui stuff and that's it.
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.

This topic is closed to new replies.

Advertisement