Quantcast
The ring theory part two - Page 4 - WoWInterface
Thread Tools Display Modes
03-02-16, 08:14 PM   #61
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by SDPhantom View Post
I was actually more interested in data relating to the additional impact of having paused animations continuously rendering. An earlier version of my custom flight HUD used a bounce looping method on rotating textures and paused whenever the loop state changed. I scrapped the method since it not only had its own problems to deal with, but the entire addon as a whole was eating up a considerable chunk of processing power when the game really needed it. It wasn't the worst part of the old code, but I did consider it to be contributing factor.
The animation widget itself is fairly negligible compared to the rest of the script. The difference between being paused and playing (or even stopped) is so small that I can't measure its impact on framerate on my computer.

It's also neither optional nor something you can really optimize, so I wouldn't worry too much about it.
  Reply With Quote
03-03-16, 04:35 AM   #62
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
Originally Posted by Resike View Post
Would it be possible to create animated pie charts with this method with relatively small cost?
If you want pie charts you could use the scrollframe technique I posted before and which is used in rCompassCastbar. All you need are 2 scrollframes spanning 180 each.



Left side is one scrollframe. Right side is one scroll frame. Right side is filled counter-clockwise. Left side is filled clockwise. All you need is the texture drawlayer. Using strata "BACKGROUND" you can have up to 15 ring segments ranging from -8 to 7.

Your pie chart consists of half-circle textures.


By rotating them properly (texture:SetRotation() is enough in this case) you crop it.


Btw..one point on FPS gain. Has anyone tried hiding the frame before applying the rotation and showing it again right after applying the rotation?
I know this is not SetPoint() but maybe it has an effect like this: http://www.wowinterface.com/forums/s...ad.php?t=46740
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

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

Last edited by zork : 03-03-16 at 04:55 AM.
  Reply With Quote
03-03-16, 09:04 AM   #63
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by zork View Post
Btw..one point on FPS gain. Has anyone tried hiding the frame before applying the rotation and showing it again right after applying the rotation?
I know this is not SetPoint() but maybe it has an effect like this: http://www.wowinterface.com/forums/s...ad.php?t=46740
Yesterday I tried hiding the entire spinner at the start of the Transform function and showing it when it was finished and my framerate was actually substantially worse.

I'm not sure whether it was simply the overhead of a couple extra function calls or an interaction with something else, but it might bear investigating.

If you're using rotationally symmetrical textures, zork's example is a lot more efficient since it's not necessary to correct the animation's rotation with texture coordinates because it looks the same regardless of its orientation.
  Reply With Quote
03-03-16, 02:32 PM   #64
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,924
One thing I've noticed in my own animations is that they stop playing and refuse to start if an ancestor (parent of target or further down the chain) is hidden.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
03-03-16, 03:33 PM   #65
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
If you want pie charts you could use the scrollframe technique I posted before and which is used in rCompassCastbar. All you need are 2 scrollframes spanning 180 each.
Why do they need to be scrollframes? How do you keep track/calculate segments like 4 and 7?
  Reply With Quote
03-03-16, 05:17 PM   #66
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,924
He's rotating half-textures and the ScrollFrame clips one end while he's doing it. Wedges 4 and 7 need use of both ScrollFrames to make up their own pieces of the wedges together. Though it would be smart to align the edge of one of your wedges to the ScrollFrame so you'll only ever have to deal with splitting one wedge among them if any.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-03-16 at 05:25 PM.
  Reply With Quote
03-04-16, 03:42 AM   #67
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
SDPhantom is right. My example is too complicated. Just align your first pie chart with the start at the first scrollframe (0) and just move clockwise the whole way through. Thus you only have one possible overflow that you need to take care of.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
03-04-16, 03:25 PM   #68
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,111
Looking at the code throughout this thread is making my head hurt. Totally, completely, awesomely, cool, however!

So here is the stupid question of the day(tm). Is it possible to convert this idea into a library or some condensed, documented API or framework?
  Reply With Quote
03-04-16, 05:33 PM   #69
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,924
I don't see why not. It honestly isn't that complicated once you understand the concept. The ScrollFrame acts as a nested screen, cropping everything that's rendered out-of-bounds, and there's a texture with its center anchored to one side, rotating according to calculated values. It really isn't that much more complicated than traditional bar textures.

Semlar's expansion to the concept does use the animation system to allow you to use any static image as a texture and counteracts it with custom rotation matrices. While this does add flexibility to the method, I wouldn't suggest using it unless you absolutely need it.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-04-16 at 05:39 PM.
  Reply With Quote
03-05-16, 08:07 AM   #70
leblitzer
A Defias Bandit
Join Date: Jun 2011
Posts: 2
This feature is really great. Are there some ways to start the rotation by an angle which is not a multiplier of 90 degrees ?
So let's say you want to make a casting bar like the one on this pic: http://imagizer.imageshack.us/a/img907/4979/vOdhsr.jpg
Would it be possible to set the same start angle ?

Last edited by leblitzer : 03-05-16 at 10:45 AM.
  Reply With Quote
03-05-16, 09:29 AM   #71
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
Yes semlar posted this on page two at the bottom.
http://www.wowinterface.com/forums/s...0&postcount=40

It can be done but it is still kind of tricky since you need to hack the texture and the value update.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
03-05-16, 11:29 AM   #72
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by leblitzer View Post
This feature is really great. Are there some ways to start the rotation by an angle which is not a multiplier of 90 degrees ?
So let's say you want to make a casting bar like the one on this pick: http://imagizer.imageshack.us/a/img907/4979/vOdhsr.jpg
Would it be possible to set the same start angle ?
It has to start at a 90 degree angle because it needs a scroll frame to hide the excess part of our rotating slice texture, and the sides of the scroll frame are all at 90 degree angles.

However, if you're using a custom texture it doesn't matter because you can make that part of the image transparent. Even though the texture is "visible" from the 90 degree starting angle, if it's transparent you can't see it.

When you go to set the value of the spinner, you'll need to take into account both the new starting angle and the fact that the "total" value of the bar is no longer 100%.


For example, if we use this source texture, which has had a 90 degree (25% of 360) section removed from the top, and we want to start at 0 degrees and fill clockwise, we have to multiply our value by the size of the visible bar relative to a full circle (75% or 270 degrees) and add our starting angle, which is 45 degrees or half of 25%.

So you'd use spinner:SetValue( value * 0.75 + 0.25 / 2 ) to make sure it starts filling from 45 degrees, and completes after filling 270 degrees.

With your example, going counterclockwise and treating 0 degrees as straight up, you'd offset the starting angle by around 127 degrees and limit the fill arc to 106 degrees.



The "Shadowbolt" bar in that image is actually not possible with the demo script I posted because it passes through the 0 degree mark and to simplify the example I wrote it in a way that doesn't support that.

I'll probably rewrite it later and maybe just upload it as a library.

Last edited by semlar : 03-05-16 at 02:51 PM.
  Reply With Quote
03-05-16, 05:17 PM   #73
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 427
Very interesting read. Too bad cooldown frames can only be used for clockwise cropping.

__________________
  Reply With Quote
03-05-16, 09:13 PM   #74
leblitzer
A Defias Bandit
Join Date: Jun 2011
Posts: 2
Thanks a lot for your answer. I also found a workaround for the "shadowbolt" bar by splitting the texture in half and making two different spinners (but maybe it could also work if i change the quadrants order so it doesn't start in the middle of a bar).
  Reply With Quote
05-25-16, 06:08 PM   #75
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
Hey guys, I'm currently trying something new and wanna ask for a bit help with this:



Is this even possible with scroll frames / rotation due to the fact that I use SetTexCoord() to cycle through the animation sequence...
__________________
  Reply With Quote
05-25-16, 06:57 PM   #76
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
Originally Posted by syncrow View Post
Hey guys, I'm currently trying something new and wanna ask for a bit help with this:



Is this even possible with scroll frames / rotation due to the fact that I use SetTexCoord() to cycle through the animation sequence...
You'll have to apply your matrix transformation before calculating the rotated texture coordinates, that way you're rotating the transformed version of the image.

This requires knowing the matrix that was used to calculate your original texture coordinates, not the texture coordinates themselves.
  Reply With Quote
05-25-16, 07:37 PM   #77
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
Originally Posted by semlar View Post
You'll have to apply your matrix transformation before calculating the rotated texture coordinates, that way you're rotating the transformed version of the image.

This requires knowing the matrix that was used to calculate your original texture coordinates, not the texture coordinates themselves.
I simply pre-stored the texCoords for the animation in a table and used OnUpdate() function to cycle through them...

Lua Code:
  1. local texCoords = {
  2.     [ 1] = { 0.00, 0.25, 0.00, 0.0625 },
  3.     [ 2] = { 0.25, 0.50, 0.00, 0.0625 },
  4.     [ 3] = { 0.50, 0.75, 0.00, 0.0625 },
  5.     [ 4] = { 0.75, 1.00, 0.00, 0.0625 },
  6.     [ 5] = { 0.00, 0.25, 0.0625, 0.1250 },
  7.     ...
  8. }
  9.  
  10. function AnimationUpdateFrame_OnUpdate(self,elapsed)
  11.     update = update + elapsed
  12.    
  13.     while update >= interval do
  14.         if index >= 60 then
  15.             index = 1
  16.         else
  17.             index = index + 1
  18.         end
  19.  
  20.         for _, frame in pairs(framesToAnimate) do
  21.             if frame:IsShown() and frame:IsVisible() then
  22.                 frame.Fill:SetTexCoord(unpack(texCoords[index]))
  23.             end
  24.         end
  25.        
  26.         update = update - interval
  27.     end
  28. end


Failure Testing:

  • Green = centered statusBar (adjusted range from 14-86%)
  • White = 2 scrollframes (14% value each)
  • Red = counter clockwise rotated statusbars inside the scrollframes (-45)

Also tried to rotate the scrollframe itself and counter rotate the statusbar, but it seems that the scrollframe isn't rotatable.

Edit: btw, used xml for the complete scrollframe stuff (template usage)
__________________

Last edited by syncrow : 05-25-16 at 08:28 PM.
  Reply With Quote
05-27-16, 07:50 AM   #78
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
Originally Posted by semlar View Post
You'll have to apply your matrix transformation before calculating the rotated texture coordinates, that way you're rotating the transformed version of the image.
So I need to rotate and crop the texture within the transformation function that has this arguments?

Lua Code:
  1. function Transform(texture, angle, left, right, top, bottom)
  2.     ...
  3. end

How would this transformation function look like? (sry i'm bad at this math stuff)

Note:
I use a statusbar with a fake fill texture that is attached to the statusbar..
So if i rotate the statusbar inside the scrollframe, the fill would also rotate?
__________________

Last edited by syncrow : 05-27-16 at 07:55 AM.
  Reply With Quote
05-27-16, 08:28 AM   #79
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
Answered your PM. But to post it here aswell. Why don't you make a huge slice texture with cropped slices? You can do any shape with the alpha channel.



http://www.wowinterface.com/download...07-Disco2.html
https://github.com/zorker/rothui/blo...banimation.zip

Optimally you have the animation as a video. All you need is Video to Gif and you are set.

Or you do sth way simpler yet super cool. You pick one of the amazing DisplayIDs http://imgur.com/a/34ce7 (examples from the last 20k displayids, there are 50k more) and make your healthbar a rectangle scrollframe with a flat background and an animation on top. All you need to do now is chance the with of the scrollChild once the health updates.

That is what I am planning to do for my unitframes. It will look awesome because animations are super fluid.

Careful though. I tried adding 100 models to screen. Makes WoW go BOOOM BOOOM.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

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

Last edited by zork : 05-27-16 at 08:36 AM.
  Reply With Quote
05-27-16, 02:46 PM   #80
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,059
I agree with zork, it would make a lot more sense to generate your animation texture in the shape that you want than trying to fix it in-game.

It is possible to do what you want using rotations, but I don't think I can explain how to combine matrix transformations well enough to someone who doesn't already know something about matrices to make sense of it.

Essentially you would have to apply your translation, which is where you move the texture to a particular location (one of the 60 frames of your animation), then apply a rotation matrix centered around that point.

This page explains how to do the math involved (2 dimensional rotation), but really without some background on this subject already you're going to have a hard time applying it to what you're trying to do.

I would only do it this way if you really have to have your textures look like this and you can't generate them in the shape that you want.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » The ring theory part two

Thread Tools
Display Modes

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