Simple constraints demo¶
SimpleConstraints.vpb¶
1sphere = vrNodeService.findNode("Sphere")
2sphere1 = vrNodeService.findNode("Sphere1")
3box = vrNodeService.findNode("Box")
4cone = vrNodeService.findNode("Cone")
5torus = vrNodeService.findNode("Torus")
6
7created = False
8global c1, c2, c3, c4
9
10def createSimpleConstraints():
11 global c1, c2, c3, c4, created
12 # Box position will be synchronized with average of both spheres w/o keeping any offset
13 c1 = vrConstraintService.createPositionConstraint([sphere, sphere1], box, False)
14 # Cone position will be synchronized with red sphere one and keeps its offset
15 c2 = vrConstraintService.createPositionConstraint([sphere], cone, True)
16 # Furthermore will the cone point towards the torus
17 c3 = vrConstraintService.createAimConstraint([torus], [], cone)
18 # Furthermore the box will get the orientation of the cone
19 c4 = vrConstraintService.createOrientationConstraint([cone], box)
20 # Hide the info scene plates
21 infoNode = vrSceneplateService.findNode("Info")
22 infoNode.setVisibilityFlag(False)
23 created = True
24
25def deleteSimpleConstraints():
26 global created
27 all = vrConstraintService.getConstraints()
28 for c in all:
29 vrConstraintService.deleteConstraint(c)
30 created = False
31
32def changeConeTarget():
33 global c3
34 if not created:
35 return
36 # The cone will now be influenced by the yellow sphere instead of the torus
37 c3.setTargetNodes([sphere1])
38
39def changeYellowSphereWeight(weight):
40 global c1
41 if not created:
42 return
43 # Change the weight of the yellow sphere for the constraint with the box target
44 c1.setTargetNodeWeight(sphere1, weight)