Jump to content

knoxcoder

Members
  • Posts

    2
  • Joined

  • Last visited

knoxcoder's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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
×
×
  • Create New...