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
textures on my ID3DXSprite show up upsidedown!
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.
What texture coordinates? I said Im using the ID3DXSprite interface :/ World is definetly not upside down, just double checked (up is +y and down is-y)
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();
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.
I don''t know why what you''re doing is causing texture inversion, but just a couple of notes:
You''re scaling after translation, which will cause extra translation. Scale first, then translate (i.e. wd = sc * id)
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
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
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?
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?
Projection matrix:
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.
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.
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
So negating the Y-value in your transform matrix makes sense.
xyzzy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement