Examples of RigidBodyConstructionInfo


Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

        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);
        balls.add(controlBall);
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

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

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

        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;
        ballConstructionInfo.angularDamping = 0.95f;
        // Initialise 'controlBall', the final variable representing the controlled ball, to a rigid body with the
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

            // 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);
            createNewShape = false;
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

        centreOfMass.z);
    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);

    this.startWorldTransform = startTransform;
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
        myMotionState, trimesh, localInertia);
    rigidBody = new RigidBody(rbInfo);
    Transform center = new Transform();
    center.origin.set(centreOfMass.x, centreOfMass.y, centreOfMass.z);
    rigidBody.setCenterOfMassTransform(center);
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

    // using motionstate is recommended, it provides interpolation
    // capabilities, and only synchronizes 'active' objects
    DefaultMotionState myMotionState2 = new DefaultMotionState(
        planeTransform);
    RigidBodyConstructionInfo rbInfo2 = new RigidBodyConstructionInfo(0,
        myMotionState2, constrainPlane, localInertia2);
    RigidBody body2 = new RigidBody(rbInfo2);
    this.constrainPlane2D = body2;

    // We can also use DemoApplication::localCreateRigidBody, but for
    // clarity it is provided here:
    {
      float mass = 0f;

      // rigidbody is dynamic if and only if mass is non zero, otherwise
      // static
      boolean isDynamic = (mass != 0f);

      Vector3f localInertia = new Vector3f(0, 0, 0);
      if (isDynamic) {
        groundShape.calculateLocalInertia(mass, localInertia);
      }

      // using motionstate is recommended, it provides interpolation
      // capabilities, and only synchronizes 'active' objects
      DefaultMotionState myMotionState = new DefaultMotionState(
          groundTransform);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
          mass, myMotionState, groundShape, localInertia);
       groundBody = new RigidBody(rbInfo);

      this.addGround();
     
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

      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);

    ownerWorld.addRigidBody(body);
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

      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);

    ownerWorld.addRigidBody(body);
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

      transform.origin.set(new Vector3f(0, -10, 0));

      // Create new MotionState to keep track of object.
      DefaultMotionState motionState = new DefaultMotionState(transform);
      Vector3f localInertia = new Vector3f(0, 0, 0);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(0,
          motionState, groundShape, localInertia);

      // Create the rigid body and add it to the dynamicsworld.
      RigidBody body = new RigidBody(rbInfo);
      getDynamicsWorld().addRigidBody(body);

      // Set friction.
      //body.setFriction(1);

      // Store locally.
      this.ground = body;

    }

    else {
      System.out.println("Using chess surface ground");
      BoxShape bShape = new BoxShape(new Vector3f(20, 10, 20));

      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 21; j++) {
          // Create transform to store ground's location.
          Transform transform = new Transform();
          transform.setIdentity();
          float x = -10 * 40 + i * 40;
          float z = -10 * 40 + j * 40;
          transform.origin.set(new Vector3f(x, -10, z));

          // Create new MotionState to keep track of object.
          DefaultMotionState motionState = new DefaultMotionState(
              transform);
          Vector3f localInertia = new Vector3f(0, 0, 0);
          RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
              0, motionState, bShape, localInertia);

          // Create the rigid body and add it to the dynamicsworld.
          RigidBody body = new RigidBody(rbInfo);
          getDynamicsWorld().addRigidBody(body);
View Full Code Here

Examples of com.bulletphysics.dynamics.RigidBodyConstructionInfo

      this.collisionShape.calculateLocalInertia(mass, localInertia);
    }
   
    DefaultMotionState myMotionState = new DefaultMotionState(transform);
   
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
        mass, myMotionState, collisionShape, localInertia);
   
    body = new RigidBody(rbInfo);

    // Add the body to the dynamics world.
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.