WoW:SetTexCoord Transformations: Difference between revisions

yet another example
(Included a texture rotation method that worked for me)
(yet another example)
Line 210: Line 210:


radians = (pi/180) * degrees
radians = (pi/180) * degrees
==Rotation of Textures about Any Point with Any Aspect==
This function caters to all your rotation needs.
function RotateCoordPair (x,y,ox,oy,a,asp)
y=y/asp
oy=oy/asp
return ox + (x-ox)*math.cos(a) - (y-oy)*math.sin(a),
(oy + (y-oy)*math.cos(a) + (x-ox)*math.sin(a))*asp
end
And use it like this:
coords={tl={x=0,y=0},
bl={x=0,y=1},
tr={x=1,y=0},
br={x=1,y=1}}
origin={x=0.5,y=1.0}
aspect=image_width/image_height
angle=3.14159/2
texture:SetTexCoord(
RotateCoordPair(coords.tl.x,coords.tl.y,origin.x,origin.y,angle,aspect),
RotateCoordPair(coords.bl.x,coords.bl.y,origin.x,origin.y,angle,aspect),
RotateCoordPair(coords.tr.x,coords.tr.y,origin.x,origin.y,angle,aspect),
RotateCoordPair(coords.br.x,coords.br.y,origin.x,origin.y,angle,aspect)
)
[[User:SinusPi|SinusPi]] ([[User talk:SinusPi|talk]]) 15:17, September 10, 2009 (UTC)
Anonymous user