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)
Summary¶
- Functions:
- createAimConstraint(targetNodes, upTargetNodes, constrainedNode) → vrdAimConstraintNode
- createOrientationConstraint(targetNodes, constrainedNode) → vrdOrientationConstraintNode
- createParentConstraint(targetNodes, constrainedNode, maintainOffset) → vrdParentConstraintNode
- createPositionConstraint(targetNodes, constrainedNode, maintainOffset) → vrdPositionConstraintNode
- deleteConstraint(constraintNode) → bool
- findConstrainedNode(constrainedNode) → List[vrdConstraintNode]
- getConstraints() → List[vrdConstraintNode]
Functions¶
-
vrConstraintService.createAimConstraint(targetNodes, upTargetNodes, constrainedNode)¶ Creates a new aim constraint node.
Parameters: Returns: The aim constraint node.
Return type:
-
vrConstraintService.createOrientationConstraint(targetNodes, constrainedNode)¶ Creates a new orientation constraint node.
Parameters: Returns: The orientation constraint node.
Return type:
-
vrConstraintService.createParentConstraint(targetNodes, constrainedNode, maintainOffset)¶ Creates a new parent constraint node.
Parameters: Returns: The parent constraint node.
Return type:
-
vrConstraintService.createPositionConstraint(targetNodes, constrainedNode, maintainOffset)¶ Creates a new position constraint node.
Parameters: Returns: The position constraint node.
Return type:
-
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]