Thread Tools Display Modes
10-08-11, 09:36 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
PTR BUG AnimationGroups

I just tested it on the PTR and confirm that there is a bug with animationgroup rotations.

Preface:
I use the animation system to rotate textures and/or frames that have textures attached.
The rotation settings I'm using are: SetDegrees(360), SetLooping("REPEAT")
That makes the textures rotate infinitely.

Bug description:
When using rectangles the bug becomes clearly visible. The animation will fade every 90° or 180° and repop after another (but hidden) rotation of 90° or 180° depending on setting of SetDegrees.
What I found out so far is that SetDegrees is causing the bug.
If I'm using any value <= 90° it will work. But as soon as I go above 90° there will be a time where the animation will be faded. Duration and direction has no effect.
Using 360 degreens will make the animation fade for 180° while 180° will be visible.
Using any value between 90 and 360 will make the animation be visible for 90°.

This bug makes rotating frames infinitely impossible. At least for textures that do not repeat themself every 90°.
It will work for rings, and stuff but not for rectangles and such. (Galaxies in my case)

Testmod to show the bug: http://www.wowinterface.com/download...meRotater.html
SVN: http://code.google.com/p/rothui/sour.../rFrameRotater

Screenshots:
http://www.abload.de/img/wowscrnshot_100811_175cojz.jpg
http://www.abload.de/img/wowscrnshot_100811_175zpj8.jpg
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-08-11 at 10:05 AM.
  Reply With Quote
10-08-11, 11:05 PM   #2
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Rotation:SetRadians also causes this. It looks like rotating textures upside down is what makes them disappear. Even if you run multiple smaller rotations at once and they flip the texture over at some point, it will disappear then too.

Have you posted this to the PTR Bug Report forum yet?
  Reply With Quote
10-09-11, 06:07 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I think I tracked it down to a bug in the math functions. Textures disappear when using this:

lua Code:
  1. function RotateTexture(self, degrees)
  2.     local angle = math.rad(degrees)
  3.     local cos, sin = math.cos(angle), math.sin(angle)
  4.     self:SetTexCoord((sin - cos), -(cos + sin), -cos, -sin, sin, -cos, 0, 0)
  5. end

Maybe some of the math functions are bugged.

Using 90° steps still works, so here is my workaround using an onFinshed script that rotates the texture 90° by hand and restart the animation. Works perfectly for me. But my rotateTexture function is using predefined values. Nothing that gets calculated.



Full solution
lua Code:
  1. -- cfg
  2.  
  3.   local db = {
  4.     [1] = {
  5.       frame = {
  6.         parent = UIParent,
  7.         width = 100,
  8.         height = 100,
  9.         scale = 1,
  10.         alpha = 0.5,
  11.         level = 0,
  12.         pos = { a1 = "CENTER", x = -120, y = -120, },
  13.       },
  14.       texture = {
  15.         file = "Interface\\AddOns\\rFramerotater\\media\\rectangle",
  16.         color = { r = 255/255, g = 255/255, b = 0/255, },
  17.         blendmode = "BLEND", --ADD or BLEND
  18.       },
  19.       anim = {
  20.         rotateframe = true, --rotateframe, if false rotates the texture only
  21.         duration = 10, --how long should the rotation need to finish 360°
  22.         direction = 0, --0 = counter-clockwise, 1 = clockwise
  23.       },
  24.     },
  25.   }
  26.  
  27.   -- functions
  28.  
  29.   local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = 0,0,0,1,1,0,1,1
  30.  
  31.   local rotateTexture = function(self, degrees)
  32.     if degrees == 0 then
  33.       self:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy) --0°
  34.     elseif degrees == 90 then
  35.       self:SetTexCoord(LLx, LLy, LRx, LRy, ULx, ULy, URx, URy) --90°
  36.     elseif degrees == 180 then
  37.       self:SetTexCoord(LRx, LRy, URx, URy, LLx, LLy, ULx, ULy) --180°
  38.     elseif degrees == 270 then
  39.       self:SetTexCoord(URx, URy, ULx, ULy, LRx, LRy, LLx, LLy) --270°
  40.     end
  41.   end
  42.  
  43.   function init(id)
  44.  
  45.     --config
  46.     local cfg = db[id]
  47.  
  48.     --frame
  49.     local h = CreateFrame("Frame",nil,cfg.frame.parent)
  50.     h:SetHeight(cfg.frame.height)
  51.     h:SetWidth(cfg.frame.width)
  52.     h:SetPoint(cfg.frame.pos.a1,cfg.frame.pos.x,cfg.frame.pos.y)
  53.     h:SetScale(cfg.frame.scale)
  54.     h:SetAlpha(cfg.frame.alpha)
  55.     h:SetFrameLevel(cfg.frame.level)
  56.     --h.time = GetTime()
  57.  
  58.     --texture
  59.     local t = h:CreateTexture(nil,"BACKGROUND")
  60.     t:SetAllPoints(h)
  61.     t:SetTexture(cfg.texture.file)
  62.     t:SetBlendMode(cfg.texture.blendmode)
  63.     t:SetVertexColor(cfg.texture.color.r,cfg.texture.color.g,cfg.texture.color.b)
  64.     h.t = t
  65.  
  66.     --animation object
  67.     local o = t
  68.     if cfg.anim.rotateframe then
  69.       o = h --frame is object to animate
  70.     end
  71.  
  72.     --animationgroup
  73.     local ag = o:CreateAnimationGroup()
  74.     ag.t = t --keep reference to texture
  75.     ag.direction = cfg.anim.direction
  76.     ag.count = 0
  77.  
  78.     --animation
  79.     local a1 = ag:CreateAnimation("Rotation")
  80.     if cfg.anim.direction == 0 then
  81.       a1:SetDegrees(90)
  82.     else
  83.       a1:SetDegrees(-90)
  84.     end
  85.     a1:SetDuration(cfg.anim.duration/(360/90))
  86.     ag.a1 = a1
  87.  
  88.     --onfinished
  89.     ag:SetScript("OnFinished", function(ag)
  90.       if ag.direction == 0 then
  91.         ag.count = ag.count-1
  92.         if ag.count < 0 then ag.count = 3 end
  93.       else
  94.         ag.count = ag.count+1
  95.         if ag.count > 3 then ag.count = 0 end
  96.       end
  97.       rotateTexture(ag.t,90*ag.count)
  98.       ag:Play()
  99.     end)
  100.  
  101.     --play
  102.     ag:Play()
  103.  
  104.   end
  105.  
  106.   local a = CreateFrame("Frame")
  107.   a:RegisterEvent("PLAYER_LOGIN")
  108.   a:SetScript("OnEvent", function (self,event,...)
  109.     for i,v in ipairs(db) do
  110.       init(i)
  111.     end
  112.   end)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-09-11 at 06:19 AM.
  Reply With Quote
10-10-11, 02:21 AM   #4
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Originally Posted by zork View Post
lua Code:
  1. function RotateTexture(self, degrees)
  2.     local angle = math.rad(degrees)
  3.     local cos, sin = math.cos(angle), math.sin(angle)
  4.     self:SetTexCoord((sin - cos), -(cos + sin), -cos, -sin, sin, -cos, 0, 0)
  5. end

Maybe some of the math functions are bugged.
This function worked fine for me. It rotates the image around the bottom-right corner of the texture region instead of its center though. Here's a version that rotates properly around the center of the texture:
lua Code:
  1. --- Applies an affine transformation to this texture.
  2. local function ApplyTransform( self, A, B, C, D, E, F )
  3.   local Det = A * E - B * D;
  4.   if ( Det == 0 ) then
  5.     return self:Hide(); -- Scaled infinitely small
  6.   end
  7.   local AF, BF, CD, CE = A * F, B * F, C * D, C * E;
  8.  
  9.   local ULx, ULy = ( BF - CE ) / Det, ( CD - AF ) / Det;
  10.   local LLx, LLy = ( BF - CE - B ) / Det, ( CD - AF + A ) / Det;
  11.   local URx, URy = ( BF - CE + E ) / Det, ( CD - AF - D ) / Det;
  12.   local LRx, LRy = ( BF - CE + E - B ) / Det, ( CD - AF - D + A ) / Det;
  13.  
  14.   -- Bounds to prevent "TexCoord out of range" errors
  15.   if ( ULx < -1e4 ) then ULx = -1e4; elseif ( ULx > 1e4 ) then ULx = 1e4; end
  16.   if ( ULy < -1e4 ) then ULy = -1e4; elseif ( ULy > 1e4 ) then ULy = 1e4; end
  17.   if ( LLx < -1e4 ) then LLx = -1e4; elseif ( LLx > 1e4 ) then LLx = 1e4; end
  18.   if ( LLy < -1e4 ) then LLy = -1e4; elseif ( LLy > 1e4 ) then LLy = 1e4; end
  19.   if ( URx < -1e4 ) then URx = -1e4; elseif ( URx > 1e4 ) then URx = 1e4; end
  20.   if ( URy < -1e4 ) then URy = -1e4; elseif ( URy > 1e4 ) then URy = 1e4; end
  21.   if ( LRx < -1e4 ) then LRx = -1e4; elseif ( LRx > 1e4 ) then LRx = 1e4; end
  22.   if ( LRy < -1e4 ) then LRy = -1e4; elseif ( LRy > 1e4 ) then LRy = 1e4; end
  23.  
  24.   self:Show();
  25.   return self:SetTexCoord( ULx, ULy, LLx, LLy, URx, URy, LRx, LRy );
  26. end
  27. --- Rotates this texture around its center by Angle.
  28. local function RotateTexture( self, Angle )
  29.   local Cos, Sin = math.cos( Angle ), math.sin( Angle );
  30.   ApplyTransform( self,
  31.     Cos, Sin, ( Cos + Sin ) * -0.5 + 0.5,
  32.     -Sin, Cos, ( Cos - Sin ) * -0.5 + 0.5
  33.   );
  34. end
  35. --- Slowly rotates this frame's texture.
  36. local function OnUpdate ( self, Elapsed )
  37.   self.Elapsed = self.Elapsed + Elapsed;
  38.   return RotateTexture( self.Texture, math.pi * self.Elapsed );
  39. end
  40.  
  41.  
  42. local Frame = CreateFrame( "Frame" );
  43. Frame.Texture = Frame:CreateTexture();
  44. Frame.Elapsed = 0;
  45.  
  46. Frame:SetSize( 128, 128 );
  47. Frame:SetPoint( "CENTER" );
  48. Frame.Texture:SetAllPoints();
  49. Frame.Texture:SetTexture( [[Interface\MacroFrame\MacroFrame-Icon]] );
  50. Frame:SetScript( "OnUpdate", OnUpdate );

Only the animation system's rotations are bugged; Lua's math library and SetTexCoord seem fine.
  Reply With Quote
10-10-11, 12:22 PM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Maybe they messed some of the SetTexCoord calculations. That can get pretty disturbing quickly.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-13-11, 11:30 AM   #6
Iza
A Cyclonian
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 43
Hi,
I'm having the same issue with my custom statusbars. It seems like if you set texture left and right or top and bottom coordinates to the same values (or even very close values) the opacity value of that texture seems to get binary (???), so values of 0 - 0.99 make the texture completely transparent and setting it to 1 completely opaque. That will persist even if you set texture coordinates to different values after. My statusbars always get values in range of 0-100, so code was like this:

Code:
	tBar["SetValue"] = function(self, aValue)
		if ((aValue or -1) < 0) then
			aValue = 0;
		elseif (aValue > 100) then
			aValue = 100;
		end

		self["value"] = aValue;
		aValue = aValue * 0.01;
		if (self["isInverted"]) then
			aValue = 1 - aValue;
		end

		if (1 == self["txOrient"]) then -- VUHDO_STATUSBAR_LEFT_TO_RIGHT
			self["texture"]:SetTexCoord(0, aValue, 0, 1);
			self["texture"]:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", (aValue - 1) * self:GetWidth(), 0);

		elseif (2 == self["txOrient"]) then -- VUHDO_STATUSBAR_RIGHT_TO_LEFT
			self["texture"]:SetTexCoord(1 - aValue, 1, 0, 1);
			self["texture"]:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", (1 - aValue) * self:GetWidth(), 0);

		elseif (3 == self["txOrient"]) then -- VUHDO_STATUSBAR_BOTTOM_TO_TOP
			self["texture"]:SetTexCoord(0, 1, 1 - aValue, 1);
			self["texture"]:SetPoint("TOPLEFT", self, "TOPLEFT", 0, (aValue - 1) * self:GetHeight());

		else --if (VUHDO_STATUSBAR_TOP_TO_BOTTOM == self["txOrient"]) then
			self["texture"]:SetTexCoord(0, 1, 0, aValue);
			self["texture"]:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 0, (1 - aValue) * self:GetHeight());
		end
	end
All I did was limiting the values so texture coordinate deltas wouldn't shrink below 0.00001 (tried out a bit):

Code:
	tBar["SetValue"] = function(self, aValue)
		if ((aValue or -1) < 0.001) then
			aValue = 0.001;
		elseif (aValue > 100) then
			aValue = 100;
		end

		self["value"] = aValue;
		aValue = aValue * 0.01;
		if (self["isInverted"]) then
			aValue = 1.00001 - aValue;
		end
...
and this did the trick for me...

Cheers,
Iza

Last edited by Iza : 10-13-11 at 11:37 AM.
  Reply With Quote
10-27-11, 02:16 AM   #7
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Bug has been fixed. Closed.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » PTR BUG AnimationGroups


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off