Arbitrarily picked bRigid’s “Box” example & converted it to “Python Mode”:
"""
bRigid BBox (v1.0.4)
by Daniel Köhler (2013)
mod GoToLoop (2020-Jul-05)
Discourse.Processing.org/t/brigid-import-workaround-for-python-mode/22402
"""
add_library('peasycam')
try: add_library('bRigid')
except: pass
# from bRigid import BPhysics, BBox, BObject
from javax.vecmath import Vector3f
def setup():
size(800, 600, P3D)
smooth(4)
PeasyCam(this, 600)
minv = Vector3f(-120, -250, -120)
maxv = Vector3f(120, 250, 120)
grav = Vector3f(0, 500, 0)
global physics, bbox
physics = BPhysics(minv, maxv)
physics.world.gravity = grav
bbox = BBox(this, 1, 15, 60, 15)
def draw(BG = -1, STEP = .01, FREQ = 10, posv = Vector3f()):
displayTitle()
background(BG)
lights()
rotateY(frameCount * STEP)
if not frameCount % FREQ:
posv.set(random(30), -150, random(1))
physics.addBody(BObject(this, 100, bbox, posv, True))
physics.update()
physics.display()
def keyPressed(): clearAllBodies(physics)
def displayTitle(TITLE = 'Bodies: %d - FPS: %02.f'):
this.surface.title = TITLE % (len(physics.rigidBodies), frameRate)
def clearAllBodies(phy):
bodies = phy.rigidBodies
world = phy.world
for body in bodies:
rb = body.rigidBody
world.removeRigidBody(rb)
rb.destroy()
bodies.clear()
This is a workaround for @solub’s post from here: