-
Notifications
You must be signed in to change notification settings - Fork 0
/
plank_ball_scene.py
80 lines (57 loc) · 2.27 KB
/
plank_ball_scene.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# imports
from stlib.scene import MainHeader
from stlib.solver import DefaultSolver
from stlib.physics.rigid import Floor
# NOTE: double quotations for name param and single for function param
def createScene(rootNode):
"""
Following the Defrost team of the INRIA Lille Nord Europe's tutorial.
"""
MainHeader(rootNode, gravity=[0.0, -981.0, 0.0])
# Collision Handling Built-in Function
ContactHeader(rootNode, alarmDistance=10,
contactDistance=5)
cube = rootNode.createChild("Cube")
# Mechanical Model
totalMass = 5.0
volume = 5.0
inertiaMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
# DOF Mechanical Object
cube.createObject('MechanicalObject', name="DOF",
template="Rigid", translation=[0.0, 0.0, 0.0],
rotation = [0.0, 0.0, 0.0])
# Uniform Mass Object
cube.createObject('UniformMass', name="Mass",
mass=[totalMass, volume, inertiaMatrix[:]])
# Time Integration Scheme
cube.createObject('EulerImplicit', name="Odesolver")
# Solving Method
cube.createObject('CGLinearSolver', name="Solver")
# Visual Object of Cube
visual = cube.createChild("Cube Visual")
# Visual Ogl Model
visual.createObject('OglModel', name="Visual",
fileMesh="mesh/smCube27.ob",
colour=[0.1,0.1,1.0],
scale=25.0)
# Rigid Mapping Object
visual.createObject('RigidMapping')
# Collision Model for the Cube
collision = cube.createChild("Cube Collision Model")
# Creating Collision Objects
collision.createObject('MeshObjLoader', name="Loader",
filename="mesh/smCube27.obj",
triangulate="true", scale=20.0)
# Collision Objects: Mesh, Mechanical Object, Triangle, Line, Point, Rigid Mapping
collision.createObject('Mesh', src="@loader")
collision.createObject('MechanicalObject')
collision.createObject('Triangle')
collision.createObject('Line')
collision.createObject('Point')
collision.createObject('RigidMapping')
# Floor in the Scene
floor = Floor(rootNode, name="Floor",
translation=[0.0, -3200.0, 0.0],
uniformScale=7.0,
isAStaticObject=True)
return rootNode