예제 #1
0
ci = azBullet.RigidBodyConstructionInfo(
    sum(masses),
    azBullet.DefaultMotionState(principal),
    cs,
    inertia,
)
body = RigidBody(ci)

# Add the body with its compound shape to the simulation.
sim.addRigidBody(body)
del masses, ci

# Apply an initial force and torque (only valid for the first simulation step
# because Bullet will clear all the forces afterwards).
body.clearForces()
body.applyCentralForce(Vec3(*(0, 1, 0)))
# body.applyTorque(Vec3(*(0, 1, 0)))

# Step the simulation and print the position of the Ball.
for ii in range(10):
    wt = body.getMotionState().getWorldTransform()
    pos = wt.getOrigin().topy()
    rot = wt.getRotation().topy()
    print('Pos: {:.2f}  {:.2f}  {:.2f}'.format(*pos))
    print('Rot: {:.2f}  {:.2f}  {:.2f}  {:.2f}'.format(*rot))
    print('---')
    sim.stepSimulation(0.5, 30)

# Remove the rigid body from the simulation.
sim.removeRigidBody(body)