Sign in to follow this  

trouble using D3DXMatrixTransformation2D

Recommended Posts

Hello everyone, I'm working on my first game which is a sprite 2D game. I'd like to have one of the sprites rotate on user input. I've done research on gamedev and I came across D3DXMatrixTransformation2D. I'm trying to implement this functions, but when I call sprite_handler->SetTransform(&mat) then the sprite_handler->draw(..) doesn't draw anything on the screen. i have tested by commenting out sprite_handler->SetTransform(&mat), in which case the sprite is drawn correctly. The parameters passed in D3DXMatrixTransformation2D are as generic as i could imagine just so the image is rendered, but i'm guessing they could be wrong as well. here is the code, any help is greatly appreciated!

        D3DXVECTOR2 vCenter( 0.0f, 0.0f );
        D3DXVECTOR2 vScale( 100.0f, 100.0f );
        D3DXVECTOR2 vPosition( (float)100, (float)100 );
        D3DXVECTOR2 vRotationCenter( (float)0.0, (float)0.0);

        D3DXMATRIX mat;


Share this post

Link to post
Share on other sites
The parameters ... are as generic as i could imagine

I don't think a scaling factor of 100.0f would be considered "generic." If you still want to use the transformation, use a scaling factor of 1.0f and change it a little until you get what you want.

Share this post

Link to post
Share on other sites

Yes, i think that the big issue i had with this particular function was that it lacked ranges for the values. So I didn't know what to do. 100.0f was just a random value that I had tried along with a lot other values.

Finally I tried having all values null and slowly turning them on until i found what my issue was.

Initially my scale was 0.0f (thinking it would be no-scale) but it turns out it means scale to 0.0% from 100% image.

I hope this helps other people in the future =)

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