コード例 #1
0
ファイル: model.py プロジェクト: raycode/pybilliard
    def __init__(self, filename, view, mass, position=eVector3()):
        super(CueBall, self).__init__(filename, view)
        self.radius = self.model.dimension.z / 2.0
        self.mass = mass
        # Update z pos from radius
        position.z = self.radius

        # Init Transform
        transform = Transform()
        self.position = position
        self.do_transformation_matrix()
        self.mnumpy = array(self.m, 'f')
        transform.setFromOpenGLMatrix(self.mnumpy)

        # The Rigid Body
        mass = self.mass * SCALE_FACTOR
        shape = SphereShape(self.radius)
        i = shape.getLocalInertia(mass) * 0.65
        self.motion = DefaultMotionState()
        self.motion.setWorldTransform(transform)
        self.body = RigidBody.fromConstructionInfo(self.motion,         #  MotionState motion
                                                   shape,               #  CollisionShape shape
                                                   mass,                	#  btScalar mass
                                                   bVector3(i.x, i.y, i.z), #  Vector3 inertia
                                                   transform,           #  Transform worldTransform
                                                   0.2,              	#  btScalar linearDamping
                                                   0.65,              	#  btScalar angularDamping
                                                   0.25,                #  btScalar friction
                                                   0.7,          		#  btScalar restitution
                                                   1.5,                 #  btScalar linearSleepingThreshold
                                                   1.5)                 #  btScalar angularSleepingThreshold

        self.body.setContactProcessingThreshold(0)
        self.body.setCcdMotionThreshold(0)
        self.body.setHitFraction(0.1 * SCALE_FACTOR)
コード例 #2
0
ファイル: model.py プロジェクト: raycode/pybilliard
 def update_body_position(self):
     '''
     Update body position
     '''
     transform = Transform()
     self.mnumpy = array(self.m, 'f')
     transform.setFromOpenGLMatrix(self.mnumpy)
     self.motion.setWorldTransform(transform)