Package com.bulletphysics.linearmath

Examples of com.bulletphysics.linearmath.DefaultMotionState


        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;
View Full Code Here


            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);
View Full Code Here

        PhysicsSphere(Vector4f colour, Vector3f position, DynamicsWorld physicsWorld, float mass, float radius, int slices, int stacks) {
            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

        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);
View Full Code Here

        // 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;
View Full Code Here

        PhysicsSphere(Vector4f colour, Vector3f position, DynamicsWorld physicsWorld, float mass, float radius, int slices, int stacks) {
            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

    localInertia.set(0f, 0f, 0f);
    if (isDynamic) {
      shape.calculateLocalInertia(mass, localInertia);
    }

    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
        myMotionState, shape, localInertia);
    rbInfo.additionalDamping = true;
    RigidBody body = new RigidBody(rbInfo);
View Full Code Here

    transform.set(new Matrix4f(0.999522f, -0.02457619f, 0.01875775f,
        103.311295f, 0.03083701f, 0.83602184f, -0.547829f,
        22.693146f * this.scale, -0.0022183368f, 0.5481455f, 0.83638f,
        -1.0370132f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_HEAD.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_SPINE
    bodies[BodyPart.BODYPART_SPINE.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.9932064f, 0.116363324f, 7.786779E-4f,
        104.067566f, -0.1162641f, 0.99203515f, 0.04846615f,
        31.873365f * this.scale, 0.004867207f, -0.048227426f,
        0.99882454f, 0.0021075667f * this.scale, 0.0f, 0.0f, 0.0f,
        1.0f * this.scale));
    bodies[BodyPart.BODYPART_SPINE.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_PELVIS
    bodies[BodyPart.BODYPART_PELVIS.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.9835286f, 0.17898695f, -0.025202362f,
        105.264946f, -0.18059899f, 0.97884035f, -0.09620573f,
        40.34729f * this.scale, 0.007449517f, 0.099172615f, 0.9950424f,
        0.04683579f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_PELVIS.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_LEFT_UPPER_LEG
    bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.29188365f, 0.9564537f, -4.4153258E-4f,
        109.79127f, -0.9526396f, 0.29067844f, -0.0893526f,
        44.345417f * this.scale, -0.08533329f, 0.026501186f,
        0.99599993f, 3.9808998f * this.scale, 0.0f, 0.0f, 0.0f,
        1.0f * this.scale));
    bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_LEFT_LOWER_LEG
    bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.9873329f, -0.15865491f, 0.0015572663f,
        115.62421f, 0.15813647f, 0.98321307f, -0.09102161f,
        52.051834f * this.scale, 0.012909901f, 0.09011489f, 0.9958477f,
        4.6894903f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //RIGHT_UPPER_LEG
    bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.23838913f, 0.9675928f, -0.08327571f,
        110.01697f, -0.9671425f, 0.22872531f, -0.110996194f,
        44.76596f * this.scale, -0.08835185f, 0.10699976f, 0.9903257f,
        -2.6929f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_RIGHT_LOWER_LEG
    bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.9864584f, -0.14225316f, -0.081632055f,
        116.022156f, 0.13265687f, 0.98470926f, -0.11291519f,
        52.043633f * this.scale, 0.09644639f, 0.10055709f, 0.9902456f,
        -1.3562305f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_RIGHT_FOOT
    bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(0.00923717f, 0.9967484f, -0.080045804f,
        116.96003f, -0.99355465f, 1.0448694E-4f, -0.11335374f,
        57.707912f * this.scale, -0.11297679f, 0.08057695f, 0.990325f,
        -0.6338565f * this.scale, 0.0f, 0.0f, 0.0f, 1.0f * this.scale));
    bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    //BODYPART_LEFT_FOOT
    bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.setIdentity();
    transform.set(new Matrix4f(-3.4880638E-4f, 0.99999404f, 0.0034378879f,
        116.47286f, -0.9958018f, -3.2663345E-5f, -0.09153569f,
        57.707455f * this.scale, -0.09153503f, -0.0034553856f,
        0.99579585f, 5.203514f * this.scale, 0.0f, 0.0f, 0.0f,
        1.0f * this.scale));
    bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]
        .setMotionState(new DefaultMotionState(transform));

    // Setup some damping on the m_bodies
    for (int i = 0; i < BodyPart.BODYPART_COUNT.ordinal(); ++i) {
      if (bodies[i] != null) {
        bodies[i].setDamping(0.5f, 9.95f);
View Full Code Here

        this.rigidBody.getMotionState().getWorldTransform(
            currentWorldTransform).origin.y,
        this.rigidBody.getMotionState().getWorldTransform(
            currentWorldTransform).origin.z);

    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);

    this.startWorldTransform = startTransform;
  }
View Full Code Here

    Vector3f localInertia = new Vector3f(0, 0, 0);
    float mass = this.getMass();
    trimesh.calculateLocalInertia(mass, localInertia);
    startTransform.origin.set(centreOfMass.x, centreOfMass.y,
        centreOfMass.z);
    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);

    this.startWorldTransform = startTransform;
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
        myMotionState, trimesh, localInertia);
View Full Code Here

TOP

Related Classes of com.bulletphysics.linearmath.DefaultMotionState

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.