Thread Tools Display Modes
02-06-15, 05:18 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
WoW Animation Experiments/Tests

Has any of you worked with the WoW animation API and can share some of the experiments/tests?

http://wow.curseforge.com/addons/blackbox/
http://www.wowace.com/addons/librecursiveanim-1-0/
https://code.google.com/p/rothui/sou...ameRotater.lua

I checked the wow addon code. Lua wise only the TutorialFrame has some animation groups. But thankfully the XML has a ton of <AnimationGroup> examples.

The following have a tag that starts with "<Rotation"



Why I'm asking this is the following. I want to create a frame with a set of textures. I want to rotate that frame by a specific degree based on an event.

The degree change should be tweened by using the animation.

My question is. When the animation is stopped. What will happen to the frame and the textures inside?
__________________
| 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 : 02-06-15 at 05:28 AM.
  Reply With Quote
02-06-15, 06:56 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Stop() will end the animation and the frame/textures will be set to their initial state.
Pause() will pause the animation in its current state.

That's what I am using in BAB Bars to 'permanently rotate' the button frames. A rotation animation that is paused 0.00001 secs after it starts.

Last edited by Duugu : 02-06-15 at 07:02 AM.
  Reply With Quote
02-06-15, 07:07 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Is it possible to rotate the frame itself properly with all of it's children? I would be very intrested about how to do that.
  Reply With Quote
02-06-15, 08:47 AM   #4
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Resike View Post
Is it possible to rotate the frame itself properly with all of it's children? I would be very intrested about how to do that.
Theoretically

As the rotation animation is kind of broken it will fail in scenarios like fontstring childs, backdrops, and others.

Just apply the animation to the parent Frame.
  Reply With Quote
02-06-15, 09:02 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Hmmm. So with Pause() you can freeze the frame. Is there a way where you can set a rotation duration and pause it right before it ends?

I guess when the duration is over it will just Stop() itself.

There is OnFinished though. But I think that is to late.

Basically I want a smooth animation from A --> B and pause it right before it reaches B.

__________________
| 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 : 02-06-15 at 09:13 AM.
  Reply With Quote
02-06-15, 09:36 AM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by zork View Post
Hmmm. So with Pause() you can freeze the frame. Is there a way where you can set a rotation duration and pause it right before it ends?

I guess when the duration is over it will just Stop() itself.

There is OnFinished though. But I think that is to late.

Basically I want a smooth animation from A --> B and pause it right before it reaches B.

There is a rotation widget which might be what you want, however i've never played it with yet:

http://wowprogramming.com/docs/widge...ion/SetDegrees
  Reply With Quote
02-06-15, 09:45 AM   #7
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Yes that is the widget I'm going to use.

Since I only use one type of animation (rotation) I could play/pause/stop the animation itself. Not the full animationgroup.

AnimationGroup Widget API
http://wowprogramming.com/docs/widgets/AnimationGroup

I could track the animation/animationgroup progress via the OnUpdate handler.

But I may have a better idea. I could set the animation to "REPEAT" and use OnLoop.

http://wowprogramming.com/docs/scripts/OnLoop

Inside the OnLoop I could Pause() the animation after one cycle.

Later I can apply new degrees and Play() the animation again. The question is will the animation be persistant.
__________________
| 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 : 02-06-15 at 09:49 AM.
  Reply With Quote
02-06-15, 09:55 AM   #8
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by zork View Post
Hmmm. So with Pause() you can freeze the frame. Is there a way where you can set a rotation duration and pause it right before it ends?

I guess when the duration is over it will just Stop() itself.

There is OnFinished though. But I think that is to late.

Basically I want a smooth animation from A --> B and pause it right before it reaches B.

Yes, there is a way:

Lua Code:
  1. t.ag = t:CreateAnimationGroup()
  2. t.a1 = t.ag:CreateAnimation("Rotation")
  3. t.a1:SetDuration(1)
  4. t.a1:SetEndDelay(10)
  5. t.a1:SetScript("OnUpdate", function(self, elapsed) if self:IsPlaying() then if self:IsDelaying() then self:Pause() end end end)    
  6. t.a1:SetDegrees(90)
  7. t.ag:Play()
The point is that there are two timeframes for each animation. First the animation plays for SetDuration seconds from its initial state to its final state. Then the animated object remains in its final state for SetEndDelay seconds.

The trick is to pause the animation during the end delay period. The it remains in its 'end' animation state until the animation is really stopped via Stop().

[e]
OnFinish is to late, yes. If the event Triggers the object is already resetted to its initial state.
  Reply With Quote
02-06-15, 10:47 AM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Duugu View Post
Theoretically

As the rotation animation is kind of broken it will fail in scenarios like fontstring childs, backdrops, and others.

Just apply the animation to the parent Frame.
What i would like to do is to rotate a simple frame, and use the rotated frames boundaries for the OnEnter and OnLeave scripts:

Lua Code:
  1. local t = CreateFrame("Frame", nil, UIParent)
  2. t:SetPoint("Center", UIParent, "Center", 0, 0)
  3. t:SetSize(100, 100)
  4. t.texture = t:CreateTexture(nil, "Overlay")
  5. t.texture:SetTexture("Interface\\Buttons\\White8x8.blp")
  6. t.texture:SetAllPoints(t)
  7.  
  8. t.ag = t:CreateAnimationGroup()
  9. t.a1 = t.ag:CreateAnimation("Rotation")
  10. t.a1:SetDuration(1)
  11. t.a1:SetEndDelay(10)
  12. t.a1:SetScript("OnUpdate", function(self, elapsed)
  13.     if self:IsPlaying() then
  14.         if self:IsDelaying() then
  15.             self:Pause()
  16.         end
  17.     end
  18. end)    
  19. t.a1:SetDegrees(45)
  20. t.ag:Play()
  21.  
  22. t:SetScript("OnEnter", function(self)
  23.     print("OnEnter")
  24. end)
  25.  
  26. t:SetScript("OnLeave", function(self)
  27.     print("OnLeave")
  28. end)

But it doesn't seems to work.
  Reply With Quote
02-06-15, 12:19 PM   #10
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Resike View Post
What i would like to do is to rotate a simple frame, and use the rotated frames boundaries for the OnEnter and OnLeave scripts:

But it doesn't seems to work.
As far as I know that's impossible.

The rotate animation ignores clickable areas. To be honest ... I do believe the animation ignores the parent frame itself at all and the rotation is applied to ALL of its elements (like backdrops) and childs (like textures) only.

Whatever the reason is - I couldn't find a way to rotate a clickable area.
As I wrote ... the feature is more or less broken.

[e]
I was working on a workaround for this a while ago but never finished it.
The idea was to make the frame non-clickable and to (internaly) fill the rotated frame with the required number of non-rotated invisible clickable frames each having a clickable area and to map the events to the main frame.

See this post: http://www.wowinterface.com/forums/s...light=triangle

Last edited by Duugu : 02-06-15 at 01:18 PM.
  Reply With Quote
02-06-15, 05:50 PM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Duugu View Post
As far as I know that's impossible.

The rotate animation ignores clickable areas. To be honest ... I do believe the animation ignores the parent frame itself at all and the rotation is applied to ALL of its elements (like backdrops) and childs (like textures) only.

Whatever the reason is - I couldn't find a way to rotate a clickable area.
As I wrote ... the feature is more or less broken.

[e]
I was working on a workaround for this a while ago but never finished it.
The idea was to make the frame non-clickable and to (internaly) fill the rotated frame with the required number of non-rotated invisible clickable frames each having a clickable area and to map the events to the main frame.

See this post: http://www.wowinterface.com/forums/s...light=triangle
It's possible to create a polynom and find if a point inside the polynom or not via an update script, but it's not worth the hassle to use it, and goes strong on the resources with fps like update speed:

Lua Code:
  1. local x, y = -0.5, 0.5
  2.  
  3. local p = {
  4.     [1] = {x = 0, y = 0},
  5.     [2] = {x = -1, y = 0},
  6.     [3] = {x = -1, y = 1},
  7.     [4] = {x = 0, y = 1}
  8. }
  9.  
  10. function PointInPolynom(p, x, y)
  11.     local c = false
  12.     for i = 1, #p do
  13.         local j = i + 1
  14.         if j > #p then
  15.             j = 1
  16.         end
  17.         if ((p[i].y > y) ~= (p[j].y > y)) and (x < (p[j].x - p[i].x) * (y - p[i].y) / (p[j].y - p[i].y) + p[i].x) then
  18.             c = not c
  19.         end
  20.     end
  21.     return c
  22. end
  Reply With Quote
02-06-15, 06:54 PM   #12
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by Resike View Post
It's possible to create a polynom and find if a point inside the polynom or not via an update script, but it's not worth the hassle to use it, and goes strong on the resources with fps like update speed:
Thats true. Thanks for the code. In my case it was about clickable secure frames/buttons so I couldn't use such an approach. :/
  Reply With Quote
02-07-15, 02:12 AM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Duugu View Post
Thats true. Thanks for the code. In my case it was about clickable secure frames/buttons so I couldn't use such an approach. :/
I also wrote a polynom in polynom code, if someone might need something similar in the future:
It can be used for collision detection too.

Lua Code:
  1. function PolynomInPolynom(p1, p2)
  2.     local c = { }
  3.     for i = 1, #p2 do
  4.         c[i] = false
  5.         for j = 1, #p1 do
  6.             local k = j + 1
  7.             if k > #p1 then
  8.                 k = 1
  9.             end
  10.             if ((p1[j].y > p2[i].y) ~= (p1[k].y > p2[i].y)) and (p2[i].x < (p1[k].x - p1[j].x) * (p2[i].y - p1[j].y) / (p1[k].y - p1[j].y) + p1[j].x) then
  11.                 c[i] = not c[i]
  12.             end
  13.         end
  14.         if c[i] then
  15.             return true
  16.         end
  17.     end
  18.     return false
  19. end

Last edited by Resike : 02-07-15 at 02:18 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » WoW Animation Experiments/Tests


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