Sign in to follow this  
kogh

blurry translated d3dxsprite object

Recommended Posts

kogh    122
Ok so I have a sprite using the D3DXSprite class and while moving it, the texture gets all blurry and antialiased. the sprite shows up fine on the screen at first, it only gets blurry when I press, for example, the right arrow key and after it's translated to its new position BAM it looks terrible. here's an example image on the left is how it looks initially, image on the right is how it looks after it has been translated. now, I solved this problem before by changing the speed at which my tank moves to a whole number like 1.0f or 2.0f, etc rather than what its at now (0.02f). 1.0 and above of course is too fast. so besides adjusting the speed is there anything else I can do? here's some code:

//...
float  g_fMoveSpeed = 0.02f;
float fPositionX = 0.0f;
float fPositionY = 0.0f;
float fPositionZ = 0.0f;
int nFrame	   = 0;
D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vPosition( fPositionX, 50.0f, 0.0f );

//...


//...
if(KEY_DOWN(VK_RIGHT))
{
    Move(fPositionX += (1.0f* g_fMoveSpeed), fPositionY, 0.0f);
    g_Dir = 1;
    g_Dir2 = 0;
    nFrame = g_Dir2;
}
//...


int Move(float x, float y, float z)
{





	D3DXMatrixTranslation(&matTrans, x, y, z);
	sprite->SetTransform( &matTrans );

	return 0;
}

Any help is GREATLY appreciate, guys. I want the blurriness to STOP >:O

Share this post


Link to post
Share on other sites
Stephen R    721
It seems that when the tank is aligned to exact pixel then it is getting blurred by DX. Try changing

D3DXMatrixTranslation(&matTrans, x, y, z);

to

D3DXMatrixTranslation(&matTrans, (float)((int)x), (float)((int)y), (float)((int)z));

Which will make sure it is always aligned to the nearest whole pixel, while still allowing you to have any movement speed you want.

Hope that helps.

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