Notifications
Clear all

[Closed] Get/Set a Controller's actual value…?

Is there a way to get/set a controller’s actual value, without being affected by the scaling factor of a specific node’s property?

I have several color controllers stored in Track View via the addTrackViewController() function, and I’d expected to be able to have them store a color value (static or animated) that I could sometimes use to control the colors of a set of lights.

However, because these controllers aren’t always connected to any node properties, Max seems to get confused about whether to scale the internal values in these controllers to RGB values or not. Sometimes these values are reported as valid RGB color values, and sometimes I get the actual values in the controllers (i.e. floats between 0.0 and 1.0).

So far, I’ve been unable to reliably retain the same color using the following steps:

  1. Store a Track View controller’s current value to a variable
  2. Instance the controller to the color track of the light
  3. Assign that value back to the controller, either via the light’s .color property or directly to the controller’s .value property

Any ideas or workaround come to mind?

2 Replies

I think this is a serious problem if not bug in max. You simply can’t get the REAL value of the controller if you’ve assigned it to some property which scales it. <controller>.value always returns the scaled value.

The best way I’ve found around this is to store the node to custom attribute of rootNode and then accessing the nodes value like this rootNode.controllers[1].value asuming you’ve added “controllers” custom attribute array to rootNode.

I don’t understand the point of applying the scaling to <controller>.value, if I want the scaled value then I’ll get it from <node>.<property>. The way max handdles this is extremely stupid and should be fixed.

I agree that this is a serious limitation, and that there should be a way to either get/set the scaling factor (if any) applied to a controller’s value property, or a method to get/set the actual controller value. Get/set access to controllers should not be limited to their being assigned to nodes.

As a workaround, I’ve had to restrict color values assigned to these controllers to a range of 0 or 2-255, since RGB values between 0 and 1 would be impossible to differentiate from the occasional unscaled values. When my script gets an RGB color value in which the R,G and B values are all 1.0 or less, the color value is scaled by 255 before being used.