com.badlogic.gdx.physics.bullet.Bullet Java Examples

The following examples show how to use com.badlogic.gdx.physics.bullet.Bullet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameObjectBlueprint.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
public GameObjectBlueprint(BlenderModel blenderModel, Model model) {
	this.model = model;
	setFromObject(blenderModel);
	this.mass = 0;
	ModelInstance modelInstance = new ModelInstance(model);
	GameModel.applyTransform(position, rotation, blenderModel.scale, modelInstance);

	this.shape = Bullet.obtainStaticNodeShape(modelInstance.nodes);
	this.shapeType = "static_node_shape_" + blenderModel.name;
	setCollisionFlags(this.mass);
}
 
Example #2
Source File: MenuScene.java    From Skyland with MIT License 5 votes vote down vote up
@Override
public void show() {
    Bullet.init();
    init3d();
    initScene2d();
    initRayCastListener();
}
 
Example #3
Source File: Builder.java    From Skyland with MIT License 5 votes vote down vote up
private static void buildCave(Matrix4 transform) {
    Model caveModel = Assets.get(CURR_MODEL, Model.class);
    if (WORLD.getConstructor("cave") == null) {
        for (Node n : caveModel.nodes) n.scale.set(.6f, .6f, .6f);
        btCollisionShape collisionShape = Bullet.obtainStaticNodeShape(caveModel.nodes);
        collisionShape.setLocalScaling(new Vector3(.6f, .6f, .6f));
        WORLD.addConstructor("cave", new BulletConstructor(caveModel, 0, collisionShape));
    }
    BulletEntity cave = WORLD.add("cave", transform);
    cave.body.setCollisionFlags(cave.body.getCollisionFlags()
            | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
    cave.body.setActivationState(Collision.DISABLE_DEACTIVATION);
    cave.body.userData = new BulletUserData("cave", cave);
}
 
Example #4
Source File: WorldGenerator.java    From Skyland with MIT License 5 votes vote down vote up
public static BulletWorld generateBaseWorld(boolean grid, boolean debug) {
    BulletWorld world = new BulletWorld(new Vector3(0, -9.81f, 0));
    Builder.init(world); //Sets the stuff so you can use Builder class

    if (debug)
        world.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_DrawWireframe | btIDebugDraw.DebugDrawModes.DBG_DrawFeaturesText | btIDebugDraw.DebugDrawModes.DBG_DrawText | btIDebugDraw.DebugDrawModes.DBG_DrawContactPoints);
    if (grid)
        world.add(new BulletEntity(ModelGenerator.generateAxis(-10, 10, 1), null));

    btCollisionShape collisionShape = Bullet.obtainStaticNodeShape(Assets.get(Models.MODEL_ISLAND_PROTOTYPE, Model.class).nodes.first(), true);
    world.addConstructor("island", new BulletConstructor(Assets.get(Models.MODEL_ISLAND_PROTOTYPE, Model.class), 0, collisionShape));
    return world;
}
 
Example #5
Source File: Physics.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
public Physics() {
	Bullet.init();
	shapes = new Array<>();
	objects = new Array<>();
	disposables = new Array<>();
	if (Main.isClient()) {
		debugDrawer = new DebugDrawer();
		debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE);
	}
	inst = this;
	collisionConfig = new btDefaultCollisionConfiguration();
	dispatcher = new btCollisionDispatcher(collisionConfig);
	broadphaseInterface = new btDbvtBroadphase();
	// TODO is it worth comparing performance with other broadphase types?
	//broadphaseInterface = new btSimpleBroadphase();
	//broadphaseInterface = new btAxisSweep3(tmp.set(0f, -10, 0f), tmp2.set(GameWorld.WORLD_WIDTH, 200f, GameWorld.WORLD_DEPTH));
	world = new btCollisionWorld(dispatcher, broadphaseInterface, collisionConfig);
	if (Main.isClient()) {
		world.setDebugDrawer(debugDrawer);
	}
	contactListener = new MyContactListener();

	disposables.add(world);
	if (debugDrawer != null) {
		disposables.add(debugDrawer);
	}
	disposables.add(collisionConfig);
	disposables.add(dispatcher);
	disposables.add(broadphaseInterface);
	disposables.add(contactListener);
}
 
Example #6
Source File: BulletSteeringTest.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
public static void init () {
	if (initialized) return;
	// Need to initialize bullet before using it.
	if (Gdx.app.getType() == ApplicationType.Desktop && customDesktopLib != null) {
		System.load(customDesktopLib);
	} else
		Bullet.init();
	Gdx.app.log("Bullet", "Version = " + LinearMath.btGetVersion());
	initialized = true;
}