D3DXMATRIX temp;
D3DXVECTOR2 scale(0.5f,0.5f);
D3DXMatrixTransformation2D(&temp, NULL,0.0f,&scale, NULL, 0.0f, NULL);
g_engine->GetSprite()->SetTransform(&temp);
ID3DXSprite scaling question
I am working on a RTS game where the player can scroll around the world by moving the window. If I leave the scale set to 1.0f everything works perfectly, but when I scale the buildings to 0.5f or anything for that fact they seem to wander with the movement of the window. My question is how do determine the screen coordinates of a texture that has been scaled. I am basically keeping up with the current viewport location and modifying each object based on the window's position. I have to double the win.left and win.top coordinates to make a scale of 0.5f work, but when I have it set to a scale of 1.0f I don't have to modify anything. It could have something to do with the way I am scaling the building
Thanks in advance for any tips
The Sprite's screen location is also scaled by the same transformation matrix. That means that if you're are scaling by a factor of 0.5, and you want to Sprite to be at location X, you need to divide it by the scaling factor: newX = oldX / 0.5. This is then scaled by the scale factor, which is 0.5, and is thus eliminated, leaving the actual position the Sprite is drawn to as X.
Since you're using a 2D transformation matrix, you probably won't have to scale the Z value at all.
Hope this helps.
Since you're using a 2D transformation matrix, you probably won't have to scale the Z value at all.
Hope this helps.
Quote:Original post by sirob
The Sprite's screen location is also scaled by the same transformation matrix. That means that if you're are scaling by a factor of 0.5, and you want to Sprite to be at location X, you need to divide it by the scaling factor: newX = oldX / 0.5. This is then scaled by the scale factor, which is 0.5, and is thus eliminated, leaving the actual position the Sprite is drawn to as X.
Since you're using a 2D transformation matrix, you probably won't have to scale the Z value at all.
Hope this helps.
That makes a lot of sense!
Thank you
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement