Replies: 2 comments 1 reply
-
|
I used GLM math library, and basically created conversion functions in my physics class to return GLM types to see the positions/rotations. If i recall correctly, Bullet is row major in matricies, and GLM is column major by default. |
Beta Was this translation helpful? Give feedback.
-
|
I use Simple pip install Panda3Dfrom panda3d.bullet import BulletWorld, BulletRigidBodyNode, BulletBoxShape
from panda3d.core import Vec3, Point3, Quat, TransformState
import time
# Setup the Physics World
world = BulletWorld()
world.set_gravity(Vec3(0, 0, -9.81))
# Create a Collision Shape (Box with half-extents 0.5)
shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))
# Create a Rigid Body
node = BulletRigidBodyNode("Box")
node.set_mass(1.0)
node.add_shape(shape)
# Set Initial Position and Orientation
p = Point3(0, 0, 10) # Position
q = Quat.ident_quat() # Orientation (No rotation)
s = Vec3(1, 1, 1) # Scale (100%)
initial_transform = TransformState.make_pos_quat_scale(p, q, s)
node.set_transform(initial_transform)
# Attach to the world
world.attach_rigid_body(node)
print(f"{'Step':<5} | {'Z-Position':<12} | {'Quaternion (W, X, Y, Z)':<30}")
print("-" * 60)
# Physics Loop (Simulate falling for 2 seconds)
dt = 1.0 / 60.0
for i in range(120):
world.do_physics(dt)
# Get the current transform
curr_transform = node.get_transform()
pos = curr_transform.get_pos()
quat = curr_transform.get_quat()
# Print the coordinates
# Quaternions are printed as (w, x, y, z) in Panda3D
print(f"{i:<5} | {pos.get_z():<12.4f} | {quat}")
time.sleep(dt)This is more advanced example in OpenGL + PySDL3 + Panda3D's Bullet Physics: pip install Panda3D PySDL3 numpy PyOpenGL Pillow PyGLM
py main.py
My examples in |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying for days use PyBullet as a physics engine for my game and I had some trouble displaying PyBullet's physics calculation. With weird rotations and position offsets being displayed in my OpenGL window (in relation to what is displayed in PyBullet's debug viewer). How do I correctly convert position/orientation data from PyBullet (for example getBasePositionAndOrientation()) to something PyOpenGL and PyGLM can use correctly and the opposite?
Beta Was this translation helpful? Give feedback.
All reactions