Jump to content

knoxcoder

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by knoxcoder

  1. I'm having trouble getting the images to line up correctly when we export a texture atlas that trims empty space.

    Correct version:

    post-10655-14159834127904_thumb.png

    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:

    post-10655-14159834125658_thumb.png

    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:

    post-10655-14159834127072_thumb.png

    Any ideas what I'm doing wrong here?

    Robert

×
×
  • Create New...