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

Function buildModel

pyPBD/examples/pendulum.py:14–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12size = 4.0
13
14def buildModel():
15 sim = pbd.Simulation.getCurrent()
16
17 # Init simulation and collision detection with standard settings
18 sim.initDefault()
19 model = sim.getModel()
20
21 pd = model.getParticles()
22
23 ts = sim.getTimeStep()
24 ts.setValueUInt(pbd.TimeStepController.NUM_SUB_STEPS, 10)
25
26 # add particles
27 dx = size / (numParticles - 1)
28 for i in range(numParticles):
29 pd.addVertex([dx*i,0,0])
30
31 # link them by distance constraints
32 for i in range(numParticles-1):
33 model.addDistanceConstraint_XPBD(i,i+1, 1000000.0)
34
35 # make first particle static
36 pd.setMass(0, 0.0)
37
38# render pendulum
39def render():

Callers 2

resetFunction · 0.70
mainFunction · 0.70

Calls 6

getModelMethod · 0.80
getTimeStepMethod · 0.80
addVertexMethod · 0.80
setMassMethod · 0.80
getCurrentMethod · 0.45

Tested by

no test coverage detected