def makeBox(pos=position_init, vel=velocity_init):
    if (True):
        box = btConvexHullShape()
        box.addPoint(btVector3(-1.0, 1.0, -1.0))
        box.addPoint(btVector3(-1.0, -1.0, -1.0))
        box.addPoint(btVector3(-1.0, -1.0, 1.0))
        box.addPoint(btVector3(-1.0, 1.0, 1.0))
        box.addPoint(btVector3(1.0, 1.0, 1.0))
        box.addPoint(btVector3(1.0, 1.0, -1.0))
        box.addPoint(btVector3(1.0, -1.0, -1.0))
        box.addPoint(btVector3(1.0, -1.0, 1.0))
    else:
        box = btBoxShape(btVector3(1.0, 1.0, 1.0))

    # a bullet shape with a mass (1.0)
    box1 = BulletWeightedShape(box, 1.0)

    # A Bullet Dynamical System : a shape + a mass + position and velocity
    body = BulletDS(box1,
                    [0, 0, pos, 1., 0, 0, 0],
                    [0, 0, vel, 0., 0., 0.])
    
    # set external forces
    weight = [0, 0, - box1.mass() * g]
    body.setFExtPtr(weight)

    return body
예제 #2
0
    box.addPoint(btVector3(-1.0, 1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, 1.0))
    box.addPoint(btVector3(-1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, 1.0))
else:
    box = btBoxShape(btVector3(1.0, 1.0, 1.0))

# a bullet shape with a mass (1.0)
box1 = BulletWeightedShape(box, 1.0)

# A Bullet Dynamical System : a shape + a mass + position and velocity
body = BulletDS(box1, [0, 0, position_init, 1., 0, 0, 0],
                [0, 0, velocity_init, 0., 0., 0.])

# set external forces
weight = [0, 0, -box1.mass() * g]
body.setFExtPtr(weight)

#
# Model
#
bouncingBox = Model(t0, T)

# add the dynamical system to the non smooth dynamical system
bouncingBox.nonSmoothDynamicalSystem().insertDynamicalSystem(body)

#
# Simulation
예제 #3
0
    box.addPoint(btVector3(-1.0, -1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, 1.0))
    box.addPoint(btVector3(-1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, 1.0))
else:
    box = btBoxShape(btVector3(1.0, 1.0, 1.0))

# a bullet shape with a mass (1.0)
box1 = BulletWeightedShape(box, 1.0)

# A Bullet Dynamical System : a shape + a mass + position and velocity
body = BulletDS(box1,
                [0, 0, position_init, 1., 0, 0, 0],
                [0, 0, velocity_init, 0., 0., 0.])

# set external forces
weight = [0, 0, - box1.mass() * g]
body.setFExtPtr(weight)

#
# Model
#
bouncingBox = Model(t0, T)

# add the dynamical system to the non smooth dynamical system
bouncingBox.nonSmoothDynamicalSystem().insertDynamicalSystem(body)

#