forked from SofaDefrost/STLIB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontactheader.py
More file actions
55 lines (40 loc) · 2.09 KB
/
contactheader.py
File metadata and controls
55 lines (40 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
def ContactHeader(applyTo, alarmDistance, contactDistance, frictionCoef=0.0):
'''
Args:
applyTo (Sofa.Node): the node to attach the object to
alarmDistance (float): define the distance at which the contact are integrated into
the detection computation.
contactDistance (float): define the distance at which the contact response is
integrated into the computation.
frictionCoef (float, default=0.0): optional value, set to non-zero to enable
a global friction in your scene.
Structure:
.. sourcecode:: qml
applyTo : {
CollisionPipeline,
BruteForceDetection,
RuleBasedContactManager,
LocalMinDistance
}
'''
if applyTo.hasObject("CollisionPipeline") is False:
applyTo.addObject('CollisionPipeline')
applyTo.addObject('BruteForceBroadPhase')
applyTo.addObject('BVHNarrowPhase')
applyTo.addObject('RuleBasedContactManager', responseParams="mu="+str(frictionCoef),
name='Response', response='FrictionContactConstraint')
applyTo.addObject('LocalMinDistance',
alarmDistance=alarmDistance, contactDistance=contactDistance,
angleCone=0.01)
if applyTo.hasObject("FreeMotionAnimationLoop") is False:
applyTo.addObject('FreeMotionAnimationLoop')
if applyTo.hasObject("BlockGaussSeidelConstraintSolver") is False:
applyTo.addObject('BlockGaussSeidelConstraintSolver', tolerance=1e-6, maxIterations=1000)
return applyTo
# This function is just an example on how to use the DefaultHeader function.
def createScene(rootnode):
import os
from mainheader import MainHeader
MainHeader(rootnode, plugins=["SofaPython3"], repositoryPaths=[os.getcwd()])
ContactHeader(rootnode, alarmDistance=1, contactDistance=0.1, frictionCoef=1.0)