11from typing import Optional
22import Sofa
33
4- from SSD .SOFA import UserAPI
4+ from SSD .SOFA . Rendering import UserAPI
55
66
77class Caduceus (Sofa .Core .Controller ):
@@ -17,37 +17,43 @@ def __init__(self, root, factory: Optional[UserAPI] = None, *args, **kwargs):
1717 # Root
1818 self .root .gravity .value = [0 , - 1000 , 0 ]
1919 self .root .dt .value = 0.04
20- required_plugins = ['Sofa.Component' , 'Sofa.GL.Component' ]
20+ with open ('plugins.txt' , 'r' ) as file :
21+ required_plugins = [plugin [:- 1 ] if plugin .endswith ('\n ' ) else plugin for plugin in file .readlines ()
22+ if plugin != '\n ' ]
2123 self .root .addObject ('RequiredPlugin' , pluginName = required_plugins )
2224 self .root .addObject ('VisualStyle' , displayFlags = 'showVisual' )
2325 self .root .addObject ('FreeMotionAnimationLoop' , parallelCollisionDetectionAndFreeMotion = True )
24- self .root .addObject ('DefaultPipeline ' , depth = 15 , verbose = 0 , draw = 0 )
26+ self .root .addObject ('CollisionPipeline ' , depth = 15 , verbose = 0 , draw = 0 )
2527 self .root .addObject ('BruteForceBroadPhase' )
2628 self .root .addObject ('BVHNarrowPhase' )
2729 self .root .addObject ('MinProximityIntersection' , alarmDistance = 1.5 , contactDistance = 1 )
28- self .root .addObject ('DefaultContactManager ' , response = 'FrictionContactConstraint' )
30+ self .root .addObject ('CollisionResponse ' , response = 'FrictionContactConstraint' )
2931 self .root .addObject ('LCPConstraintSolver' , tolerance = 1e-3 , maxIt = 1000 , initial_guess = False , build_lcp = False ,
3032 printLog = 0 , mu = 0.2 )
3133
3234 # Camera
3335 self .root .addObject ('InteractiveCamera' , position = [0 , 30 , 90 ], lookAt = [0 , 30 , 0 ])
3436 self .root .addObject ('LightManager' )
35- self .root .addObject ('SpotLight' , position = [0 , 80 , 25 ], direction = [0 , - 1 , - 0.8 ], cutoff = 30 , exponent = 1 )
36- self .root .addObject ('SpotLight' , position = [0 , 40 , 100 ], direction = [0 , 0 , - 1 ], cutoff = 30 , exponent = 1 )
37+ self .root .addObject ('SpotLight' , name = 'light1' , position = [0 , 80 , 25 ], direction = [0 , - 1 , - 0.8 ], cutoff = 30 ,
38+ exponent = 1 )
39+ self .root .addObject ('SpotLight' , name = 'light2' , position = [0 , 40 , 100 ], direction = [0 , 0 , - 1 ], cutoff = 30 ,
40+ exponent = 1 )
3741
3842 # Snake.Physics
3943 self .root .addChild ('snake' )
4044 self .root .snake .addObject ('MeshOBJLoader' , name = 'Snake' , filename = 'mesh/snake_body.obj' )
4145 self .root .snake .addObject ('EulerImplicitSolver' , rayleighMass = 1 , rayleighStiffness = 0.03 )
46+ self .root .snake .addObject ('MatrixLinearSystem' , name = 'LinearSystem' , template = 'CompressedRowSparseMatrixMat3x3' )
4247 self .root .snake .addObject ('CGLinearSolver' , iterations = 20 , tolerance = 1e-12 , threshold = 1e-18 ,
43- template = 'CompressedRowSparseMatrixMat3x3d' )
48+ template = 'CompressedRowSparseMatrixMat3x3d' , linearSystem = '@LinearSystem' )
4449 self .root .snake .addObject ('SparseGridRamificationTopology' , name = 'Grid' , src = '@Snake' , n = [4 , 12 , 3 ],
4550 nbVirtualFinerLevels = 3 , finestConnectivity = 0 )
46- self .root .snake .addObject ('MechanicalObject' , src = '@Grid' , scale = 1 , dy = 2 )
51+ self .root .snake .addObject ('MechanicalObject' , name = 'GridMO' , src = '@Grid' , scale = 1 , dy = 2 )
4752 self .root .snake .addObject ('UniformMass' , totalMass = 1. )
4853 self .root .snake .addObject ('HexahedronFEMForceField' , youngModulus = 30000 , poissonRatio = 0.3 , method = 'large' ,
4954 updateStiffnessMatrix = False )
50- self .root .snake .addObject ('UncoupledConstraintCorrection' , useOdeSolverIntegrationFactors = False )
55+ self .root .snake .addObject ('UncoupledConstraintCorrection' , defaultCompliance = 184 ,
56+ useOdeSolverIntegrationFactors = False )
5157
5258 # Snake.Collision
5359 self .root .snake .addChild ('collision' )
0 commit comments