Sign in to follow this  

ID3DXSprite and Zoom

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

Hi, I just toyed around with the ID3DXSprite a bit more and I used DrawTransform to move it. But somehow it doesn't react to translations on the z-axis. I can't zoom it with DrawTransform. Is this even possible? Thanks in advance.

Share this post


Link to post
Share on other sites
I'm not sure but maybe this is what you mean:
Quote:
From the DirectX documentation
HRESULT Begin(
DWORD Flags
);


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.

Share this post


Link to post
Share on other sites
Quote:
Original post by MannyCalavera
Hi, I just toyed around with the ID3DXSprite a bit more and I used DrawTransform to move it. But somehow it doesn't react to translations on the z-axis. I can't zoom it with DrawTransform. Is this even possible?

Thanks in advance.


You can't "Zoom" stuff in a orthographic projection by moving it in the Z axis.
To "Zoom" a sprite you would apply a scale transformation to it before rendering. E.g.:

[Code]
pSprite->Begin();

D3DXMATRIX trans,scale;

D3DXMatrixScaling(&scale,2.0f,2.0f,1.0f);
D3DXMatrixTranslation&trans,50.0f,132.0f,0.0f);

scale *= trans;

pSprite->SetTransform(&scale);

pSprite->Draw(pTexture,NULL,NULL,NULL,0xFFFFFFFF);

pSprite->End();
[/Code]

Share this post


Link to post
Share on other sites
Thanks.

What makes me wonder is that I don't use an ortohographic projection, I use a perspective and show my sprites.

This article:

http://www.gamasutra.com/features/20010629/geczy_pfv.htm

said, that I can transform the sprites when I use matrices:

Quote:

Finally, for those wishing to go one step further, and maybe even dip your toes into 3D waters, the ID3DXSprite interfaces offer an alternate version of the Draw() function, called DrawTransform(). Instead of taking scaling, rotation, and translation (positioning) information, the DrawTransform() function takes a transformation matrix, which defines the geometrical transformations for every pixel using a 4x4 matrix. Using this you gain access to effects involving the Z-axis, meaning distances closer to or farther from the viewer. A popular effect is perspective, which would give your image the impression of receding into the distance. The use of transformation matrices is far beyond the scope of this article, but for those interested you can start with "About 3-D Transformations" in the DirectX 8 SDK and go from there. Be prepared to dig out your old math textbooks.


That's why I tried it. Is this wrong in itself?

Share this post


Link to post
Share on other sites

This topic is 4866 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.

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