Quote:Original post by Mussi
Quote:If I try reducing them by 1 for purposes of calculating m_src_rect.bottom and m_src_rect.top, three things happen:
B) The border still appears around the left and top of the sprite when rotated (though the right and bottom borders are no longer visible)
A) Sorry, my earlier post was incorrect in describing my attempt at a fix. What I meant to write was:
Quote:If I try reducing them by 1 for purposes of calculating m_src_rect.bottom and m_src_rect.right, three things happen:
So what I'm saying is, I changed the code to the following, per your suggestion:
m_src_Rect.top = 1 + ((m_curr_frame / m_x_cells) * (m_height + 1)); m_src_Rect.left = 1 + ((m_curr_frame % m_x_cells) * (m_width + 1)); m_src_Rect.bottom = m_src_Rect.top + m_height - 1; m_src_Rect.right = m_src_Rect.left + m_width - 1;
Quote:I think you're forgetting that you added +1 to the left and top. You should reduce m_src_Rect.bottom and m_src_Rect.right by 2.
I need to add +1 to the left and top because the border surrounds all the frames. Reducing m_src_Rect.bottom and m_src_Rect.right by 2 not only does not make sense, but does not help either - the clipping on the right is even more severe (since I'm essentially reducing the width and height by 2, instead of 1 or 0).
Quote:If that doesn't help, make sure your rectangle(the area enclosed in the outer border) is not wider that 98 pixels(rect.right-rect.left) and that it's not higher than 115 pixels.
First, m_src_rect should only encompass one cell (i.e., one frame), not all six cells - so if by "rect.right-rect.left" you mean "m_src_rect.right-m_src_rect.left", then it should be 33 x 57.
I counted and made sure the entire six cells with their borders are 100 x 117 pixels. If I discount the outer borders (but keep the separating borders in the middle), the six cells are 98 pixels by 115 pixels.
That is, for a rectangle of 3 x 2 cells:
width = 1 (outer border) + 32 (first cell width) + 1 (first middle border) + 32 (second cell width) + 1 (second middle border) + 32 (third cell width) + 1 (outer border) = 100
height = 1 (outer border) + 57 (first cell height) + 1 (middle border) + 57 (second cell height) + 1 (outer border) = 117
Like I said, the image linked above is the actual texture I use - you can check for yourself if you don't believe me, but I've checked and re-checked that my sizes and numbers are correct.
Quote:Original post by Aiwendil
Any reason why you can't just get rid of the border in the image itself?
Like I said, I COULD simply use transparent borders - but that seems like an awkward requirement and workaround. I specified a rectangle with top-left coordinates of (1, 1) to DirectX - so DirectX should draw my image with no regard for what kind of pixels are at (0, 0) or (1, 0) or anything else above (1, 1), since y = 1 should be the highest row of pixels it's using.
What if I had my sprite cells all next to each other without ANY border? In principle, it seems like I should be able to do that. But with this problem, the images will overlap slightly. If the top three rocket cells were blue and the bottom three were red, then attempting to draw the fourth cell, for example, would draw a mostly red rocket with a blue tip at the top (since the blue rocket in the first cell's position is bordering the top of the red rocket in the fourth cell's position).
Nothing in the documentation says your images cannot border one another in the texture. Likewise, nothing suggests your images must not only have a border, but that it be transparent as well.
Which leads me to believe that it isn't a requirement for accurate images, and that something wrong must be occurring. Otherwise, wouldn't this problem be mentioned somewhere by MS?