AnimColor Alpha

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
dkwroot
Posts: 659
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

AnimColor Alpha

Post by dkwroot » Sun May 27, 2018 9:14 am

I'm having a problem with the AnimColor class. When I use the GetValue function and perform vector operations with other AnimColor objects and then use the SetValue function, the alpha value doesn't transfer. Is this a bug or am I doing something wrong? I checked and both AnimColor objects have an alpha property and when I create a new AnimeColor object by adding, it also has an alpha. It's just the setvalue function doesn't recognize the alpha.
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: AnimColor Alpha

Post by synthsin75 » Sun May 27, 2018 6:57 pm

The LM_ColorVector operators don't seem to handle alpha. So the alpha may need to be done separately.

Code: Select all

	local mesh = moho:Mesh()
	
	local col1 = mesh:Shape(0).fMyStyle.fFillCol:GetValue(0)
	local col2 = mesh:Shape(0).fMyStyle.fFillCol:GetValue(1)
	local col3 = LM.ColorVector:new_local()
	col3:Set(col1+col2)
	print(col1.a.."   "..col2.a.."   "..col3.a)
	col3.a = col1.a+col2.a
	print(col1.a.."   "..col2.a.."   "..col3.a)
dkwroot
Posts: 659
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: AnimColor Alpha

Post by dkwroot » Tue May 29, 2018 3:47 am

This worked, thanks Wes. I wonder if this is a bug or if the colorvector operators are supposed to work like this.
User avatar
synthsin75
Posts: 7114
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: AnimColor Alpha

Post by synthsin75 » Tue May 29, 2018 7:27 am

dkwroot wrote:This worked, thanks Wes. I wonder if this is a bug or if the colorvector operators are supposed to work like this.
I'm not sure if it was intended to handle alpha or not.
hayasidist
Posts: 2123
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: AnimColor Alpha

Post by hayasidist » Tue May 29, 2018 1:10 pm

Yeah - I've never seen alpha handled by the operators - I've also found a few other "uh?" moments with color vectors -- there seems to be no limiting on an operation - IOW e.g. white*5 = 5,5,5; white + white = 2,2,2; black - white = -1,-1,-1 -- but that's what Normalise is there for... although that does just limit instead of "scale" (I can see the reason why it does - but I can also see that norm could be e.g. 6,3,2 -> 1, .5, .333 rather than 1,1,1 - and I've never bothered to try to use Mag or SquaredMag in such situations)

Personally, I usually do colour operations "by hand" on each channel

the 4 versions of Set do seem to work as expected tho'
Post Reply