Class MCDeviceBinding

3DS Max Plug-In SDK

Class MCDeviceBinding

See Also: Class ReferenceTarget, Class MCInputDevice, Class IMCParamDlg, Class IRollupWindow.

class MCDeviceBinding : public ReferenceTarget

Description:

An instance of this class is created when a motion capture controller binds one of its parameters to a device. The main purpose of this class is to store any parameters that describe the binding.

Methods:

Prototype:

virtual MCInputDevice *GetDevice()=0;

Remarks:

Returns a pointer to the bound input device.

Prototype:

virtual void DeleteThis()=0;

Remarks:

Deletes this instace of the class.

Prototype:

virtual TSTR BindingName()=0;

Remarks:

Returns the name of the bound input device.

Prototype:

virtual float Eval(TimeValue t)=0;

Remarks:

A device binding is the thing that the controller evaluates to get the value of the device. Everything is simply a scalar parameter. So for example even for a device like a mouse that has X and Y motion the device binding will break down into simply X or Y. This method is used to return the value of the device at the instant this method is called.

Parameters:

TimeValue t

The time at which this method is called.

Prototype:

virtual void AddRollup(IMCParamDlg *dlg)=0;

Remarks:

This method is called to allow the binding to put up any user interface it has into the command panel via rollup pages.

Parameters:

IMCParamDlg *dlg

The IRollupWindow data member of this class may be used to add the rollup page.

Sample Code:

dlg->iRoll->AppendRollup(

  hInstance,

  MAKEINTRESOURCE(IDD_MC_MOUSE),

  MouseDeviceDlgProc,

  GetString(IDS_RB_MOUSEDEVICE),

  (LPARAM)dlg);

Prototype:

virtual void UpdateRollup(IRollupWindow *iRoll)=0;

Remarks:

This method is called to allow the plug-in to update the values in its user interface rollup.

Parameters:

IRollupWindow *iRoll

The interface into the command panel rollups. The GetPanelDlg() method may be used to return the window handle of the dialog and this HWND may be used to update the controls.

Prototype:

virtual void BeginActivate(BOOL reset=TRUE);

Remarks:

This method is called when the binding becomes active.

Parameters:

BOOL reset=TRUE

If TRUE 3ds max is being reset; otherwise this is the first time the binding is becoming active.

Default Implementation:

{}

Prototype:

virtual void EndActivate();

Remarks:

This method is called when the binding has been released.

Default Implementation:

{}

Prototype:

virtual void Accumulate(TimeValue t);

Remarks:

This method is called 50 times per second during motion capture.

To understand how this is used consider the following two situations for a motion capture device:

1. The motion capture device is a joystick, and the position of the joystick directly maps to a range of some parameter. In this case, if you need to evaluate the parameter, you simply evaluate the joystick (inside the Eval() method). The position establishes the value.

2. A different case is where you have a parameter at a starting value, and if the joystick is moved, to say the right, the value is incremented. If the joystick is moved to the left the value is decremented. In this case the value can theoretically reach any value. What is needed is for the value to be incremented and decremented in a consistent fashion. If the joystick is polled only during the Eval() method, and the value is incremented or decremented there, it may be a problem. If two things are using the same motion capture device, the value will be incremented or decremented twice inside Eval(). This will cause the value to grow or shrink twice as fast. If three things evaluated the same joystick it would move three times as fast because it would get incremented three times per frame. The solution is to use this method. It is called 50 times per second. The increments are done inside this method, and when the Eval() method is called the accumulated state is simply returned. This works because the method is called a fixed number of times per second regardless of the number of items evaluating the device.

Parameters:

TimeValue t

The current time when this method is called.

Default Implementation:

{}