Examples of MotionState


Examples of com.bulletphysics.linearmath.MotionState

        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

Examples of com.bulletphysics.linearmath.MotionState

        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

Examples of com.bulletphysics.linearmath.MotionState

        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

Examples of com.bulletphysics.linearmath.MotionState

        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

Examples of com.bulletphysics.linearmath.MotionState

      if (this.rigidBody == null || trimesh == null)
        return;

      Transform transform = new Transform();
      MotionState motionstate = rigidBody.getMotionState();
      motionstate.getWorldTransform(transform);
      Matrix4f chairMatrix = new Matrix4f();
      transform.getMatrix(chairMatrix);
      //  LOGGER.debug("current origin"+transform.origin.toString());

      //this is overwritten when settign the chair matrix
      //transform.origin.set(this.centreOfMass.x, this.centreOfMass.y,
      //    this.centreOfMass.z);

      LOGGER.debug("delta x" + deltaCentreOfmass.x);
      LOGGER.debug("delta y" + deltaCentreOfmass.y);
      LOGGER.debug("delta z" + deltaCentreOfmass.z);

      float newX = ((chairMatrix.m00) * deltaCentreOfmass.x)
          + ((chairMatrix.m01) * deltaCentreOfmass.y)
          + ((chairMatrix.m02) * deltaCentreOfmass.z);
      float newY = (((chairMatrix.m10) * deltaCentreOfmass.x)
          + ((chairMatrix.m11) * deltaCentreOfmass.y) + ((chairMatrix.m12) * deltaCentreOfmass.z));
      float newZ = ((chairMatrix.m20) * deltaCentreOfmass.x)
          + ((chairMatrix.m21) * deltaCentreOfmass.y)
          + ((chairMatrix.m22) * deltaCentreOfmass.z);

      //these are the origin
      chairMatrix.m03 -= deltaCentreOfmass.x;//10;//deltaCentreOfmass.x;
      chairMatrix.m13 -= deltaCentreOfmass.y;//deltaCentreOfmass.y;
      chairMatrix.m23 += deltaCentreOfmass.z;//deltaCentreOfmass.z;

      //chairMatrix.m03 = this.centreOfMass.x;
      //chairMatrix.m13 = this.centreOfMass.y;
      //chairMatrix.m23 = this.centreOfMass.z;

      LOGGER.debug("delta x t " + newX);
      LOGGER.debug("delta y t " + newY);
      LOGGER.debug("delta z t " + newZ);

      transform.set(chairMatrix);
      motionstate.setWorldTransform(transform);
      rigidBody.setMotionState(motionstate);

      Vector3f center = new Vector3f();
      rigidBody.getCenterOfMassPosition(center);
      LOGGER.debug("getCenterOfMassPosition set " + center);

      // System.out.println("weight" + this.getArea());
      Vector3f AngularVelocity = new Vector3f(0, 0, 0);
      rigidBody.getAngularVelocity(AngularVelocity);

      Vector3f LinearVelocity = new Vector3f(0, 0, 0);
      rigidBody.getLinearVelocity(LinearVelocity);

      GLOBAL.jBullet.update();

      motionstate.getWorldTransform(transform);
      //  LOGGER.debug("new origin"+transform.origin.toString());

      //this.translate(-newX, newY, newZ);

      // rigidBody.setAngularVelocity(AngularVelocity);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.