Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

transformation

textures on my ID3DXSprite show up upsidedown!

This topic is 5403 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, Im using the ID3DXSprite interface with the summer update sdk. And I load in a texture and just set the world coords of the sprite and render it using the OBJECT_SPACE option.
        D3DXMATRIX wd, id, sc, rt;
        D3DXMatrixTranslation( &id, xpos, ypos, zpos );
        D3DXMatrixScaling( &sc, 0.05, 0.05, 0.05 );
        wd = id * sc;
        pSprite->SetTransform( &wd );
        pSprite->Begin( D3DXSPRITE_OBJECTSPACE );
        pSprite->Draw( pTexture, 0, 0, 0, 0xfffffffff );
        pSprite->End();
But my sprite is appearing oon screen upside down

Share this post


Link to post
Share on other sites
Advertisement
ok, I fixed the problem with a little hack. I specified negative scale values and the image looks fine now. Is that something that is *supposed* to be done? Or is there some other problem?


D3DXMATRIX wd, id, sc, rt;
D3DXMatrixTranslation( &id, xpos, ypos, zpos );
D3DXMatrixScaling( &sc, -0.05, -0.05, 0.05 ); // HACK

wd = id * sc;
pSprite->SetTransform( &wd );
pSprite->Begin( D3DXSPRITE_OBJECTSPACE );
pSprite->Draw( pTexture, 0, 0, 0, 0xfffffffff );
pSprite->End();

Share this post


Link to post
Share on other sites
Sounds about right. I remember trying to get rotation to work about an arbitrary point, and I had to use negative values. For example, to rotate a 100x100 sprite around its center, I had to set the rotation center to (-50,-50) not like you''d expect.

Share this post


Link to post
Share on other sites
I don''t know why what you''re doing is causing texture inversion, but just a couple of notes:

quote:
D3DXMatrixTranslation( &id, xpos, ypos, zpos ); D3DXMatrixScaling( &sc, 0.05, 0.05, 0.05 );
wd = id * sc;

You''re scaling after translation, which will cause extra translation. Scale first, then translate (i.e. wd = sc * id)

quote:
Sounds about right. I remember trying to get rotation to work about an arbitrary point, and I had to use negative values. For example, to rotate a 100x100 sprite around its center, I had to set the rotation center to (-50,-50) not like you''d expect

You had to use negative values to get rotation in which direction (Clockwise or Counter-clockwise), about what axis (positive or negative Z)?

Muhammad Haggag

Share this post


Link to post
Share on other sites
upon further testing, I''ve figured that to get the texture right way up, all I have to do is change the sign of the y scale value. So simply doing D3DXMATRIX::_22 = -D3DXMATRIX::_22; Gets the texture to show up right way.

Still dont know whats causeing this behavior in the first place. Can anyone confirm if they''ve had similar problems, or can anyone just make a small test and use ID3DXSprite to draw a sprite in world space and not screen space and see if they get similar behavior?

Share this post


Link to post
Share on other sites
Projection matrix:

D3DXMatrixPerspectiveFovLH( &mProjection,
D3DX_PI / 4.0f,
screenWidth/screenHeight,
1.0f, 1000.0f );


View matrix is being set inside my camera class. The up vector defaults to positive y and stays like that thorughout. The only thing I change constantly depending on the keyboard input is the eye position and the look at position. Nothing else.

Share this post


Link to post
Share on other sites
I believe the reason it is being drawn upside down is that ID3DXSprite always draws sprites in the XY plane, with X increasing from left to right, and Y increasing from top to bottom.

So negating the Y-value in your transform matrix makes sense.

xyzzy

Share this post


Link to post
Share on other sites

  • 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!