Here's a quick tip on how to initialize a struct in maxscript, when an instance of the struct is created:
( -- This is just a sample of a struct that will be initialized -- when an instance of it will be created. -- For this demo, we'll populate the someArray variable with -- some random numbers. struct s_InitializableStruct ( someArray = #(), -- The default value is an empty array. -- The init function is the function that determines what will -- be initilized. fn init = ( someArray = for i = 1 to 10 collect (random 0 1000) ), -- And this is the trick: use another variable, and assign to it -- the "result" of the init function. _init = init() ) -- Create an instance of the struct local structInstance = s_InitializableStruct() -- Print the value of someArray format "%\n" structInstance.someArray -- As you can see, the someArray variable has been initialized with 10 random numbers )
This tip describes how to create multiple masks with Renderman. This technique comes to expand the simple RGBA as masks technique. The problem with masks is usually anti-aliasing. If you use an object channel, it can only have a discreet value for each pixel, meaning that each pixel can hold only one object id value (as demonstrated in the image below,) and this means no anti-aliasing.
In a recent job, I needed to create a dynamic user interface in Maya. I don't really like MEL, so I decided to go with Python. This was the first time I really used Python for anything.
One of the reasons I don't like MEL, is it kind of forces you to use global variables (using local ones becomes a pain if not impossible at some point.)
So, on I went and wrote something like this: