Package com.bulletphysics.linearmath

Examples of com.bulletphysics.linearmath.DefaultMotionState


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

    DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
    RigidBody body = new RigidBody(rbInfo);

    ownerWorld.addRigidBody(body);
View Full Code Here


    // using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects

    //#define USE_MOTIONSTATE 1
    //#ifdef USE_MOTIONSTATE
    DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
   
    RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
   
    RigidBody body = new RigidBody(cInfo);
    //#else
View Full Code Here

      for (int i = 0; i < numObjects; i++) {
        CollisionObject colObj = dynamicsWorld.getCollisionObjectArray().getQuick(i);
        RigidBody body = RigidBody.upcast(colObj);

        if (body != null && body.getMotionState() != null) {
          DefaultMotionState myMotionState = (DefaultMotionState) body.getMotionState();
          m.set(myMotionState.graphicsWorldTrans);
        }
        else {
          colObj.getWorldTransform(m);
        }
View Full Code Here

    for (int i = 0; i < numObjects; i++) {
      CollisionObject colObj = dynamicsWorld.getCollisionObjectArray().getQuick(i);
      RigidBody body = RigidBody.upcast(colObj);
      if (body != null) {
        if (body.getMotionState() != null) {
          DefaultMotionState myMotionState = (DefaultMotionState) body.getMotionState();
          myMotionState.graphicsWorldTrans.set(myMotionState.startWorldTrans);
          colObj.setWorldTransform(myMotionState.graphicsWorldTrans);
          colObj.setInterpolationWorldTransform(myMotionState.startWorldTrans);
          colObj.activate();
        }
View Full Code Here

        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);
      RigidBody body = new RigidBody(rbInfo);

      // add the body to the dynamics world
      dynamicsWorld.addRigidBody(body);
    }

    {
      // create a dynamic rigidbody

      // btCollisionShape* colShape = new
      // btBoxShape(btVector3(1,1,1));
      CollisionShape colShape = new SphereShape(1.f);
      collisionShapes.add(colShape);

      // Create Dynamic Objects
      Transform startTransform = new Transform();
      startTransform.setIdentity();

      float mass = 1f;

      // 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) {
        colShape.calculateLocalInertia(mass, localInertia);
      }

      startTransform.origin.set(new Vector3f(2, 10, 0));

      // using motionstate is recommended, it provides
      // interpolation capabilities, and only synchronizes
      // 'active' objects
      DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
          mass, myMotionState, colShape, localInertia);
      RigidBody body = new RigidBody(rbInfo);

View Full Code Here

      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);
      RigidBody body = new RigidBody(rbInfo);

      // add the body to the dynamics world
      dynamicsWorld.addRigidBody(body);
    }

    {
      // create a few dynamic rigidbodies
      // Re-using the same collision is better for memory usage and performance

      CollisionShape colShape = new BoxShape(new Vector3f(1, 1, 1));
      //CollisionShape colShape = new SphereShape(1f);
      collisionShapes.add(colShape);

      // Create Dynamic Objects
      Transform startTransform = new Transform();
      startTransform.setIdentity();

      float mass = 1f;

      // 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) {
        colShape.calculateLocalInertia(mass, localInertia);
      }

      float start_x = START_POS_X - ARRAY_SIZE_X / 2;
      float start_y = START_POS_Y;
      float start_z = START_POS_Z - ARRAY_SIZE_Z / 2;

      for (int k = 0; k < ARRAY_SIZE_Y; k++) {
        for (int i = 0; i < ARRAY_SIZE_X; i++) {
          for (int j = 0; j < ARRAY_SIZE_Z; j++) {
            startTransform.origin.set(
                2f * i + start_x,
                10f + 2f * k + start_y,
                2f * j + start_z);

            // using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);
            body.setActivationState(RigidBody.ISLAND_SLEEPING);

            dynamicsWorld.addRigidBody(body);
View Full Code Here

        liquidWrapper = new PhysicsLiquidWrapper(world);
        VoxelWorldShape liquidShape = new VoxelWorldShape(liquidWrapper);

        Matrix3f rot = new Matrix3f();
        rot.setIdentity();
        DefaultMotionState blockMotionState = new DefaultMotionState(new Transform(new Matrix4f(rot, new Vector3f(0, 0, 0), 1.0f)));
        RigidBodyConstructionInfo blockConsInf = new RigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());
        BulletRigidBody rigidBody = new BulletRigidBody(blockConsInf);
        rigidBody.rb.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.rb.getCollisionFlags());
        short mask = (short) (~(CollisionFilterGroups.STATIC_FILTER | StandardCollisionGroup.LIQUID.getFlag()));
        discreteDynamicsWorld.addRigidBody(rigidBody.rb, combineGroups(StandardCollisionGroup.WORLD), mask);
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.