m
→SetTexCoord Math with Matrices: Fixed algorithm/examples due to tex coordinate origin update
(Added example function.) |
m (→SetTexCoord Math with Matrices: Fixed algorithm/examples due to tex coordinate origin update) |
||
| Line 109: | Line 109: | ||
To calculate the final image coordinates, we apply T' to each of the corner Texture coordinates: | To calculate the final image coordinates, we apply T' to each of the corner Texture coordinates: | ||
UL Texture Coordinates (X,Y) = (0, | UL Texture Coordinates (X,Y) = (0,0) | ||
ULx = ( | ULx = ( BF - CE) / det | ||
ULy = ( | ULy = (-AF + CD) / det | ||
LL Texture Coordinates (X,Y) = (0, | LL Texture Coordinates (X,Y) = (0,1) | ||
LLx = ( BF - CE) / det | LLx = (-B + BF - CE) / det = (-(1-F)B - CE) / det | ||
LLy = (-AF + CD) / det | LLy = ( A - AF + CD) / det = ( (1-F)A + CD) / det | ||
UR Texture Coordinates (X,Y) = (1, | UR Texture Coordinates (X,Y) = (1,0) | ||
URx = ( E | URx = ( E + BF - CE) / det = ( BF + (1-C)E ) / det | ||
URy = (-D | URy = (-D - AF + CD) / det = ( AF - (1-C)D ) / det | ||
LR Texture Coordinates (X,Y) = (1, | LR Texture Coordinates (X,Y) = (1,1) | ||
LRx = ( E + BF - CE) / det = ( | LRx = ( E - B + BF - CE) / det = ( (1-C)E - (1-F)B ) / det | ||
LRy = (-D - AF + CD) / det = ( | LRy = (-D + A - AF + CD) / det = (-(1-C)D + (1-F)A ) / det | ||
===Example Function=== | ===Example Function=== | ||
| Line 131: | Line 131: | ||
local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy; | local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy; | ||
ULx, ULy = ( | ULx, ULy = ( B*F - C*E ) / det, ( -(A*F) + C*D ) / det; | ||
LLx, LLy = ( B*F - C*E ) / det, ( - | LLx, LLy = ( -B + B*F - C*E ) / det, ( A - A*F + C*D ) / det; | ||
URx, URy = ( E | URx, URy = ( E + B*F - C*E ) / det, ( -D - A*F + C*D ) / det; | ||
LRx, LRy = ( E + B*F - C*E ) / det, ( -D - A*F + C*D ) / det; | LRx, LRy = ( E - B + B*F - C*E ) / det, ( -D + A -(A*F) + C*D ) / det; | ||
t:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy); | t:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy); | ||