knoxcoder
-
Posts
2 -
Joined
-
Last visited
Content Type
Forums
Store
Gallery
Downloads
Posts posted by knoxcoder
-
-
I'm having trouble getting the images to line up correctly when we export a texture atlas that trims empty space.
Correct version:
I thought I could scale the quad based on the original vs atlas size:
Rect size(0, 0, originalSize.x, originalSize.y);
Vector2 temp(originalSize.x * pivot.x, originalSize.y * pivot.y);
size -= temp;
float sx = textureSize.x / originalSize.x;
float sy = textureSize.y / originalSize.y;
size.left *= sx; size.right *= sx;
size.top *= sy; size.bottom *= sy;It produces this:
So next I tried to use the offset from the top/left which is the amount removed from the top/left. The idea is to compute the original quad and then get the true quad based on that:
Rect size(0, 0, originalSize.x, originalSize.y);
Vector2 temp(originalSize.x * pivot.x, originalSize.y * pivot.y);
size -= temp;
size.left += offset.x;
size.right += offset.y;
size.right = size.left + textureSize.x;
size.bottom = size.top + textureSize.y;It produces this:
Any ideas what I'm doing wrong here?
Robert
Texture altas and pivot points
in Developer Help
Posted
This worked. Thanks.
Robert