Thread Tools Display Modes
11-10-10, 11:50 PM   #21
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Maybe... i'll try it a little later, just to see what is more efficient.

I got the rotation working based on a degree scale now, so i'ts fluent and working!

Of course now I am just second guessing my whole "desire" to use custom textures... Yah they look nice but godddd they eat up memory...
  Reply With Quote
11-11-10, 02:38 AM   #22
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I think he meant:
http://elitistjerks.com/blogs/zork/362-ring.html
__________________
| 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
11-11-10, 02:45 AM   #23
Olog
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 8
I haven't actually ever tried SetRotation but from your screenshots it would appear that it automatically resizes the texture so that the whole thing fits inside your texture widget. So in the most extreme case of 45 degrees rotation like in your picture the size is reduced by a factor of sqrt(2). This however depends on the rotation (or so I'm guessing) so just simply making the texture widget bigger probably won't get you what you want. You could compensate by changing the size to fit the rotation. I think it'd be something like this (add math. where needed).

Code:
local size=addon:GetWidth()*sqrt(2)*max(abs(sin(theta+pi/4)),abs(cos(theta+pi/4)))
tex:SetSize(size,size)
Your furthest point (one of the corners) in texture is sqrt(2) away from middle, when theta is 0 this point is actually already rotated 45 degrees = pi/4. Then sin and cos will get it's y and x coordinates respectively. Abs because they go negative too and finally the max will take the bigger of the two.

Code:
local theta = math.rad(90)
local cos, sin = math.cos(angle), math.sin(angle)
tex:SetTexCoord((sin - cos), -(cos + sin), -cos, -sin, sin, -cos, 0, 0)
Why this didn't work is because it rotates the texture around one of the corners. So it probably did rotate it 90 degrees, in other words completely outside your texture widget. Try smaller angles to see how it behaves.

If you want to do it with SetTexCorod instead of Setrotation, the code under "Simple rotation of square textures around the center" on the wowpedia page should get you what you want. Though you will probably have a kind of opposite problem to what you have with SetRotation. Your texture will end up partly outside the texture widget. You can deal with this by just leaving some empty space in your texture.
  Reply With Quote
11-11-10, 02:56 AM   #24
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Regarding SetRotation this is what I do in rRingMod3 for the spark
Code:
  local function calc_health_spark(self,value)
    local spark = self.health_spark.texture  
    value = 1-value --values is between 0 and 1
    local radian = math.rad(value * 360)
    spark:SetPoint("CENTER", spark.radius * math.cos(radian), spark.radius * math.sin(radian))
    spark:SetRotation(radian)  
  end
The spark will be placed ontop of the ring in a radian based on hp/pp values.

Most of that code is from Boloking: http://www.wowinterface.com/download...4-GCDRing.html

If you dont have to adjust the setpoint there is still the radian that you need based on the value.

Example above uses 360°. Now that would be values from 0 to 1. Quarterrings would be at 0.25, 0.5, 0.75 and one. So a value of 0.25 would be 90°.

But thx to animationgroups I think the easiest way to do this now is by using the animationgroups. They do all the math.

Tick-Tack Example
lua Code:
  1. [code]
  2.   local rotateme = function(texture,width,height,scale,anchorframe,framelevel,texr,texg,texb,alpha,duration,side,blendmode,point,pointx,pointy)
  3.  
  4.     local h = CreateFrame("Frame",nil,anchorframe)
  5.     h:SetHeight(height)
  6.     h:SetWidth(width)            
  7.     h:SetPoint(point,pointx,pointy)
  8.     h:SetScale(scale)
  9.     h:SetFrameLevel(framelevel)
  10.  
  11.     local t = h:CreateTexture()
  12.     t:SetAllPoints(h)
  13.     t:SetTexture("Interface\\AddOns\\yourTextures\\"..texture)
  14.     t:SetBlendMode(blendmode)
  15.     t:SetVertexColor(texr,texg,texb,alpha)
  16.     h.t = t
  17.    
  18.     local ag = h:CreateAnimationGroup()
  19.     h.ag = ag
  20.    
  21.     local a1 = h.ag:CreateAnimation("Rotation")
  22.     a1:SetDegrees(6)
  23.     a1:SetDuration(1)
  24.     h.ag.a1 = a1
  25.    
  26.     h.ag:SetLooping("REPEAT")  --repeat this OVER AND OVER?!
  27.  
  28.     return h
  29.  
  30.   end
  31.  
  32.   local f = rotateme(...)
  33.   f.ag:Play()
  34.  
  35.   --adjust values
  36.   --f.ag.a1:SetDegrees(20)
  37.   --f.a1:SetDuration(10)
  38.   --f.ag:SetLooping("REPEAT")
  39. [/code]

This will do a Rotation for 6° and need "duration" to do that. Well you could just bring that duration down to 0 to make it be there instantly. Since it's an object you can adjust the value of SetDegrees anytime, even later and after that just Play() the animation.

The example above with a duration of 1 would be a clock. It moves 6° every second forever.

To make that acutally look like a clock you need a line-texture. Now you play it every second. The animation does a 6° move but only takes 0.3ms to do that. This will leave 0.7ms until the next move.
__________________
| 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 : 11-11-10 at 03:21 AM.
  Reply With Quote
11-11-10, 11:25 AM   #25
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
I'm liking the look of the animation groups... seems like it might add more flexibility and ease of use

Thanks for all the help guys. Maybe after I finish my project I'll do some Wiki page updating for other people.

Edit: First addons are fun. :P

Last edited by lilgulps : 11-11-10 at 11:31 AM.
  Reply With Quote
11-11-10, 04:58 PM   #26
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
my first stab at addons was actually on my brothers computer, where I made it everytime he entered combat, he would /yell how great I was.

My first public addon was Battlemaster
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-16-10, 01:02 AM   #27
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Here is what I finally got working! No animation useage yet, i'll try and do that over thanksgiving.
  Reply With Quote
11-16-10, 07:21 AM   #28
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
On a side note. You can put animationgroups on textures. I do that for my orb animation.

lua Code:
  1. [code]
  2.   --create galaxy func
  3.   local createGalaxy = function(f,x,y,size,duration,texture,sublevel)
  4.  
  5.     local t = f:CreateTexture(nil, "BACKGROUND", nil, sublevel)
  6.     t:SetSize(size,size)
  7.     t:SetPoint("CENTER",x,y)
  8.     t:SetTexture("Interface\\AddOns\\rTextures\\"..texture)
  9.     if f.type == "power" then
  10.       t:SetVertexColor(cfg.galaxytab[cfg.manacolor].r, cfg.galaxytab[cfg.manacolor].g, cfg.galaxytab[cfg.manacolor].b)
  11.     else
  12.       t:SetVertexColor(cfg.galaxytab[cfg.healthcolor].r, cfg.galaxytab[cfg.healthcolor].g, cfg.galaxytab[cfg.healthcolor].b)
  13.     end
  14.     t:SetBlendMode("ADD")
  15.    
  16.     local ag = t:CreateAnimationGroup()    
  17.     local anim = ag:CreateAnimation("Rotation")
  18.     anim:SetDegrees(360)
  19.     anim:SetDuration(duration)    
  20.     ag:Play()
  21.     ag:SetLooping("REPEAT")
  22.    
  23.     return t
  24.  
  25.   end
  26. [/code]
__________________
| 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
11-16-10, 09:00 AM   #29
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Wow that is incredibly helpful lol. I thought I was going to have to make new frames for each texture I wanted to animate

THIS IS MUCH EASIER!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to rotate a frame?

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