Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.CollisionShape


        CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
        CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
        ConstraintSolver solver = new SequentialImpulseConstraintSolver();
        dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
        dynamicsWorld.setGravity(new Vector3f(0, -10 /* m/s2 */, 0));
        CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0.25f /* m */);
        CollisionShape ballShape = new SphereShape(3.0f);
        MotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(
                new Quat4f(0, 0, 0, 1),
                new Vector3f(0, 0, 0), 1.0f)));
        RigidBodyConstructionInfo groundBodyConstructionInfo = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
        groundBodyConstructionInfo.restitution = 0.25f;
        RigidBody groundRigidBody = new RigidBody(groundBodyConstructionInfo);
        dynamicsWorld.addRigidBody(groundRigidBody);
        MotionState ballMotionState = new DefaultMotionState(DEFAULT_BALL_TRANSFORM);
        Vector3f ballInertia = new Vector3f(0, 0, 0);
        ballShape.calculateLocalInertia(2.5f, ballInertia);
        RigidBodyConstructionInfo ballConstructionInfo = new RigidBodyConstructionInfo(2.5f, ballMotionState, ballShape, ballInertia);
        ballConstructionInfo.restitution = 0.5f;
        ballConstructionInfo.angularDamping = 0.95f;
        controlBall = new RigidBody(ballConstructionInfo);
        controlBall.setActivationState(CollisionObject.DISABLE_DEACTIVATION);
View Full Code Here


            force.sub(cameraPosition, controlBallLocation);
            controlBall.activate(true);
            controlBall.applyCentralForce(force);
        }
        if (createNewShape) {
            CollisionShape shape = new SphereShape(3.0f);
            DefaultMotionState motionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(camera.x(), 35, camera.z()), 1)));
            Vector3f inertia = new Vector3f();
            shape.calculateLocalInertia(1.0f, inertia);
            RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(1.0f, motionState, shape, inertia);
            constructionInfo.restitution = 0.75f;
            RigidBody body = new RigidBody(constructionInfo);
            dynamicsWorld.addRigidBody(body);
            balls.add(body);
View Full Code Here

            this.colour = colour;
            this.radius = radius;
            this.slices = slices;
            this.stacks = stacks;
            MotionState motion = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), position, 1.0f)));
            CollisionShape shape = new SphereShape(radius);
            this.physicsBody = new RigidBody(mass, motion, shape);
            this.physicsWorld = physicsWorld;
            this.physicsWorld.addRigidBody(physicsBody);
            this.renderSphere = new org.lwjgl.util.glu.Sphere();
        }
View Full Code Here

        // zero.
        dynamicsWorld.setGravity(new Vector3f(0, -10, 0));
        // Initialise 'groundShape' to a static plane shape on the origin facing upwards ([0, 1, 0] is the normal).
        // 0.25 metres is an added buffer between the ground and potential colliding bodies, used to prevent the bodies
        // from partially going through the floor. It is also possible to think of this as the plane being lifted 0.25m.
        CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0.25f);
        // Initialise 'ballShape' to a sphere with a radius of 3 metres.
        CollisionShape ballShape = new SphereShape(3);
        // Initialise 'groundMotionState' to a motion state that simply assigns the origin [0, 0, 0] as the origin of
        // the ground.
        MotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, 0, 0), 1.0f)));
        // Initialise 'groundBodyConstructionInfo' to a value that contains the mass, the motion state, the shape, and the inertia (= resistance to change).
        RigidBodyConstructionInfo groundBodyConstructionInfo = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
        // Set the restitution, also known as the bounciness or spring, to 0.25. The restitution may range from 0.0
        // not bouncy) to 1.0 (extremely bouncy).
        groundBodyConstructionInfo.restitution = 0.25f;
        // Initialise 'groundRigidBody', the final variable representing the ground, to a rigid body with the previously
        // assigned construction information.
        RigidBody groundRigidBody = new RigidBody(groundBodyConstructionInfo);
        // Add the ground to the JBullet world.
        dynamicsWorld.addRigidBody(groundRigidBody);
        // Initialise 'ballMotion' to a motion state that assigns a specified location to the ball.
        MotionState ballMotion = new DefaultMotionState(new Transform(DEFAULT_BALL_TRANSFORM));
        // Calculate the ball's inertia (resistance to movement) using its mass (2.5 kilograms).
        Vector3f ballInertia = new Vector3f(0, 0, 0);
        ballShape.calculateLocalInertia(2.5f, ballInertia);
        // Composes the ball's construction info of its mass, its motion state, its shape, and its inertia.
        RigidBodyConstructionInfo ballConstructionInfo = new RigidBodyConstructionInfo(2.5f, ballMotion, ballShape, ballInertia);
        // Set the restitution, also known as the bounciness or spring, to 0.5. The restitution may range from 0.0
        // not bouncy) to 1.0 (extremely bouncy).
        ballConstructionInfo.restitution = 0.5f;
View Full Code Here

            controlBall.applyCentralForce(force);
        }
        // If a new shape should be created ...
        if (createNewShape) {
            // Create the collision shape (sphere with radius of 3 metres).
            CollisionShape shape = new SphereShape(3);
            // Create the motion state (x and z are the same as the camera's).
            DefaultMotionState motionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(camera.x(), 35, camera.z()), 1.0f)));
            // Calculate the inertia (resistance to movement) using the ball's mass of 1 kilogram.
            Vector3f inertia = new Vector3f(0, 0, 0);
            shape.calculateLocalInertia(1.0f, inertia);
            RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(1, motionState, shape, inertia);
            constructionInfo.restitution = 0.75f;
            RigidBody rigidBody = new RigidBody(constructionInfo);
            balls.add(rigidBody);
            dynamicsWorld.addRigidBody(rigidBody);
View Full Code Here

            this.colour = colour;
            this.radius = radius;
            this.slices = slices;
            this.stacks = stacks;
            MotionState motion = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), position, 1.0f)));
            CollisionShape shape = new SphereShape(radius);
            this.physicsBody = new RigidBody(mass, motion, shape);
            this.physicsWorld = physicsWorld;
            this.physicsWorld.addRigidBody(physicsBody);
            this.renderSphere = new org.lwjgl.util.glu.Sphere();
        }
View Full Code Here

    myWorld.setGravity(new Vector3f(0f, 3, 0f));

    // create a few basic rigid bodies
    // CollisionShape groundShape = new BoxShape(new Vector3f(50f, 50f,
    // 50f));
    CollisionShape groundShape = new StaticPlaneShape(
        new Vector3f(0, -1, 0), 1);

    collisionShapes.add(groundShape);

    Transform groundTransform = new Transform();
    groundTransform.setIdentity();
    groundTransform.origin.set(this.scaleVal(600), this.scaleVal(1600),
        this.scaleVal(600));

    CollisionShape constrainPlane = new StaticPlaneShape(new Vector3f(0, 0,
        1), 1);

    Vector3f localInertia2 = new Vector3f(0, 0, 0);
    Transform planeTransform = new Transform();
    planeTransform.setIdentity();
View Full Code Here

      // rBody.
      // System.out.println(myTransform.origin.y);
      // fill(fallRigidBody.c);
      // do the actual drawing of the object

      CollisionShape col = rBody.getCollisionShape();
      //if (col.isPolyhedral()) {
        Vector3f posP = new Vector3f();
        float[] sizeP = { 0 };
        col.getBoundingSphere(posP, sizeP);
        g.pushMatrix();
        g.translate(posP.x, posP.y, posP.z);
        g.sphere(sizeP[0]);
        g.popMatrix();

      //}

      if (col.getShapeType() == BroadphaseNativeType.GIMPACT_SHAPE_PROXYTYPE) {

        ConcaveShape polyshape = (ConcaveShape) col;
        /*
        int i;
        for (i=0;i<polyshape.getNumEdges();i++)
        {
          Vector3f a = Stack.alloc(Vector3f.class);
          Vector3f b = Stack.alloc(Vector3f.class);;
          polyshape.getEdge(i,a,b);
          Vector3f tmp2 = new Vector3f(0f, 0f, 1f);

          debugD.drawLine(a, b, tmp2);
        //          getDebugDrawer()->drawLine(wa,wb,color);
        //
        }
        */
        //
        //
      }

      if (col.getShapeType() == BroadphaseNativeType.CAPSULE_SHAPE_PROXYTYPE) {
        Vector3f pos = new Vector3f();
        // System.out.println("capsula");
        float[] size = { 0 };
        //col.getAabb(t, aabbMin, aabbMax)
        col.getBoundingSphere(pos, size);
        g.pushMatrix();
        g.translate(pos.x, pos.y, pos.z);
        g.box(05, (int) (size[0] * 1.5), 05);
        g.popMatrix();

View Full Code Here

      localA.origin.set(0f, 0f, 0f);

      localB.origin.set(0f, 0f, 0f);

      CollisionShape ZeroShape = null;
      GLOBAL.jBullet.ZeroBody = new RigidBody(0.0f, null, ZeroShape);

      Transform Rotation = new Transform();
      Rotation.setIdentity();
      GLOBAL.jBullet.ZeroBody.setWorldTransform(Rotation);
View Full Code Here

      localA.origin.set(0f, 0f, 0f);

      localB.origin.set(0f, 0f, 0f);

      CollisionShape ZeroShape = null;
      GLOBAL.jBullet.ZeroBody = new RigidBody(0.0f, null, ZeroShape);

      Transform Rotation = new Transform();
      Rotation.setIdentity();
      GLOBAL.jBullet.ZeroBody.setWorldTransform(Rotation);
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.shapes.CollisionShape

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.