vrConstraintService

class vrConstraintService

(Inherits vrBaseService)

Interface to manage constraints in VRED.

This is the basic interface to access, create or delete constraints. These are some basic examples how to work with it:

# Get some nodes from the scene graph
obj1 = vrNodeService.findNode("Object1")
obj2 = vrNodeService.findNode("Object2")
obj3 = vrNodeService.findNode("Object3")

# Create a position constraint which synchronizes the position of two objects.
posConstraint = vrConstraintService.createPositionConstraint([obj1], obj2, False)

# Change the constrained node of the position constraint.
posConstraint.setConstrainedNode(obj3)

# Deletes the constraint.
vrConstraintService.deleteConstraint(posConstraint)

# Create another position constraint which synchronizes the position of two objects
# with a third one and keeps the current offsets.
posConstraint = vrConstraintService.createPositionConstraint([obj1, obj2], obj3, True)

# Modify the weight of an object.
posConstraint.setTargetNodeWeight(obj1, 0.5)

# Create an aim constraint which computes the target orientation by a source position.
# The up vector is calculated automatically.
aimConstraint = vrConstraintService.createAimConstraint([obj1], [], obj2)

# Find constraints for a given constrained node.
constraints = vrConstraintService.findConstrainedNode(obj2)

# Set all found constraints inactive
for constraint in constraints:
    constraint.setActive(False)

Functions

vrConstraintService.createAimConstraint(targetNodes, upTargetNodes, constrainedNode)

Creates a new aim constraint node.

Parameters:
  • targetNodes (List[vrdNode]) – The nodes to use as constraint targets.
  • upTargetNodes (List[vrdNode]) – The nodes to use as constraint up vector targets. Use an empty list for auto calculation.
  • constrainedNode (vrdNode) – The node to use as the constrained one.
Returns:

The aim constraint node.

Return type:

vrdAimConstraintNode

vrConstraintService.createOrientationConstraint(targetNodes, constrainedNode)

Creates a new orientation constraint node.

Parameters:
  • targetNodes (List[vrdNode]) – The nodes to use as constraint targets.
  • constrainedNode (vrdNode) – The node to use as the constrained one.
Returns:

The orientation constraint node.

Return type:

vrdOrientationConstraintNode

vrConstraintService.createParentConstraint(targetNodes, constrainedNode, maintainOffset)

Creates a new parent constraint node.

Parameters:
  • targetNodes (List[vrdNode]) – The nodes to use as constraint targets.
  • constrainedNode (vrdNode) – The node to use as the constrained one.
  • maintainOffset (bool) – True if the offset shall be maintained, False otherwise.
Returns:

The parent constraint node.

Return type:

vrdParentConstraintNode

vrConstraintService.createPositionConstraint(targetNodes, constrainedNode, maintainOffset)

Creates a new position constraint node.

Parameters:
  • targetNodes (List[vrdNode]) – The nodes to use as constraint targets.
  • constrainedNode (vrdNode) – The node to use as the constrained one.
  • maintainOffset (bool) – True if the offset shall be maintained, False otherwise.
Returns:

The position constraint node.

Return type:

vrdPositionConstraintNode

vrConstraintService.deleteConstraint(constraintNode)

Deletes a given constraint node.

Parameters:constraintNode (vrdConstraintNode) – The constraint node to delete.
Returns:True on success, False otherwise.
Return type:bool
vrConstraintService.findConstrainedNode(constrainedNode)

Returns a list of constraint nodes for a given constrained node.

Parameters:constrainedNode (vrdNode) – The constrained node to get the constraint nodes for.
Returns:The list of constraint nodes.
Return type:List[vrdConstraintNode]
vrConstraintService.getConstraints()

Returns a list of all public constraint nodes.

Returns:The list of constraint nodes.
Return type:List[vrdConstraintNode]