ConstraintOps
 
 
 

Constraint Operator Examples

This addon shows various self-installed custom operators that "constrain" objects together. For example one object may influence the rotation or position of another object in the scene. This sort of operator is common when building rigs and are an alternative to the Constraint, Expression and Proxy Parameter features of Softimage. A Custom Operator is best suitable for cases where the logic of the relationship between the objects is complex such that it can't be described by a simple fcurve or expression statement.

CenterOp_Basic
This is a straightforward example, that sets the position of a Null to the average of the position of 3 other objects. In many cases an operator deals with a fixed number of inputs and a single output as shown in this example.

CenterOp_Simple
The simple CenterOp Plugin builds on the basic example, but it is more flexible and powerful. Rather than a hard-coded number of inputs it supports any number of inputs. It also offers a special custom command "ApplyCenterOp_Simple" that makes it easier to create the operator and its output Null with a single API call.

CenterOp_Dynamic
This is the most advanced CenterOp variation, which lets you connect addition input objects even after the operator has been created. Rather than building a separate input port for each input object as is done in the Simple example, it uses a single input port but allows an unlimited number of instances of the port to be created (via the PortGroup concept). There are two commands, ApplyCenterOp_Dynamic to create the operator and make the initial connections and AddInputsToCenterOp to attach additional inputs to an existing instance of the operator. Because it requires more code to create this type of operator it is only recommended for operators that really need to be fully dynamic.

SurfConstrainOp
This is a Python example which creates an operator that constrains the kinematic global position of a 3D object (the constrained) to a surface. The constrained object position is based on the closest position of an other 3D object (the controller) to the surface object.

SpringOp_Cpp
This is a classic scripted operator example, ported into a C++ self-installed operator.

CSCenterOp
The JScript simple CenterOp plug-in ported to C#.

Example Files

Location
Files
CenterOp_Basic.js
CenterOp_Dynamic.js
CenterOp_Simple.js
SurfaceConstrainOp.py
SpringOp_cpp.cpp
CSCenterOp.cs

Running the Example

To run the DemoCenterOp_Basic example

  • Execute the DemoCenterOp_Basic command.
  • Move the spheres or cylinder and watch the null adjust its position.

To run the DemoCenterOp_Simple example

  • Execute the DemoCenterOp_Simple command.
  • The resulting scene is similar to the DemoCenterOp_Basic scene.

To run the DemoCenterOp_Dynamic example

  • Execute the DemoCenterOp_Dynamic command.
  • The resulting scene is similar to the DemoCenterOp_Basic scene. However if you inspect the details of the operator in the SDK explorer you will see the different Port configuration.

To run the SurfaceConstrainOp example

  • Execute the CreateSurfConstrainOp command.
  • Translates the 'constrainer' Null object around and see how the 'constrained' Null object is moving onto the sphere.

To run the SpringOp example

  • Execute the DemoSpringOp command.
  • Select the cube and move it, and watch the sphere bounce beneath it.
  • Also open the property page for the SpringOp (found under the Global Kinematics of the sphere) and adjust the parameters to change the spring behavior.

To run the CSCenterOp example

  • Select CSCenterOp_Menu|Demo item on the top menu bar.
  • Move the spheres or cylinder and watch the null adjust its position.
  • Also open the property page for the CSCenterOp (found under the Global Kinematics of the null) and adjust the parameters to change the CSCenterOp behavior.

Building the SpringOp Example

Softimage SDK includes a compiled version of SpringOp_Cpp. If you want to modify the code, you can rebuild the example by following these instructions.

To build the example on Windows

  1. Open an Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from an Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the SpringOp_Cpp project from the command line, type:

    devenv cppsrc_SpringOp\SpringOp_Cpp.vcproj
    
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Release or Debug) and build the DLL.

To build the example on Linux

  1. In a shell (tcsh) window, type:

    source $XSI_HOME/.xsi_<xsi_version>
    
  2. Change directories to

    cppsrc_SpringOp
    
  3. To remove all intermediate files before building the example, run this command:

    gmake clean
    
  4. To compile the example, run this command:

    gmake
    

Building the C# Center Op Example

Softimage SDK includes a compiled version of CSCenterOp. If you want to modify the code, you can rebuild the example by following these instructions.

To build the example on Windows

  1. Open an Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from an Softimage command prompt ensures that environment variables such as XSI_HOME are set (otherwise you'll get build and link errors).

    Tip To load the CSCenterOp project from the command line, type:

    devenv cssrc_CenterOp/CSCenterOp.csproj
    
  2. In Visual Studio .NET, open the project file .csproj.
  3. Select a configuration (Release or Debug) and build the DLL.

Keywords

This example uses the following keywords:

Operator CustomOperator OperatorContext JScript Python