MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / buildModel

Function buildModel

pyPBD/examples/armadillo.py:23–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22
23def buildModel():
24 sim = pbd.Simulation.getCurrent()
25
26 # Init simulation and collision detection with standard settings
27 sim.initDefault()
28 model = sim.getModel()
29
30 rbs = model.getRigidBodies()
31
32 # Create the mesh for the solid model
33 createMesh(simModel)
34
35 # Load geometry from OBJ file
36 fileName2 = "../../data/models/torus.obj"
37 (vdTorus, meshTorus) = pbd.OBJLoader.loadObjToMesh(fileName2, [1, 1, 1])
38
39 # torus
40 rb = model.addRigidBody(1.0, # density
41 vdTorus, meshTorus, # vertices, mesh
42 [0.0, 1.5, 0.0], # position
43 np.identity(3), # rotation matrix
44 [2.0, 2.0, 2.0], # scaling
45 testMesh=True, # test mesh vertices against other signed distance fields
46 generateCollisionObject= True, # automatically generate an SDF and a corresponding collision object
47 resolution=[30, 30, 30]) # resolution of the signed distance field
48 rb.setMass(0.0)
49 rb.setFrictionCoeff(0.3)
50
51 # Set collision tolerance (distance threshold)
52 cd = sim.getTimeStep().getCollisionDetection()
53 cd.setTolerance(0.05)
54
55 ts = sim.getTimeStep()
56 ts.setValueUInt(pbd.TimeStepController.NUM_SUB_STEPS, 5)
57
58
59# Create a particle model mesh

Callers 2

resetFunction · 0.70
mainFunction · 0.70

Calls 8

getModelMethod · 0.80
setMassMethod · 0.80
getCollisionDetectionMethod · 0.80
getTimeStepMethod · 0.80
setToleranceMethod · 0.80
createMeshFunction · 0.70
getCurrentMethod · 0.45
setFrictionCoeffMethod · 0.45

Tested by

no test coverage detected