Jump to content
  • Advertisement
Sign in to follow this  
asafpolt

ID3DXSprite::Draw() parameters

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

Hello, I am trying to write a nice little particle engine for my game. To achieve this I figured I should learn billboarding and alpha-blending. I want to achieve billboarding using sprites but I can't figure out what the parameters in ID3DXSprite::Draw() mean. especially the two D3DXVector3 parameters. Help would be highly appreciated. Thanks, Asaf, Israel

Share this post


Link to post
Share on other sites
Advertisement
Hi,

This was taking from the SDK.


ID3DXSprite::Draw Method

--------------------------------------------------------------------------------

Adds a sprite to the list of batched sprites.

Syntax

HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture,
CONST RECT *pSrcRect,
CONST D3DXVECTOR3 *pCenter,
CONST D3DXVECTOR3 *pPosition,
D3DCOLOR Color
);
Parameters

pTexture
[in] Pointer to an IDirect3DTexture9 interface that represents the sprite texture.
pSrcRect
[in] Pointer to a RECT structure that indicates the portion of the source texture to use for the sprite. If this parameter is NULL, then the entire source image is used for the sprite.
pCenter
[in] Pointer to a D3DXVECTOR3 vector that identifies the center of the sprite. If this argument is NULL, the point (0,0,0) is used, which is the upper-left corner.
pPosition
[in] Pointer to a D3DXVECTOR3 vector that identifies the position of the sprite. If this argument is NULL, the point (0,0,0) is used, which is the upper-left corner.
Color
[in] D3DCOLOR type. The color and alpha channels are modulated by this value. A value of 0xFFFFFFFF maintains the original source color and alpha data. Use the D3DCOLOR_RGBA macro to help generate this color.
Return Value


If the method succeeds, the return value is S_OK.

If the method fails, the return value can be one of the following values.


D3DERR_INVALIDCALL The method call is invalid. For example, a method's parameter may have an invalid value.
D3DXERR_INVALIDDATA The data is invalid.




ace

Share this post


Link to post
Share on other sites
Thanks a lot for showing me the sdk documentation which I obviously wasn't aware to its existance.
I'm just kidding, anyway what I didn't understand in the documentation is what the two D3DXVector3 params mean? it's not the location of the sprite in 3d space, or is it? and if so what the other one means???

Share this post


Link to post
Share on other sites
pCenter is the sprite's center. Usually, (0.0f, 0.0f, 0.0f) will do.

pPosition is the Sprite's position. If you're using the ObjectSpace flag, this would be it's position in object space (3d).

Share this post


Link to post
Share on other sites
would that mean I don't need to translate before rendering, because the position is already specified?

"pCenter is the sprite's center. Usually, (0.0f, 0.0f, 0.0f) will do." - why?
center where? I don't understand the difference between the two...

Share this post


Link to post
Share on other sites
The first parameter, pCenter, specifies what part of the sprite is it's center. If you specify (0.0f, 0.0f, 0.0f), this means that that point is the sprites center. If you place it somewhere else, it's center will be somewhere else. This is useful when you want to rotate the sprite around some point, so you need to specify what the center of rotation is. If you don't need to rotate around a specific center, set it to null.

The second parameter, pPosition, specifies where, in object space, to draw the sprite (I'm assuming you're using the ObjectSpace flag). If you set the world matrix to an identity matrix (what I do), then this position becomes the world position. This means that this is where in the world the sprite is drawn.

Hope this helps.

Share this post


Link to post
Share on other sites
that was helpful with the exception of:

"The first parameter, pCenter, specifies what part of the sprite is it's center."

but a sprite is 2d, so why it's center is described in 3d?

Share this post


Link to post
Share on other sites
Quote:
Original post by asafpolt
but a sprite is 2d, so why it's center is described in 3d?
Just to annoy people I think. The Z coordinate isn't used.

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!