-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathRigidAnimation.py
More file actions
54 lines (45 loc) · 2.42 KB
/
Copy pathRigidAnimation.py
File metadata and controls
54 lines (45 loc) · 2.42 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
# -*- coding: utf-8 -*-
import Sofa
import os
path = os.path.dirname(os.path.abspath(__file__)) + '/'
pathMesh = os.path.dirname(os.path.abspath(__file__)) + '/mesh/'
def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='SoftRobots')
rootNode.addObject("RequiredPlugin", name='SofaPython3')
rootNode.addObject('RequiredPlugin', pluginName=[
"Sofa.Component.IO.Mesh", # Needed to use components MeshOBJLoader
"Sofa.Component.LinearSolver.Iterative", # Needed to use components CGLinearSolver
"Sofa.Component.IntegrationScheme.Backward", # Needed to use components EulerImplicitIntegrationScheme
"Sofa.Component.Setting", # Needed to use components BackgroundSetting
"Sofa.GL.Component.Rendering3D", # Needed to use components OglModel, OglSceneFrame
])
rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('DefaultVisualManagerLoop')
point = rootNode.addChild('point')
point.addObject('EulerImplicitIntegrationScheme', firstOrder=True)
point.addObject('CGLinearSolver', iterations=100, tolerance=1e-5, threshold=1e-5)
point.addObject('MechanicalObject', template='Rigid3',
position=[0, 0, 0, 0, 0, 0, 1],
showObject=True,
showObjectScale=0.1,
drawMode=1,
showColor=[255, 255, 255, 255])
# The AnimationEditor takes multiple options
# template : should be the same as the mechanical you want to animate
# filename : file in which the animation will be saved
# load : set to true to load the animation at init (default is true)
# loop : when the animation is playing, set this option to true to loop and start again the animation
# dx : to control the animation in displacement instead of time
# frameTime (default is 0.01)
# drawTimeline (default is true)
# drawTrajectory (default is true)
# drawSize : coefficient size of displayed elements of trajectory
point.addObject('AnimationEditor', name='animation',
template='Rigid3', filename=path + 'RigidAnimation.txt',
load=True,
drawTimeline=True, drawTrajectory=True)
visu = point.addChild('visu')
visu.addObject('MeshOBJLoader', name='loader', filename='mesh/cube.obj')
visu.addObject('OglModel', src='@loader', filename='mesh/cube.obj')
visu.addObject('RigidMapping')
return rootNode