Creating a Parameter Block 1
 
 
 

This topic describes how to create the now parameter blocks used in earlier versions of 3ds Max. The original parameter block 1 type is deprecated, but still supported for compatibility issues, and the parameter block 2 system should be used instead.

Throughout this topic an example of a plug-in with three parameters is used. An angle, a length, and a integer count parameter. A parameter block descriptor is used to describe each parameter. It is initialized by passing three arguments per parameter. (Note that another version uses four arguments. The version with four arguments is used to help maintain backward compatibility. The two descriptors are otherwise the same).

class  ParamBlockDesc {
 public:
  ParamType type;
  UserType *user;
  BOOLanimatable;
 };
// This version of the descriptor has an ID for each parameter.
class  ParamBlockDescID {
 public:
  ParamType type;
  UserType *user;
  BOOLanimatable;
  DWORDid;
 };

The arguments to ParamBlockDesc are:

ParamTypetype

The Parameter Type - The following types may be used:

The next value is NOT USED - it must always be passed as NULL.

BOOLanimatable - This is a flag indicating if the parameter may be animated or not. Pass TRUE if the value may be animated and FALSE if it is constant.

DWORDid (Second version only) - This is an ID used to identify this parameter. This provides a solution to the problem of backwards compatibility. If you alter the parameter structure of your plug-in in the future (by adding or deleting parameter for example) previously saved 3ds Max files will be incompatible. You can however use a mechanism which uses these IDs to convert older versions to the current version.

Items in the parameter block are referred to by index. The index is derived from the order in which the descriptors appear in the ParamBlockDesc array.

// Parameter block indices
#define PB_INDEX_ANGLE 0
#define PB_INDEX_LENGTH 1
#define PB_INDEX_COUNT 2
ParamBlockDesc pdesc[] = {
 { TYPE_FLOAT, NULL, TRUE }, // Angle
 { TYPE_FLOAT, NULL, TRUE }, // Length
 { TYPE_INT, NULL, FALSE } // Count
};

A parameter block is created from this array by calling CreateParameterBlock(). This function requires two values, a pointer to the ParamBlockDesc array and a count of the number of parameters. (Note there is an alternate version for use with the backwards compatibility mechanism discussed above that uses three arguments. The third argument is used to indicate a version of the parameter block. See the topic on Parameter Maps for more information).

IParamBlock* CreateParameterBlock( ParamBlockDesc *pdesc, int count);

or

IParamBlock* CreateParameterBlock( ParamBlockDescID *pdesc, int count,DWORD version);

The function returns a pointer to the parameter block it creates.