Class Physics


  • public class Physics
    extends Object
    Class that contains someuseful jbullet methods
    Author:
    Darius Dinger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static float GRAVITY_OF_EARTH  
    • Constructor Summary

      Constructors 
      Constructor Description
      Physics()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.bulletphysics.collision.shapes.ConvexHullShape createConvexHullShape​(float[] vertices)
      Creating a convex hull shape from vertices.
      static com.bulletphysics.dynamics.DynamicsWorld createDynamicsWorld​(float gravity)
      Creating a default JBullet dynamics world
      static com.bulletphysics.dynamics.RigidBody createRigidBody​(float mass, com.bulletphysics.collision.shapes.CollisionShape shape, boolean rotate)
      Creating new RigidBody with a specific shape.
      static com.bulletphysics.dynamics.RigidBody createTerrainRigidBody()
      Create new terrain rigid body.
      static com.bulletphysics.collision.shapes.BvhTriangleMeshShape createTriangleMeshShape​(float[] vertices, int[] indices)
      Creates a collision shape for a triangle mesh shape.
      static com.bulletphysics.collision.shapes.BvhTriangleMeshShape createTriangleMeshShape​(float[] vertices, int[][] indices)
      Creates a collision shape for a triangle mesh shape.
      static void scaleRigidBody​(com.bulletphysics.dynamics.RigidBody body, float sx, float sy, float sz, com.bulletphysics.dynamics.DynamicsWorld physicWorld)
      Scaling a rigidbody in a dynamics world
    • Constructor Detail

      • Physics

        public Physics()
    • Method Detail

      • createDynamicsWorld

        public static com.bulletphysics.dynamics.DynamicsWorld createDynamicsWorld​(float gravity)
        Creating a default JBullet dynamics world
        Parameters:
        gravity - Gravity of the world
        Returns:
        Created dynamics world
      • createTriangleMeshShape

        public static com.bulletphysics.collision.shapes.BvhTriangleMeshShape createTriangleMeshShape​(float[] vertices,
                                                                                                      int[][] indices)
        Creates a collision shape for a triangle mesh shape. Only for static objects!
        Parameters:
        vertices - 3D vertices of the body
        indices - Indices that connect the vertices
        Returns:
        Created triangle mesh shaped rigid body
      • createTriangleMeshShape

        public static com.bulletphysics.collision.shapes.BvhTriangleMeshShape createTriangleMeshShape​(float[] vertices,
                                                                                                      int[] indices)
        Creates a collision shape for a triangle mesh shape. Only for static objects!
        Parameters:
        vertices - 3D vertices of the body
        indices - Indices that connect the vertices
        Returns:
        Created triangle mesh shaped rigid body
      • createConvexHullShape

        public static com.bulletphysics.collision.shapes.ConvexHullShape createConvexHullShape​(float[] vertices)
        Creating a convex hull shape from vertices. Also posible for dynamic objects.
        Parameters:
        vertices - Vertex positions of the convex hull
        Returns:
        Create convex hull shape
      • createRigidBody

        public static com.bulletphysics.dynamics.RigidBody createRigidBody​(float mass,
                                                                           com.bulletphysics.collision.shapes.CollisionShape shape,
                                                                           boolean rotate)
        Creating new RigidBody with a specific shape. A mass of zero means static object.
        Parameters:
        mass - Mass of the body (or zero for a static body)
        shape - Shape of the body
        rotate - Can the body rotate
        Returns:
        Created rigidy body
      • createTerrainRigidBody

        public static com.bulletphysics.dynamics.RigidBody createTerrainRigidBody()
        Create new terrain rigid body.
        Returns:
        Created terrain rigid body
      • scaleRigidBody

        public static void scaleRigidBody​(com.bulletphysics.dynamics.RigidBody body,
                                          float sx,
                                          float sy,
                                          float sz,
                                          com.bulletphysics.dynamics.DynamicsWorld physicWorld)
        Scaling a rigidbody in a dynamics world
        Parameters:
        body - Rigidbody to scale
        sx - X Scale of the rigid body
        sy - Y Scale of the rigid body
        sz - Z Scale of the rigid body
        physicWorld - Dynamic world, the rigid body belongs to