• Advertisement
Sign in to follow this  

ID3DXSprite in 3D

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

Is that any way to use ID3DXSprite interface to draw arbitrary semi-transparet quads (e.g. leafs and limbs of the trees)? Quads would not be bilboarded. I found some flags in the ID3DXSprite::Begin() method, like D3DXSPRITE_ALPHABLEND, D3DXSPRITE_OBJECTSPACE and D3DXSPRITE_SORT_DEPTH_BACKTOFRONT. And also funcions SetTransform() or SetWorldViewLH(). Can these be used and how? Or sprites can be only bilboarded? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Hi there JoystickX,
The ID3DXSprite interface.
"The ID3DXSprite interface provides a set of methods that simplify the process of drawing sprites using Microsoft Direct3D."

What is a sprite?
"A bitmap of an arbitrary shape that can be moved across complex backgrounds without flicker or damage to the background image."

How do I use it?
[Creating a sprite]
D3DXCreateSprite()
"Creates a sprite object which is associated with a particular device. Sprite objects are used to draw 2-D images to the screen."

[How to draw a sprite]

ID3DXSprite::Begin Method
"Prepares a device for drawing sprites."

ID3DXSprite::Draw Method
"Adds a sprite to the list of batched sprites."

ID3DXSprite::End Method
"Calls ID3DXSprite::Flush and restores the device state to how it was before ID3DXSprite::Begin was called."

That's a very simple break down of what you want to do :)
Hope this helps.

PS: Sprites are automatically billboarded (They face the always face the camera)

[Edited by - Armadon on July 30, 2005 4:06:48 AM]

Share this post


Link to post
Share on other sites
Hello Joystickx

Quote:

Sprites are automatically billboarded (They face the always face the camera)


No not if you pass the D3DXSPRITE_OBJECTSPACE flag to ID3DXSprite->Begin.

These D3DSprites are built up of 4 verts each. The width and height of the sprite is the width and height of its texture. The center-point of the sprite is that you pass to the Draw function (3rd argument i belive).

If you pass the D3DXSPRITE_OBJECTSPACE flag to Begin() then all vectors of the sprites will be in object-space (with the center-point as (0,0,0)). Then you can apply transformations like scaling and rotation around all 3 axis. This is what youll need for leaves etc in 3d.

If you dont pass the D3DXSPRITE_OBJECTSPACE flag, then all vectors of the sprites will be treated as on-screen coordinates. Also the sprites will be billboarded = No X or Y rotation (i think, i always use D3DXSPRITE_OBJECTSPACE). This option is good for user interface.

The D3DXSPRITE_ALPHABLEND tells ID3DXSprite that texels with any alpha value will be transperant. You dont need this flag if you enable alphablending manualy.

Hope it helps to get you started!

//Emil

Share this post


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

  • Advertisement