Parameter block values are get and set from an IParamBlock2
object using a ParamID
that identifies the parameter value. This must be the same parameter identifier that is supplied as part of the Parameter Specification Arguments.
IParamBlock2::GetValue()
and IParamBlock2::SetValue()
with the parameter block 1 system for setting and retrieving values (IParamBlock::GetValue()
and IParamBlock::SetValue()
) which uses integer indexes instead of ParamID
.There are two sets of functions in class IParamBlock2
for retrieving values from the parameter block.
IParamBlock2::GetValue
functions used for retrieving various data-types in the parameter block. These functions take as one of their arguments an address of a value with the appropriate data type that you want to fill, and return a boolean value indicating success or failure.int
, float
, Point3
, etc...). For example: IParamBlock2::GetColor
, IParamBlock2::GetFloat
, or IParamBlock2::GetPoint3
.When accessing a value from the parameter block an Interval
reference must be supplied. This method is frequently used by developers to 'whittle' down an interval. When a parameter of a parameter block is animated, for any given time there is a interval over which the parameter is constant. If the parameter is constantly changing the interval is instantaneous. If the parameter does not change for a certain period the interval will be longer. If the parameter never changes the interval will be FOREVER
. By passing an interval to the GetValue()
method you ask the parameter block to 'intersect' the interval passed in with the interval of the parameter. Intersecting two intervals means returning a new interval whose start value is the greater of the two, and whose end value is smaller of the two. In this way, the resulting interval represents a combined period of constancy for the two intervals.
This technique is used frequently to compute a validity interval for an object. The developer starts an interval off as FOREVER, then intersects this interval with each of its animated parameters (by calling GetValue()
). GetValue()
'whittles' down the interval with each call. When all the parameters have been intersected the result is the overall validity interval of an object at a specific time. For more information see the section on Intervals.
The following code example is taken from the Bend modified example at maxsdk
\howto\modifiers\bend\bendmod.cpp and demonstrates this technique:
Interval BendMod::GetValidity(TimeValue t)
{
float f = 0.0f;
// Start our interval at forever...
Interval valid = FOREVER;
// Intersect each parameters interval to narrow it down.
pblock2->GetValue(bend_angle,t,f,valid);
pblock2->GetValue(bend_dir,t,f,valid);
pblock2->GetValue(bend_from,t,f,valid);
pblock2->GetValue(bend_to,t,f,valid);
// Return the final validity interval.
return valid;
}
The IParamBlock2::GetValue
methods might be called in the following scenarios:
SimpleMod::GetValidity()
).Functions for setting values in a parameter blocks.
IParamBlock2::SetValue
functions used for setting the parameter value in the parameter block. These functions return a boolean value indicating success or failure.Most of the time parameter values are modified automatically through the associated UI element on the roll-out window, or by an animation controller.
In some circumstances the parameter block value must be set manually. For example during interactive creation and modification of the object via the viewport. See CreateMouseCallback::proc()
for an example of this.