WoW:SetTexCoord Transformations: Difference between revisions

m
Line 37: Line 37:
Logically the process by which a point is transformed from image space to a point on screen can be represented by two transformations T, the transformation from the image to the Texture, and then S, the transformation from the Texture to the screen (I'll go into the math later):
Logically the process by which a point is transformed from image space to a point on screen can be represented by two transformations T, the transformation from the image to the Texture, and then S, the transformation from the Texture to the screen (I'll go into the math later):


Texture coordinate from image coordinate: t = i * T
Texture coordinate from image coordinate: t = T * i
Screen coordinate from Texture coordinate: s = t * S
Screen coordinate from Texture coordinate: s = S * t


The S transformation is implied by the anchors, size, and scale of the Texture frame element (and the Frame it's contained within).
The S transformation is implied by the anchors, size, and scale of the Texture frame element (and the Frame it's contained within).


==T, and its inverse==
==T, and its inverse==
Most of the time you are most readily able to provide T, the transformation between the image and the Texture, because you want to achieve a specific thing (Say, rotate the image 30 degrees and move it to the left).  However SetTexCoord wants image coordinates as its parameters, for the four corner Texture coordinates. In order to do this, we need to create T', the inverse of T, such that given t = i * T, the inverse can be applied to get i = t * T'.
Most of the time you are most readily able to provide T, the transformation between the image and the Texture, because you want to achieve a specific thing (Say, rotate the image 30 degrees and move it to the left).  However SetTexCoord wants image coordinates as its parameters, for the four corner Texture coordinates. In order to do this, we need to create T', the inverse of T, such that given t = T * i, the inverse can be applied to get i = T' * t.


With the inverse in hand, we can determine what the image coordinates are going to be by passing in the four corner Texture coordinate values (0,1) (0,0) (1,1) (1,0) in turn and passing the resulting set of coordinates into SetTexCoord as the UL, LL, UR, and LR image coordinates.
With the inverse in hand, we can determine what the image coordinates are going to be by passing in the four corner Texture coordinate values (0,1) (0,0) (1,1) (1,0) in turn and passing the resulting set of coordinates into SetTexCoord as the UL, LL, UR, and LR image coordinates.
Line 55: Line 55:


{|
{|
|(X||Y||Z)||=||(x||y||z)||*||(A||D||G)
|(X)|| ||(A||B||C)|| ||(x)
|-
|-
| || || || ||  || || || ||(B||E||H)
|(Y)||=||(D||E||F)||*||(y)
|-
|-
| || || || || || ||  || ||(C||F||I)
|(Z)|| ||(G||H||I)|| ||(z)
|}
|}


Line 71: Line 71:


{|
{|
|(X||Y||1)||=||(x||y||1)||*||(A||D||0)
|(X)|| ||(A||B||C)|| ||(x)
|-
|-
| || || || ||  || || || ||(B||E||0)
|(Y)||=||(D||E||F)||*||(y)
|-
|-
| || || || ||  || || || ||(C||F||1)
|(1)|| ||(0||0||1)||*||(1)
|}
|}


Line 99: Line 99:


{|
{|
|(||E/det||-B/det||0||)
|(||E/det||-D/det||(BF-CE)/det||)
|-
|-
|(||-D/det||A/det||0||)
|(||-B/det||A/det||-(AF-CD)/det||)
|-
|-
|(||(BF-CE)/det||-(AF-CD)/det||1||)
|(||0||0||1||)
|}
|}


Anonymous user