A constraint is a restriction of the behavior of one object (the constrained object) based on the behavior of another object (the source object). In the real world, there are many constraints. For example, gravity constrains us to the ground, or a dog is constrained by the length of its leash. In MotionBuilder, constraints are used to simulate these relationships between objects. For example, the constraint on a dog attached to a five-foot leash is X<5, which means that the dog’s motion must be less than 5 (the length of the leash). This simple constraint ensures that the dog behaves like it is on a leash. A control rig is actually a series of many constraints. The rig’s hand is constrained by the motion of the arm that is constrained by the elbow joint, which in turn is constrained by the upper arm, and so on.
Constraints can be expressed in a number of forms including formulae, positional information, and hierarchal relationships.
Constraints are managed using the FBConstraint
class.
You can add a custom constraint to the constraints list in MotionBuilder using the FBConstraint
class. This constraint can be a simple relation between models, or can have a more complex interface based on the FBConstraintLayout
class. All of the constraints functionality in the MotionBuilder UI is exposed to the SDK.
A constraint is linked to a model through a reference. A reference is a handle for an element in a scene that is stored in a list of items inside the constraint data structure. References might be grouped into logical ReferenceGroups. Reference manipulation is done using functions like FBConstraint::ReferenceGroupAdd
, FBConstraint::ReferenceGet
, and FBConstraint::ReferenceRemove
.
Constraints are of two types: regular or deformer. This property is accessed using FBConstraint::Deformer
.
FBConstraint::AnimationNodeNotify
evaluates animation nodes for references in real-time. Regular constraints evaluate the animation nodes of the models being constrained, and affect them with the required behavior.FBConstraint::DeformerNotify
is called at the refresh rate to calculate the vertex deformation.The constraint layout class FBConstraintLayout
is manipulated in exactly the same way as a traditional layout with one added feature (similar to manipulators and devices).
For code examples, see the constraint_template, constraintdeformer, and constraintposition
samples in