Ejemplo n.º 1
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                halfExtents=(1, 0.2, 1))

        self.body1 = igeBullet.rigidBody(shape, 0, (0, 5, -1.2), (0, 0, 0, 1))
        world.add(self.body1)
        Utils().AddShapeMesh(shape)

        self.body2 = igeBullet.rigidBody(shape, 1, (0, 5, 1.2), (0, 0, 0, 1))
        world.add(self.body2)
        Utils().AddShapeMesh(shape)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 3.14 / 2, 0))
        posA = vmath.vec3(0, 0, 1.2)
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 3.14 / 2, 0))
        posB = vmath.vec3(0, 0, -1.2)
        joint = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE,
                                     self.body1,
                                     self.body2,
                                     frameA=(posA, rotA),
                                     frameB=(posB, rotB))
        world.add(joint)

        efig.mergeSameMaterialMesh()
Ejemplo n.º 2
0
def addObject(world, type, mass, position, size=(1,1,1), radius=1, height=3, name='body'):
    if type == igeBullet.BOX_SHAPE_PROXYTYPE:
        shape = igeBullet.shape(type, halfExtents=size)
    elif type == igeBullet.SPHERE_SHAPE_PROXYTYPE:
        shape = igeBullet.shape(type, radius=radius)
    elif type ==igeBullet.CAPSULE_SHAPE_PROXYTYPE:
        shape = igeBullet.shape(type, radius=radius, height=height)
    elif type ==igeBullet.CONE_SHAPE_PROXYTYPE:
        shape = igeBullet.shape(type, radius=radius, height=height)
    elif type ==igeBullet.CYLINDER_SHAPE_PROXYTYPE:
        shape = igeBullet.shape(type, halfExtents=size)

    body = igeBullet.rigidBody(shape, mass, position, (0, 0, 0, 1))
    body.name = name
    world.add(body)
    Utils().AddShapeMesh(shape)
    return body
Ejemplo n.º 3
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        #shape = igeBullet.shape(igeBullet.STATIC_PLANE_PROXYTYPE, normal=(0,1,0), constant=0)
        shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                halfExtents=(10, 1, 10))
        self.body1 = igeBullet.rigidBody(shape, 0, (0, 0, 0), (0, 0, 0, 1))
        world.add(self.body1)
        Utils().AddShapeMesh(shape)

        shape = igeBullet.shape(igeBullet.SPHERE_SHAPE_PROXYTYPE, radius=1)
        self.body2 = igeBullet.rigidBody(shape, 5, (0, 15, 0), (0, 0, 0, 1))
        world.add(self.body2)
        Utils().AddShapeMesh(shape)

        efig.mergeSameMaterialMesh()
Ejemplo n.º 4
0
    def __init__(self, world):
        self.figure = core.figure('capeMan')

        points = self.figure.getVertexElements('body',
                                               core.ATTRIBUTE_ID_POSITION,
                                               core.WorldSpace)
        shape = igeBullet.shape(igeBullet.CONVEX_HULL_SHAPE_PROXYTYPE,
                                points=points)
        min, max = shape.getAabb()
        compound = igeBullet.shape(igeBullet.COMPOUND_SHAPE_PROXYTYPE)
        compound.addChildShape(shape, (0, -min[1], 0), (0, 0, 0, 1))
        self.body = igeBullet.rigidBody(compound, 5, (0, 0, 0), (0, 0, 0, 1))
        self.body.angularFactor = (0, 1, 0)
        world.add(self.body)
        #utl = Utils()
        #utl.AddShapeMesh(compound)

        points = self.figure.getVertexElements('cape',
                                               core.ATTRIBUTE_ID_POSITION,
                                               space=core.WorldSpace)
        triangles = self.figure.getTriangles('cape')
        self.soft = igeBullet.softBody(world, points, triangles)
        self.figure.killJointTransform('cape')
        self.figure.setMaterialRenderState('phong1', 'cull_face_enable', False)
        pos, _, _ = self.figure.getJoint('anchor1', core.WorldSpace)
        no, pos = self.soft.findNearestNode(pos)
        self.soft.appendDeformableAnchor(no, self.body)
        pos, _, _ = self.figure.getJoint('anchor2', core.WorldSpace)
        no, pos = self.soft.findNearestNode(pos)
        self.soft.appendDeformableAnchor(no, self.body)
        pos, _, _ = self.figure.getJoint('anchor3', core.WorldSpace)
        no, pos = self.soft.findNearestNode(pos)
        self.soft.appendDeformableAnchor(no, self.body)
        pos, _, _ = self.figure.getJoint('anchor4', core.WorldSpace)
        no, pos = self.soft.findNearestNode(pos)
        self.soft.appendDeformableAnchor(no, self.body)
Ejemplo n.º 5
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                halfExtents=(10, 1, 10))
        self.ground = igeBullet.rigidBody(shape, 0, (0, 0, 0), (0, 0, 0, 1))
        world.add(self.ground)
        Utils().AddShapeMesh(shape)

        compound = igeBullet.shape(igeBullet.COMPOUND_SHAPE_PROXYTYPE)
        box = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                              halfExtents=(0.5, 0.5, 0.5))
        compound.addChildShape(box, (0, 0, 0), (0, 0, 0, 1))
        compound.addChildShape(box, (0, -1, 0), (0, 0, 0, 1))
        compound.addChildShape(box, (0, 0, 1), (0, 0, 0, 1))
        self.body1 = igeBullet.rigidBody(
            compound, 1, (0, 20, 0),
            vmath.quat(vmath.mat_rotationZYX(3, 0.4, 0, 0)))
        world.add(self.body1)
        Utils().AddShapeMesh(compound)

        efig.mergeSameMaterialMesh()
Ejemplo n.º 6
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        shape = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 1, 4)

        self.body1 = igeBullet.rigidBody(shape,0,(-3,5,0),vmath.quat(vmath.mat_rotationZYX(3, 0, 0, 3.14/2)))
        world.add(self.body1)
        Utils().AddShapeMesh(shape)

        self.body2 = igeBullet.rigidBody(shape,1,(3,5,0),vmath.quat(vmath.mat_rotationZYX(3, 0, 0, 3.14/2)))
        world.add(self.body2)
        Utils().AddShapeMesh(shape)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, 3.14/2))
        posA = vmath.vec3(0, -3.2, 0)
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, 3.14/2))
        posB = vmath.vec3(0,  3.2, 0)
        joint = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.body1, self.body2,
                                     frameA=(posA, rotA), frameB=(posB, rotB))
        world.add(joint)

        efig.mergeSameMaterialMesh()
Ejemplo n.º 7
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                halfExtents=(10, 1, 10))
        self.ground = igeBullet.rigidBody(shape, 0, (0, 0, 0), (0, 0, 0, 1))
        world.add(self.ground)
        Utils().AddShapeMesh(shape)

        compound = igeBullet.shape(igeBullet.COMPOUND_SHAPE_PROXYTYPE)
        chassisShape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                       halfExtents=(1.0, 0.5, 2.0))
        compound.addChildShape(chassisShape, (0, 1, 0), (0, 0, 0, 1))
        suppShape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE,
                                    halfExtents=(0.5, 0.1, 0.5))
        compound.addChildShape(suppShape, (0, 1.0, 2.5), (0, 0, 0, 1))
        self.carChassis = igeBullet.rigidBody(compound, 10, (7, 1, 0),
                                              (0, 0, 0, 1))
        world.add(self.carChassis)
        Utils().AddShapeMesh(compound)

        wheelRadius = 0.5
        wheelWidth = 0.4
        wheelShape = igeBullet.shape(igeBullet.CYLINDER_SHAPE_PROXYTYPE,
                                     halfExtents=(wheelWidth, wheelRadius,
                                                  wheelRadius),
                                     axis=0)
        Utils().AddShapeMesh(wheelShape)
        Utils().AddShapeMesh(wheelShape)
        Utils().AddShapeMesh(wheelShape)
        Utils().AddShapeMesh(wheelShape)
        self.vehicle = igeBullet.vehicle(world, self.carChassis)
        world.add(self.vehicle)

        connectionHeight = 1.2
        CUBE_HALF_EXTENTS = 1.0
        suspensionRestLength = 0.6
        wheelDirectionCS0 = (0, -1, 0)
        wheelAxleCS = (-1, 0, 0)

        isFrontWheel = True
        connectionPointCS0 = (CUBE_HALF_EXTENTS - (0.3 * wheelWidth),
                              connectionHeight,
                              2 * CUBE_HALF_EXTENTS - wheelRadius)
        self.vehicle.addWheel(connectionPointCS0, wheelDirectionCS0,
                              wheelAxleCS, suspensionRestLength, wheelRadius,
                              isFrontWheel)
        connectionPointCS0 = (-CUBE_HALF_EXTENTS + (0.3 * wheelWidth),
                              connectionHeight,
                              2 * CUBE_HALF_EXTENTS - wheelRadius)
        self.vehicle.addWheel(connectionPointCS0, wheelDirectionCS0,
                              wheelAxleCS, suspensionRestLength, wheelRadius,
                              isFrontWheel)
        isFrontWheel = False
        connectionPointCS0 = (-CUBE_HALF_EXTENTS + (0.3 * wheelWidth),
                              connectionHeight,
                              -2 * CUBE_HALF_EXTENTS + wheelRadius)
        self.vehicle.addWheel(connectionPointCS0, wheelDirectionCS0,
                              wheelAxleCS, suspensionRestLength, wheelRadius,
                              isFrontWheel)
        connectionPointCS0 = (CUBE_HALF_EXTENTS - (0.3 * wheelWidth),
                              connectionHeight,
                              -2 * CUBE_HALF_EXTENTS + wheelRadius)
        self.vehicle.addWheel(connectionPointCS0, wheelDirectionCS0,
                              wheelAxleCS, suspensionRestLength, wheelRadius,
                              isFrontWheel)

        efig.mergeSameMaterialMesh()
        """
Ejemplo n.º 8
0
    def setup(self, world):
        world.clear()
        efig = Utils().GetFigure()
        efig.clearMesh()

        #shape = igeBullet.shape(igeBullet.STATIC_PLANE_PROXYTYPE, normal=(0,1,0), constant=0)
        shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE, halfExtents=(10,1,10))
        body = igeBullet.rigidBody(shape,0,(0,0,0),(0,0,0,1))
        world.add(body)
        Utils().AddShapeMesh(shape)

        scale = 5.0
        offset = vmath.vec3(0, 5, 0)

        M_PI = 3.14159265358979323846
        M_PI_2 = 1.57079632679489661923
        M_PI_4 = 0.785398163397448309616

        BODYPART_PELVIS = 0
        BODYPART_SPINE = 1
        BODYPART_HEAD = 2
        BODYPART_LEFT_UPPER_LEG = 3
        BODYPART_LEFT_LOWER_LEG = 4
        BODYPART_RIGHT_UPPER_LEG = 5
        BODYPART_RIGHT_LOWER_LEG = 6
        BODYPART_LEFT_UPPER_ARM = 7
        BODYPART_LEFT_LOWER_ARM = 8
        BODYPART_RIGHT_UPPER_ARM = 9
        BODYPART_RIGHT_LOWER_ARM = 10
        self.BODYPART_COUNT = 11
        JOINT_PELVIS_SPINE = 0
        JOINT_SPINE_HEAD = 1
        JOINT_LEFT_HIP = 2
        JOINT_LEFT_KNEE = 3
        JOINT_RIGHT_HIP = 4
        JOINT_RIGHT_KNEE = 5
        JOINT_LEFT_SHOULDER = 6
        JOINT_LEFT_ELBOW = 7
        JOINT_RIGHT_SHOULDER = 8
        JOINT_RIGHT_ELBOW = 9
        JOINT_COUNT = 10

        m_shapes = [0] * self.BODYPART_COUNT
        m_shapes[BODYPART_PELVIS] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.15 * scale, 0.20 * scale)
        m_shapes[BODYPART_SPINE] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.15 * scale, 0.28 * scale)
        m_shapes[BODYPART_HEAD] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.10 * scale, 0.05 * scale)
        m_shapes[BODYPART_LEFT_UPPER_LEG] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.07 * scale, 0.45 * scale)
        m_shapes[BODYPART_LEFT_LOWER_LEG] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.05 * scale, 0.37 * scale)
        m_shapes[BODYPART_RIGHT_UPPER_LEG] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.07 * scale, 0.45 * scale)
        m_shapes[BODYPART_RIGHT_LOWER_LEG] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.05 * scale, 0.37 * scale)
        m_shapes[BODYPART_LEFT_UPPER_ARM] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.05 * scale, 0.33 * scale)
        m_shapes[BODYPART_LEFT_LOWER_ARM] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.04 * scale, 0.25 * scale)
        m_shapes[BODYPART_RIGHT_UPPER_ARM] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.05 * scale, 0.33 * scale)
        m_shapes[BODYPART_RIGHT_LOWER_ARM] = igeBullet.shape(igeBullet.CAPSULE_SHAPE_PROXYTYPE, 0.04 * scale, 0.25 * scale)

        for i in range(self.BODYPART_COUNT):
            Utils().AddShapeMesh(m_shapes[i])

        self.m_bodies = [0] * self.BODYPART_COUNT
        pos = vmath.vec3(0, 1, 0) * scale + offset
        rot = vmath.quat()
        self.m_bodies[BODYPART_PELVIS] = igeBullet.rigidBody(m_shapes[BODYPART_PELVIS], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_PELVIS])

        pos = vmath.vec3(0, 1.2, 0) * scale + offset
        self.m_bodies[BODYPART_SPINE] = igeBullet.rigidBody(m_shapes[BODYPART_SPINE], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_SPINE])

        pos = vmath.vec3(0, 1.6, 0) * scale + offset
        self.m_bodies[BODYPART_HEAD] = igeBullet.rigidBody(m_shapes[BODYPART_HEAD], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_HEAD])

        pos = vmath.vec3(-0.18, 0.65, 0) * scale + offset
        self.m_bodies[BODYPART_LEFT_UPPER_LEG] = igeBullet.rigidBody(m_shapes[BODYPART_LEFT_UPPER_LEG], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_LEFT_UPPER_LEG])

        pos = vmath.vec3(-0.18, 0.2, 0) * scale + offset
        self.m_bodies[BODYPART_LEFT_LOWER_LEG] = igeBullet.rigidBody(m_shapes[BODYPART_LEFT_LOWER_LEG], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_LEFT_LOWER_LEG])

        pos = vmath.vec3(0.18, 0.65, 0) * scale + offset
        self.m_bodies[BODYPART_RIGHT_UPPER_LEG] = igeBullet.rigidBody(m_shapes[BODYPART_RIGHT_UPPER_LEG], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_RIGHT_UPPER_LEG])

        pos = vmath.vec3(0.18, 0.2, 0) * scale + offset
        self.m_bodies[BODYPART_RIGHT_LOWER_LEG] = igeBullet.rigidBody(m_shapes[BODYPART_RIGHT_LOWER_LEG], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_RIGHT_LOWER_LEG])

        pos = vmath.vec3(-0.35, 1.45, 0) * scale + offset
        rot = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_2))
        self.m_bodies[BODYPART_LEFT_UPPER_ARM] = igeBullet.rigidBody(m_shapes[BODYPART_LEFT_UPPER_ARM], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_LEFT_UPPER_ARM])

        pos = vmath.vec3(-0.7, 1.45, 0) * scale + offset
        rot = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_2))
        self.m_bodies[BODYPART_LEFT_LOWER_ARM] = igeBullet.rigidBody(m_shapes[BODYPART_LEFT_LOWER_ARM], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_LEFT_LOWER_ARM])

        pos = vmath.vec3(0.35, 1.45, 0) * scale + offset
        rot = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, -M_PI_2))
        self.m_bodies[BODYPART_RIGHT_UPPER_ARM] = igeBullet.rigidBody(m_shapes[BODYPART_RIGHT_UPPER_ARM], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_RIGHT_UPPER_ARM])

        pos = vmath.vec3(0.7, 1.45, 0) * scale + offset
        rot = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, -M_PI_2))
        self.m_bodies[BODYPART_RIGHT_LOWER_ARM] = igeBullet.rigidBody(m_shapes[BODYPART_RIGHT_LOWER_ARM], 1, pos, rot)
        world.add(self.m_bodies[BODYPART_RIGHT_LOWER_ARM])

        for i in range(self.BODYPART_COUNT):
            self.m_bodies[i].linearDamping = 0.05
            self.m_bodies[i].angularDamping = 0.85
            self.m_bodies[i].deactivationTime = 0.8
            self.m_bodies[i].linearSleepingThreshold = 1.6
            self.m_bodies[i].angularSleepingThreshold = 2.5

        m_joints = [0] * JOINT_COUNT
        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posA = vmath.vec3(0, 0.15, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posB = vmath.vec3(0, -0.15, 0) * scale
        m_joints[JOINT_PELVIS_SPINE] = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE, self.m_bodies[BODYPART_PELVIS],
                                                            self.m_bodies[BODYPART_SPINE], frameA=(posA, rotA),
                                                            frameB=(posB, rotB))
        m_joints[JOINT_PELVIS_SPINE].setLimit(-M_PI_4, M_PI_2)
        world.add(m_joints[JOINT_PELVIS_SPINE], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_2))
        posA = vmath.vec3(0, 0.3, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_2))
        posB = vmath.vec3(0, -0.14, 0) * scale
        m_joints[JOINT_SPINE_HEAD] = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.m_bodies[BODYPART_SPINE],
                                                          self.m_bodies[BODYPART_HEAD], frameA=(posA, rotA), frameB=(posB, rotB))
        m_joints[JOINT_SPINE_HEAD].setLimit(M_PI_4, M_PI_4, M_PI_2)
        world.add(m_joints[JOINT_SPINE_HEAD], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, -M_PI_4 * 5))
        posA = vmath.vec3(-0.18, -0.10, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, -M_PI_4 * 5))
        posB = vmath.vec3(0, 0.225, 0) * scale
        m_joints[JOINT_LEFT_HIP] = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.m_bodies[BODYPART_PELVIS],
                                                        self.m_bodies[BODYPART_LEFT_UPPER_LEG], frameA=(posA, rotA),
                                                        frameB=(posB, rotB))
        m_joints[JOINT_LEFT_HIP].setLimit(M_PI_4, M_PI_4, 0)
        world.add(m_joints[JOINT_LEFT_HIP], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posA = vmath.vec3(0, -0.225, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posB = vmath.vec3(0, 0.185, 0) * scale
        m_joints[JOINT_LEFT_KNEE] = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE, self.m_bodies[BODYPART_LEFT_UPPER_LEG],
                                                         self.m_bodies[BODYPART_LEFT_LOWER_LEG], frameA=(posA, rotA),
                                                         frameB=(posB, rotB))
        m_joints[JOINT_LEFT_KNEE].setLimit(0, M_PI_2)
        world.add(m_joints[JOINT_LEFT_KNEE], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_4))
        posA = vmath.vec3(0.18, -0.10, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_4))
        posB = vmath.vec3(0, 0.225, 0) * scale
        m_joints[JOINT_RIGHT_HIP] = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.m_bodies[BODYPART_PELVIS],
                                                         self.m_bodies[BODYPART_RIGHT_UPPER_LEG], frameA=(posA, rotA),
                                                         frameB=(posB, rotB))
        m_joints[JOINT_RIGHT_HIP].setLimit(M_PI_4, M_PI_4, 0)
        world.add(m_joints[JOINT_RIGHT_HIP], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posA = vmath.vec3(0, -0.225, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posB = vmath.vec3(0., 0.185, 0) * scale
        m_joints[JOINT_RIGHT_KNEE] = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE,
                                                          self.m_bodies[BODYPART_RIGHT_UPPER_LEG],
                                                          self.m_bodies[BODYPART_RIGHT_LOWER_LEG], frameA=(posA, rotA),
                                                          frameB=(posB, rotB))
        m_joints[JOINT_RIGHT_KNEE].setLimit(0, M_PI_2)
        world.add(m_joints[JOINT_RIGHT_KNEE], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI))
        posA = vmath.vec3(-0.2, 0.15, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI))
        posB = vmath.vec3(0, -0.18, 0) * scale
        m_joints[JOINT_LEFT_SHOULDER] = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.m_bodies[BODYPART_SPINE],
                                                             self.m_bodies[BODYPART_LEFT_UPPER_ARM], frameA=(posA, rotA),
                                                             frameB=(posB, rotB))
        m_joints[JOINT_LEFT_SHOULDER].setLimit(M_PI_2, M_PI_2, 0)
        world.add(m_joints[JOINT_LEFT_SHOULDER], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posA = vmath.vec3(0, 0.18, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posB = vmath.vec3(0, -0.14, 0) * scale
        m_joints[JOINT_LEFT_ELBOW] = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE,
                                                          self.m_bodies[BODYPART_LEFT_UPPER_ARM],
                                                          self.m_bodies[BODYPART_LEFT_LOWER_ARM], frameA=(posA, rotA),
                                                          frameB=(posB, rotB))
        m_joints[JOINT_LEFT_ELBOW].setLimit(-M_PI_2, 0)
        world.add(m_joints[JOINT_LEFT_ELBOW], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, 0))
        posA = vmath.vec3(0.2, 0.15, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, 0, M_PI_2))
        posB = vmath.vec3(0, -0.18, 0) * scale
        m_joints[JOINT_RIGHT_SHOULDER] = igeBullet.constraint(igeBullet.CONETWIST_CONSTRAINT_TYPE, self.m_bodies[BODYPART_SPINE],
                                                              self.m_bodies[BODYPART_RIGHT_UPPER_ARM], frameA=(posA, rotA),
                                                              frameB=(posB, rotB))
        m_joints[JOINT_RIGHT_SHOULDER].setLimit(M_PI_2, M_PI_2, 0)
        world.add(m_joints[JOINT_RIGHT_SHOULDER], True)

        rotA = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posA = vmath.vec3(0, 0.18, 0) * scale
        rotB = vmath.quat(vmath.mat_rotationZYX(3, 0, M_PI_2, 0))
        posB = vmath.vec3(0, -0.14, 0) * scale
        m_joints[JOINT_RIGHT_ELBOW] = igeBullet.constraint(igeBullet.HINGE_CONSTRAINT_TYPE,
                                                           self.m_bodies[BODYPART_RIGHT_UPPER_ARM],
                                                           self.m_bodies[BODYPART_RIGHT_LOWER_ARM], frameA=(posA, rotA),
                                                           frameB=(posB, rotB))
        m_joints[JOINT_RIGHT_ELBOW].setLimit(-M_PI_2, 0)
        world.add(m_joints[JOINT_RIGHT_ELBOW], True)

        efig.mergeSameMaterialMesh()
Ejemplo n.º 9
0
import igeBullet
from utils import Utils

utl = Utils()

devtool.convertAssets('.', '.', core.TARGET_PLATFORM_PC)
core.window(True, 480, 640)

world = igeBullet.world(True)

ground = graphicsHelper.createSprite(20.0,
                                     20.0,
                                     texture='images/Dirt-2290',
                                     normal=(0, 1, 0))
ground_shape = igeBullet.shape(igeBullet.STATIC_PLANE_PROXYTYPE,
                               normal=(0, 1, 0),
                               constant=0)
ground_body = igeBullet.rigidBody(ground_shape, 0, (0, 0, 0), (0, 0, 0, 1))
world.add(ground_body)

efig = utl.GetFigure()
efig.clearMesh()
shape = igeBullet.shape(igeBullet.SPHERE_SHAPE_PROXYTYPE, radius=1)
body2 = igeBullet.rigidBody(shape, 5, (0, 10, 0), (0, 0, 0, 1))
world.add(body2)
utl.AddShapeMesh(shape)

char = Character(world)
cam = TargetCamera()
controller = Controller()
Ejemplo n.º 10
0
import igeBullet
import os
from utils import Utils
import igeVmath as vmath

from igeCore import devtool
devtool.convertAssets('.', '.', core.TARGET_PLATFORM_MOBILE)

utl = Utils()
core.window(True, 480, 640)

world = igeBullet.world(True)

efig = utl.GetFigure()
efig.clearMesh()
shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE, halfExtents=(15, 2, 15))
body1 = igeBullet.rigidBody(shape, 0, (0, 0, 0), (0, 0, 0, 1))
world.add(body1)
utl.AddShapeMesh(shape)

shape = igeBullet.shape(igeBullet.BOX_SHAPE_PROXYTYPE, halfExtents=(3, 3, 3))
body2 = igeBullet.rigidBody(shape, 5, (5, 8, 0), (0, 0, 0, 1))
world.add(body2)
utl.AddShapeMesh(shape)

sphere = core.figure('box')
poss = sphere.getVertexElements(0, core.ATTRIBUTE_ID_POSITION)
tris = sphere.getTriangles(0)
soft = igeBullet.softBody(world, poss, tris, mass=5.5, springStiffness=50.0)
soft.transform = ((0, 30, 0), (0, 0, 0, 1))