I packed several images to a single one by using texture packer.But I don't know how to exactly restore each of them to the original one when drawing.
Each image may be trimmed and/or rotated after it is packed.For only roated image,I think I can simply restore it by multiplying a rotate matrix.But for timmed,how should I do?

stefnotch

05-07-2016, 03:58 AM

What you have done is called: Texture Atlas

You will need to know the coordinates of the individual images. If you combined them, with regular spaced images (look for "minecraft textures"), it is a pretty easy task.

Then, pass the correct texture coordinates to the shader.

liyao0602yy

05-07-2016, 06:49 AM

What you have done is called: Texture Atlas

You will need to know the coordinates of the individual images. If you combined them, with regular spaced images (look for "minecraft textures"), it is a pretty easy task.

Then, pass the correct texture coordinates to the shader.

Yes,it is indeed very simple if all images are not trimmed.Just as you said, what I need to do is to send the image's texture coordinates in the texture atlas to shader.But now it is trimmed which means the size is smaller than the original one.So if I oh....I got it!
In fact what I concerned about is the pivot point of the image trimmed will be different from it of the orignal image while the same pivot point value are set for both. Now I see. I only need to transform the pivot point coordinate of the original image to that of the trimmed image.
Thank you so much.