D3DXMatrixIdentity(&mat);
Sprite->SetTransform(&mat);
if(Tex_scale_x < 1) Tex_scale_x+=0.1;
if(Tex_scale_y < 1) Tex_scale_y+=0.1;
I want to achieve a visual effect, very known and common - that an image from 0*0 size grows to its normal size very quickly. And the code above does what it was supposed everything is rendered from the left up corner and that's why only right and bottom part of image coordinates increase. Is such visual effect that sprite grows in all directions from 0*0 size to its normal size possible to achieve?
I am finding your question difficult to understand. You want to know if it is possible to scale an image? By scaling, I mean increasing its size? Isn't that what you are already doing?
What exactly are you trying to accomplish?The code in your posts shows that you know how to scale an image, so what other type of scaling are you trying to do?
You know how to scale something to (0, 0), you know how to scale something to (.5, .5) What other information do you need?
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
heh , sorry for that. What I want to achieve is a visual effect by the means of scaling. I want to grow image from 0*0 size to its original size. The scaling starts from the left top corner of image so left top corner of this image whatever the scale value is, remains with same coordinates. only right, bottom and right-bottom corner's coordinates change. That's becouse the centre of scaling is left top corner and I want to scale the image in all 4 directions so that all 4 corners change their coordinates (left part of image grows in left, right grows in right, down in down, up in up direction). I hope It's clearer
You want the images top left corner to remain static while the image increases in scaling?
Easy enough. simply move the image before you preform the scaling to correct location, then preform the scaling.
For example, if the image is 40x40, and you want the top left corner of the image to remain at the screen position 100,100.
First move the images top left corner to 100,100. You know the size of the image 40 x 40, and you know moving an image moves its center. SOOO
the center of the image is 20x20, which you get by dividing the dimensions in half. So, to move the image to 100,100, simply move the image to 120,120. This will place the images top left corner at 100,100
Now, if you are scaling this, you have to a little bit more work.
Say, you scale the image by 1/4 on each dimension, meaning, the total size of the image is now, 40 * 1/4 = 10. So, 10x10
The center of the image is now, 10/2 = 5. So the center of the image is 5,5, simply add this onto 100,100, to get 105,105 as your new position to move the image to if the scaling is 1/4
I did not write it out completely using a bunch of math formulas, because its not that difficult.
That work for you?
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.