Thread Tools Display Modes
03-13-13, 11:56 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Lol...SetRotation has a bug. It does sth to my ring texture.



To get it to work properly I had to use the SQRT trick posted by Saiket here:
http://www.wowinterface.com/forums/s...ad.php?t=36679

My code is:
Lua Code:
  1. -- // DiscoKugel2
  2.   -- // zork - 2013
  3.  
  4.   --get the addon namespace
  5.   local addon, ns = ...
  6.  
  7.   local unpack = unpack
  8.   local _G = _G
  9.   local CF = CreateFrame
  10.   local UIP = UIParent
  11.   local abs = math.abs
  12.   local sin = math.sin
  13.   local pi = math.pi
  14.  
  15.   -----------------------------
  16.   -- FUNCTIONS
  17.   -----------------------------
  18.  
  19.   local f = CF("Frame",nil,UIP)
  20.   f:SetSize(512,512)
  21.   f:SetScale(0.5)
  22.   f.w, f.h = f:GetSize()
  23.   f:SetPoint("CENTER")
  24.  
  25.   local t = f:CreateTexture(nil, "BACKGROUND", nil, -8)
  26.   t:SetTexture("Interface\\AddOns\\rTestRing2\\media\\ring")
  27.   t:SetAllPoints()
  28.   t:SetAlpha(0.2)
  29.  
  30.   local sf1 = CF("ScrollFrame",nil,f)
  31.   sf1:SetSize(f.w/2,f.h)
  32.   sf1:SetPoint("LEFT")
  33.  
  34.   local sc1 = CF("Frame")
  35.   sf1:SetScrollChild(sc1)
  36.   sc1:SetSize(f.w,f.h)
  37.  
  38.   local rt1 = sc1:CreateTexture(nil,"BACKGROUND",nil,-6)
  39.   rt1:SetTexture("Interface\\AddOns\\rTestRing2\\media\\ring_half")
  40.   rt1:SetSize(sqrt(2)*f.w,sqrt(2)*f.h)
  41.   rt1:SetPoint("CENTER")
  42.   rt1:SetVertexColor(1,0,0)
  43.   rt1:SetRotation(math.rad(40)) -- etc
  44.  
  45.   --local ag = rt1:CreateAnimationGroup()
  46.   --local anim = ag:CreateAnimation("Rotation")
  47.   --anim:SetDegrees(90)
  48.   --anim:SetDuration(10)
  49.   --ag:Play()

Maybe it has sth to do with the mysterious 1px I read about. Going to try to snip out 1px of my ring.
Afaik I read sth about it in Iriels ring theory. Thus every texture with a transparent outer edge needs to stay away from the texture edge by atleast 1px. Gonna try that. I think they did that to determine matching background colors or the like.

Loooool. That worked. I stripped the outer pixel and BÄÄÄM.



So when working with Texture:SetRotation() you have to make sure to do these:
  • Texture size has to be in SQRT
  • Texture rotation must be in rad
  • Texture file must not hit the other edge of the image or you will get background color copy behaviour that you may not want.
__________________
| 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 : 03-13-13 at 01:40 PM.
  Reply With Quote
03-13-13, 12:31 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,335
The reason for the first bug you mentioned is just the way WoW decides to render the out of bounds area of a texture's image. It tends to duplicate the last pixel out past the bounds of the image in order to fill the rendering area of the texture. This has nothing to do with texture:SetRotation() and will show up if you use texture:SetTexCoord() with coordinates that extend out of bounds.

The problem in which the SQRT method fixes is that Blizzard chose to have a texture shrink so the corners of an image fit in it at a 45 degree angle whenever texture:SetRotation() is used. If you manually calculate the coordinates of the corners and set the texcoord yourself, this doesn't apply. Although it's probably easier and more efficient to just multiply the intended size of the texture object with SQRT(2) as shown by your code example.
__________________
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-13-13 at 12:46 PM.
  Reply With Quote
03-13-13, 01:40 PM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Thanks for the insight SDPhantom.


I'm on the way of creating an oUF layout from this. I really wanted to do this for a long time. Now I'm finally able to make it work properly.

I'm currently setting up the orb templates in my GFX program. Currently I have two templates in mind that I want to bring to life.

Outer ring templates


It can be combined with an orb in the center.

Thanks to SetPortraitToTexture() [http://wowprogramming.com/docs/api/S...raitToTexture] it is even possible to work with circular icon symbols. It may not seem that the icon is circular but in fact it is.

Lua Code:
  1. local icon = select(3,GetSpellInfo(12880))
  2.   --icon = "Interface\\LFGFrame\\UI-LFR-PORTRAIT"
  3.   local t = helper:CreateTexture(nil,"OVERLAY",nil,-8)
  4.   t:SetTexCoord(0, 1, 0, 1)
  5.   t:SetAllPoints()
  6.   --t:SetTexture(icon)
  7.   SetPortraitToTexture(t,icon)

Result:


So a template-idea can be adding a circular cast icon inside a circular castbar and ring unitframes.

*edit*

I made the code of the stuff above available via SVN:
http://code.google.com/p/rothui/sour...5.0/rTestRing2
__________________
| 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 : 03-14-13 at 02:54 AM.
  Reply With Quote
03-13-13, 08:36 PM   #4
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Love what I'm seeing here
__________________
Tweets YouTube Website
  Reply With Quote
03-14-13, 06:00 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Currently doing some font tests and finishing the template:


Not sure which font I want to use. All fonts are from dafont.com (except Arial)

Hmm have not decided on the border width. 4, 6 or 8.

Top version is with castbar. Bottom is without.


__________________
| 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 : 03-14-13 at 08:18 AM.
  Reply With Quote
03-14-13, 09:07 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
The second layout I want to do is a revival of my oUF_Orbs mod (http://www.wowinterface.com/download...-oUF_Orbs.html).



The problem is the castbar icon. I think I have to put it somewhere else.

__________________
| 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
03-14-13, 10:23 AM   #7
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,362
*swoons*
  Reply With Quote
03-23-13, 11:20 AM   #8
pelf
Sentient Plasmoid
 
pelf's Avatar
Premium Member
Join Date: May 2008
Posts: 133
Originally Posted by zork View Post
The problem is the castbar icon. I think I have to put it somewhere else.
Top left has symmetry with the cast time. Have you tried putting it behind the main orb?



That looks kind of okay to me.
  Reply With Quote
04-21-13, 06:14 PM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by zork View Post
Lol...SetRotation has a bug. It does sth to my ring texture.


This bug occours, when you call the SetRotation function on a texure which doesn't have enough transparent "spaceborder" to do the full rotate, based on your pivot point. I also run into the problem:



I made a fix like that:

Code:
local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = texture:GetTexCoord();
local x = (sqrt(2) - 1) / 2
texture:SetTexCoord(ULx + x, ULy + x, LLx + x, LLy - x, URx - x, URy + x, LRx - x, LRy - x);
And its gone:

  Reply With Quote
04-23-13, 01:35 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
SDPanthom wrote an explanation on that here aswell: http://www.wowinterface.com/forums/s...7&postcount=10

Regarding your fix. Does the function only has to be called once per texture prior to any SetRotation calls?

If you have to call it after every SetRotation you will be screwed. What if you rotate the texture in a way that your math. prefixed (+-) are wrong because points have switched places.
__________________
| 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 : 04-23-13 at 01:50 AM.
  Reply With Quote
04-23-13, 03:24 AM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by zork View Post
SDPanthom wrote an explanation on that here aswell: http://www.wowinterface.com/forums/s...7&postcount=10

Regarding your fix. Does the function only has to be called once per texture prior to any SetRotation calls?

If you have to call it after every SetRotation you will be screwed. What if you rotate the texture in a way that your math. prefixed (+-) are wrong because points have switched places.
I don't want to rotate textures after the fix, only to mirror them. Whats the point rotate texture which is incapable of it. Well, you can rotate it, but it's going to be glitchy. I only made the fix so the texture going to be look okay on 0 degree, and you can properly mirror it too.

But the version you said, seems intresting too, to cut the edges after every rotation, and you can change the -+ values based on the rotation degree, i might try to code it later.

Last edited by Resike : 04-23-13 at 03:29 AM.
  Reply With Quote
04-23-13, 09:11 AM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Okay i came up with something like that:

Code:
	if (aura.textaura ~= true) then
		texture:SetRotation(math.rad(aura.rotate));
	end
	if (aura.customtex == true) or (aura.owntex == true) then
		local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = texture:GetTexCoord();
		local x = (sqrt(2) - 1) / 2
		if string.find(aura.customname, "//") then
			if (aura.rotate == 0) or (aura.rotate == 360) then
				texture:SetTexCoord(ULx + x, ULy + x, LLx + x, LLy - x, URx - x, URy + x, LRx - x, LRy - x);
			elseif (aura.rotate == 90) then
				texture:SetTexCoord(ULx + x, ULy + x, LLx - x, LLy + x, URx + x, URy - x, LRx - x, LRy - x);
			elseif (aura.rotate == 180) then
				texture:SetTexCoord(ULx + x, ULy - x, LLx + x, LLy + x, URx - x, URy - x, LRx - x, LRy + x);
			elseif (aura.rotate == 270) then
				texture:SetTexCoord(ULx - x, ULy - x, LLx + x, LLy - x, URx - x, URy + x, LRx + x, LRy + x);
			end
		else
			if (aura.rotate == 0) or (aura.rotate == 360) then
				texture:SetTexCoord(ULx + x, ULy + x, LLx + x, LLy - x, URx - x, URy + x, LRx - x, LRy - x);
			elseif (aura.rotate == 90) then
				texture:SetTexCoord(ULx - x, ULy + x, LLx + x, LLy + x, URx - x, URy - x, LRx + x, LRy - x);
			elseif (aura.rotate == 180) then
				texture:SetTexCoord(ULx - x, ULy - x, LLx - x, LLy + x, URx + x, URy - x, LRx + x, LRy + x);
			elseif (aura.rotate == 270) then
				texture:SetTexCoord(ULx + x, ULy - x, LLx - x, LLy - x, URx + x, URy + x, LRx - x, LRy + x);
			end
		end
	end
	if (aura.textaura ~= true) then
		local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy = texture:GetTexCoord();
		if (aura.symetrie == 1) then
			texture:SetTexCoord(URx, URy, LRx, LRy, ULx, ULy, LLx, LLy); -- Inverse X
		elseif (aura.symetrie == 2) then
			texture:SetTexCoord(LLx, LLy, ULx, ULy, LRx, LRy, URx, URy); -- Inverse Y
		elseif (aura.symetrie == 3) then
			texture:SetTexCoord(LRx, LRy, URx, URy, LLx, LLy, ULx, ULy); -- Inverse XY
		else
			texture:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy); -- Normal
		end
	end
	if (aura.textaura == true) then
		frame.baseH = 256 * aura.size * (2 - aura.torsion);
	elseif (aura.customtex == true) then
		local x = (sqrt(2) * 2) - 1
		if string.find(aura.customname, "//") then
			if (aura.rotate == 0) or (aura.rotate == 180) or (aura.rotate == 360) then
				frame.baseH = 256 * aura.size * (2 - aura.torsion);
			elseif (aura.rotate == 90) or (aura.rotate == 270) then
				frame.baseH = x * 256 * aura.size * (2 - aura.torsion);
			else
				frame.baseH = sqrt(2) * 256 * aura.size * (2 - aura.torsion);
			end
		else
			if (aura.rotate == 0) or (aura.rotate == 180) or (aura.rotate == 360) then
				frame.baseH = 256 * aura.size * (2 - aura.torsion);
			elseif (aura.rotate == 90) or (aura.rotate == 270) then
				frame.baseH = 256 * aura.size * (2 - aura.torsion);
			else
				frame.baseH = sqrt(2) * 256 * aura.size * (2 - aura.torsion);
			end
		end
	elseif (aura.owntex == true) then
		if (aura.rotate == 0) or (aura.rotate == 180) or (aura.rotate == 360) then
			frame.baseH = 256 * aura.size * (2 - aura.torsion);
		elseif (aura.rotate == 90) or (aura.rotate == 270) then
			frame.baseH = 256 * aura.size * (2 - aura.torsion);
		else
			frame.baseH = sqrt(2) * 256 * aura.size * (2 - aura.torsion);
		end
	else
		frame.baseH = sqrt(2) * 256 * aura.size * (2 - aura.torsion);
		frame.baseL = sqrt(2) * 256 * aura.size * aura.torsion;
	end
	if (aura.textaura == true) then
		local fontsize = math.min(33, math.max(10, math.floor(frame.baseH / 12.8)));
		local checkfont = texture:SetFont(self.Fonts[aura.aurastextfont], fontsize, "OUTLINE, MONOCHROME");
		if not checkfont then
			texture:SetFont(STANDARD_TEXT_FONT, fontsize, "OUTLINE, MONOCHROME");
		end
		frame.baseL = texture:GetStringWidth() + 5;
	elseif (aura.customtex == true) then
		local x = (sqrt(2) * 2) - 1
		if string.find(aura.customname, "//") then
			if (aura.rotate == 0) or (aura.rotate == 360) then
				frame.baseL = 256 * aura.size * aura.torsion;
			elseif (aura.rotate == 90) or (aura.rotate == 270) then
				frame.baseL = 256 * aura.size * aura.torsion;
			elseif (aura.rotate == 180) then
				frame.baseL = x * 256 * aura.size * aura.torsion;
			else
				frame.baseL = sqrt(2) * 256 * aura.size * aura.torsion;
			end
		else
			if (aura.rotate == 0) or (aura.rotate == 180) or (aura.rotate == 360) then
				frame.baseL = 256 * aura.size * aura.torsion;
			elseif (aura.rotate == 90) or (aura.rotate == 270) then
				frame.baseL = 256 * aura.size * aura.torsion;
			else
				frame.baseL = sqrt(2) * 256 * aura.size * aura.torsion;
			end
		end
	elseif (aura.owntex == true) then
		if (aura.rotate == 0) or (aura.rotate == 180) or (aura.rotate == 360) then
			frame.baseL = 256 * aura.size * aura.torsion;
		elseif (aura.rotate == 90) or (aura.rotate == 270) then
			frame.baseL = 256 * aura.size * aura.torsion;
		else
			frame.baseL = sqrt(2) * 256 * aura.size * aura.torsion;
		end
	end
	PowaAuras:InitialiseFrame(aura, frame);
It lets you rotate any textures, but it shows properly "bugged" textures too at 0, 90, 180, 270 degree. Also the mirroring works on them too.
  Reply With Quote
04-24-13, 04:06 AM   #13
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I don't really understand the hassle. Just cut out a 1px border of your texture's alpha layer. If that pixel is black the texture will be transparent thus the bug will not appear.
Blizzard uses the outmost 1 pixel for background color multiplication calculations which can be quite useful in some scenarios.
__________________
| 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
04-24-13, 07:16 AM   #14
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by zork View Post
I don't really understand the hassle. Just cut out a 1px border of your texture's alpha layer. If that pixel is black the texture will be transparent thus the bug will not appear.
Blizzard uses the outmost 1 pixel for background color multiplication calculations which can be quite useful in some scenarios.
Okay, and how do i do that? :P

The fix meant to work when the user loads a cusom texture, or a texture from wow.
I mostly have problems with ingame icons, i got a thread about it here: http://www.wowinterface.com/forums/s...81&postcount=5

Last edited by Resike : 04-24-13 at 07:29 AM.
  Reply With Quote

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


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