def update_shapes(self, physics): for obj in self.objects: if hasattr(obj, 'physics') and obj in physics: trans, rot = physics[obj] obj.shape.translationMatrix = trans obj.shape.rotationMatrix = rot if hasattr(obj, 'extra_shapes'): for s, x, y, z in obj.extra_shapes: p = SimpleVector(x, y, z) p.matMul(rot) m4 = Matrix(trans) m4.translate(p) s.translationMatrix = m4 s.rotationMatrix = rot
def physics_dump(self): d = {} for obj in self.objects: if hasattr(obj, 'physics'): t = Transform() obj.physics.getMotionState().getWorldTransform(t) m = Matrix4f() t.getMatrix(m) trans = Matrix() trans.set(3, 0, m.m03) trans.set(3, 1, m.m13) trans.set(3, 2, m.m23) rot = Matrix() for i in range(3): for j in range(3): rot.set(i, j, m.getElement(j, i)) d[obj] = (trans, rot) return d