Jump to content
  • Advertisement
Sign in to follow this  
roloenusa

trouble using D3DXMatrixTransformation2D

This topic is 3809 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 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;

        D3DXMatrixTransformation2D(&mat,&vCenter,NULL,&vScale,&vRotationCenter,0.0f,&vPosition);
        sprite_handler->SetTransform(&mat);
        
        sprite_handler->Draw(
            viperII_image,
            NULL, 
            NULL,
            &position, 
            D3DCOLOR_XRGB(255,255,255));

Share this post


Link to post
Share on other sites
Advertisement
oh, looks like i narrowed down the issues to vScale! i'm not sure why this would cause such a ruckus but it seems to work without it.

Thank you and sorry for wasting your time =)

Share this post


Link to post
Share on other sites
Quote:
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
Hehe..

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!