RobynsVeil opened this issue on Jan 24, 2009 · 490 posts
RobynsVeil posted Mon, 01 June 2009 at 6:32 AM
Sheesh, everyone moves so fast... I'm still trying to get my head around your "Mix" script you posted a page or so back, so please excuse me if I bring the thread back to that.
I'm still digesting the functionality of the script... this bit:
class CSB(object):
def init(item, color, shine, bump):
item.color = color
item.shine = shine
item.bump = bump
def mix(a, b, mask):
return CSB(
Blend(a.color, b.color, mask),
Blend(a.shine, b.shine, mask),
Blend(a.bump, b.bump, mask)
)
It is, after all, the key to the whole thing. A function referring to itself is mind-boggling. Can you point me to a remedial Python class programming site that discusses how this is supposed to work? Recursion - to my knowledge - isn't even allowed in VBA, so I never had to get my head around it. Obviously everyone else gets this, so I don't wanna hold anyone else up, but I need to be able to visualize (conceptualize) what the heck is going on.
--So, when you call CSB (the class), you create a new instance of CSB which has a Mix() function in it.
Quote - All member functions of a class are instructions on how to do something with instances of that class.
mix and init are not something to reference anywhere from outside the function.... their purpose is to define functionality to the class itself. "This is what you're made of " and "this is how you will do with things you're given."
Sheesh, I'm not even making sense to me.
I've written a lot of functions in VBA which did fairly (I thought) clever things and were reusable because they assumed nothing - did parameter-validity checking and all that, but jeez, this is an entirely new level of coding. It must have something to do with the fact that we're defining a class, not a function, which is a completely different marsupial.
For instance, I look at a place down the script where you call - instantiate? - CSB():
paint = CSB(AGC(Color(.2, .5, 1)), 1, 0)
and then I look at the CSB thingie and try to sort out where the values are being passed to.
Looks to me like we're really calling Mix(x,y,z) since it accepts 3 parameters. So, breaking down this paint = thingie, we're sending CSB or Mix() 3 values:
--anti-gammaed Color(.2, .5, 1) -> Mix(a, b, mask)
--1 -> Mix(a, b, mask)
--0 -> Mix(a, b, mask)
Three Blender nodes are returned: colour, specular (shine) and bump.
AGC Color(.2, .5, 1) is Blended (Input_1) with WHITE (Input_2) and there is no mask (meaning the Blending value will be the default, which is 0.5). That's the colour bit that is returned.
-- Is an identical Blender node for shine generated here?
-- And bump?
Before my mind explodes, I'll let you decide which one of these are worth answering.
Monterey/Mint21.x/Win10 - Blender3.x - PP11.3(cm) - Musescore3.6.2
Wir sind gewohnt, daß die Menschen verhöhnen was sie nicht verstehen
[it is clear that humans have contempt for that which they do not understand]