Java 类com.badlogic.gdx.physics.bullet.Bullet 实例源码
项目:gdx-bullet-gwt
文件:GwtBullet.java
public static void init()
{
if(init)
return;
init = true;
String javaScript = "ammo.js";
final String js = GWT.getModuleBaseForStaticFiles() + javaScript;
ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>()
{
@Override
public void onFailure(Exception e)
{
GWT.log("inject " + js + " failure " + e);
}
@Override
public void onSuccess(Void ok)
{
Bullet.initVariables();
}
}).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:Argent
文件:BulletEntity.java
public void reconstructBody() {
if(body != null) {
body.dispose();
body = null;
}
btCollisionShape shape = Bullet.obtainStaticNodeShape(gameWorld.renderer().getRenderable(this).nodes);
if(shape != null)
gameWorld.renderer().buildBulletCollision(this, shape);
if(body != null) {
btMotionState state = body.getMotionState();
if(state instanceof DefaultMotionState) {
((DefaultMotionState)state).transform = this.transform;
}
}
switch(physicsState) {
case STATIC: setStatic(); break;
case KINEMATIC: setKinematic(); break;
case DYNAMIC: setDynamic(); break;
}
body.setWorldTransform(transform);
gameWorld.addInstance(this);
}
项目:eamaster
文件:SimulationRunner.java
public SimulationRunner() {
logger.info("Loading models");
ModelBuilder builder = new ModelBuilder();
models.put("box", builder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));
Bullet.init();
logger.info("Initialized Bullet");
}
项目:gdx-bullet-gwt
文件:GwtBullet.java
public static void init()
{
if(init)
return;
init = true;
String javaScript = "ammo.js";
final String js = GWT.getModuleBaseForStaticFiles() + javaScript;
ScriptInjector.fromUrl(js).setCallback(new Callback<Void, Exception>()
{
@Override
public void onFailure(Exception e)
{
GWT.log("inject " + js + " failure " + e);
}
@Override
public void onSuccess(Void ok)
{
Bullet.initVariables();
}
}).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
项目:warp
文件:PhysicsTask.java
@Override
protected void onInit() {
logger.info("initializing physics");
new SharedLibraryLoader().load("gdx");
Bullet.init();
createPhysicsWorld();
rayTestSolver.setWorld(mainWorld);
}
项目:nhglib
文件:PhysicsSystem.java
private void initPhysics() {
Bullet.init();
collisionConfiguration = new btDefaultCollisionConfiguration();
collisionDispatcher = new btCollisionDispatcher(collisionConfiguration);
dbvtBroadphase = new btDbvtBroadphase();
constraintSolver = new btSequentialImpulseConstraintSolver();
dynamicsWorld = new btDiscreteDynamicsWorld(collisionDispatcher, dbvtBroadphase, constraintSolver, collisionConfiguration);
dynamicsWorld.setGravity(new Vector3(0f, -1f, 0f));
physicsInitialized = true;
}
项目:Argent
文件:PhysicsCore.java
public <T> void buildComplexCollisionMesh(WorldRenderer<T> renderer, T obj) {
ModelInstance inst = renderer.getRenderable(obj);
if(inst == null) return;
btCollisionShape shape = Bullet.obtainStaticNodeShape(inst.model.nodes);
if(shape != null)
renderer.buildBulletCollision(obj, shape);
}
项目:Argent
文件:PhysicsCore.java
public btCollisionObject buildComplexCollisionMesh(ModelInstance inst) {
btCollisionShape shape = Bullet.obtainStaticNodeShape(inst.model.nodes);
if(shape != null) {
btRigidBody.btRigidBodyConstructionInfo info = new btRigidBody.btRigidBodyConstructionInfo(0, null, shape, Vector3.Zero);
btRigidBody body = new btRigidBody(info);
info.dispose();
return body;
}
return null;
}
项目:Skyland
文件:MenuScene.java
@Override
public void show() {
Bullet.init();
init3d();
initScene2d();
initRayCastListener();
}
项目:Skyland
文件:Builder.java
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);
}
项目:Skyland
文件:WorldGenerator.java
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;
}
项目:eamaster
文件:BaseBulletTest.java
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;
}
项目:GdxDemo3D
文件:GameObjectBlueprint.java
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);
}
项目:Alien-Ark
文件:PlanetPart.java
/**
* Creates the collision objects of this planet part.
*/
private void initPhysics() {
for (int landscapeLayerIndex = 0; landscapeLayerIndex < planetConfig.layerConfigs.size(); landscapeLayerIndex++) {
String partName = LANDSCAPE_NODE_NAME + landscapeLayerIndex;
Node landscapeNode = model.getNode(partName);
CollisionTypes landscapeType = CollisionTypes.byName(planetConfig.layerConfigs.get(landscapeLayerIndex).collisionType);
if (areAllPartsValid(landscapeNode)) {
btCollisionShape collisionShape = Bullet.obtainStaticNodeShape(landscapeNode, false);
shapes.add(collisionShape);
if (landscapeType != CollisionTypes.WATER) {
float mass = 0;
float friction = 1;
PlanetConfig.LandscapeLayerConfig layerConfig = planetConfig.layerConfigs.get(landscapeLayerIndex);
int userValue = CollisionTypes.byName(layerConfig.collisionType).mask;
addRigidBody(collisionShape, mass, friction, userValue,
new StandardMotionState(modelInstance.transform));
} else {
btCollisionObject object = new btCollisionObject();
object.setCollisionShape(collisionShape);
object.setWorldTransform(modelInstance.transform);
object.setUserValue(CollisionTypes.WATER.mask);
addCollisionObject(object);
}
}
}
}
项目:Alien-Ark
文件:App.java
@Override
public void create () {
app = this;
gson = new GsonBuilder().setPrettyPrinting().create();
loadConfig();
Bullet.init();
Models.init(); // needs an initialized Bullet
loadSaveGame();
TEXTURES = new TextureAtlas("textures/game.atlas");
Styles.init(TEXTURES);
TUTORIAL_CONTROLLER = new TutorialController(Styles.UI_SKIN);
MULTIPLEXER = new InputMultiplexer();
MULTIPLEXER.addProcessor(new InputController());
Gdx.input.setInputProcessor(MULTIPLEXER);
audioController = new AudioController();
App.audioController.setSoundEnabled(App.config.playAudio);
App.audioController.setMusicEnabled(App.config.playAudio);
solarSystem = new SolarSystem();
solarSystem.calculatePlanetPositions();
if (config.debugMode) {
SpaceShipProperties.properties.testInit();
openSolarScreen();
} else {
openSplashScreen();
}
}
项目:ForgE
文件:ModelAsset.java
public btCollisionShape getCollisionShape() {
if (collisionShape == null) {
collisionShape = Bullet.obtainStaticNodeShape(get().nodes);
}
return collisionShape;
}
项目:ForgE
文件:ForgE.java
@Override
public void create () {
Bullet.init(false, true);
files = new FileManager();
storage = new StorageManager();
db = storage.loadOrInitializeDB();
graphics = new GraphicsUtils();
screens = new ScreenManager(this);
assets = new AssetsManager();
shaders = new ShadersManager();
input = new InputManager();
blocks = new BlocksProvider();
levels = new LevelManager(storage);
entities = new EntityManager();
scripts = new ScriptManager();
fb = new FrameBufferManager();
time = new TimeManager();
thread = Thread.currentThread();
ui = new UIManager();
Gdx.input.setInputProcessor(input);
for (ForgEBootListener listener : bootListeners) {
listener.afterEngineCreate(this);
}
ForgE.input.addProcessor(0, ui);
}
项目:libgdxcn
文件:BaseBulletTest.java
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;
}
项目:gdx-proto
文件:Physics.java
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);
}
项目:gdx-ai
文件:BulletSteeringTest.java
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;
}
项目:ahs-invaders
文件:InvadersGame.java
@Override
public void create () {
Bullet.init();
// Gdx.graphics.setDisplayMode(3840, 1080, true);
if (DEBUG_NOMENU) {
setScreen(new LevelScreen(this));
} else {
setMainMenuScreen();
}
}
项目:Tower-Defense-Galaxy
文件:TDGalaxy.java
@Override
public void create() {
Bullet.init();
themes.add("basic");
//clearPrefs();
//changePref("debug", true);
preferences = new PreferenceHandler();
dialogs = new Dialogs();
fonts = new HashMap<String, BitmapFont>();
FileHandler.loadFonts(fonts);
FileHandler.writeJSON(Gdx.files.external("Map.json"));
if(preferences.isDebug())
Gdx.app.setLogLevel(Application.LOG_DEBUG);
loadExternalAssets();
loadTheme("basic");
GameMode mode;
if(startingMode != null) {
try {
mode = GameMode.valueOf(startingMode);
Gdx.app.log("StartingMode", mode.name());
} catch (Exception e) {
Gdx.app.error("TDGalaxy", "Invalid starting mode", e);
}
}
if(preferences.isVr())
Gdx.graphics.setVSync(false);
mainScreen = new MainScreen(this);
setScreen(mainScreen);
//setScreen(new GameScreen(this, 0, themes.get(0)));
controlHandler = new ControlHandler();
client = new TDClient();
//client.connect(5000, "99.36.127.68", Networking.PORT); //99.36.127.68
Log.set(Log.LEVEL_DEBUG);
if(TDGalaxy.preferences.isDebugWindow() && debugger != null)
debugger.createWindow("Controllers");
if(vr != null && preferences.isVr()) {
vr.initialize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),2560, 1440);
new Thread() {
@Override
public void run() {
}
}.start();
}
}
项目:gdx-bullet-gwt
文件:btCollisionObject.java
public Matrix4 getWorldTransform() {
com.badlogic.gdx.physics.bullet.linearmath.btTransform.getTransform(getWorldTransformm(), Bullet.TMP_Matrix4_1);
return Bullet.TMP_Matrix4_1;
}
项目:Argent
文件:PhysicsCore.java
public PhysicsCore() {
Bullet.init();
}
项目:eamaster
文件:WheelRenderer.java
@Override
public void create() {
logger.info("Setting up camera");
camera = new PerspectiveCamera(40, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
// camera.position.set(40f, 30f, 40f);
camera.position.set(45f, 29f, 73f);
// camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
// camera.position.set(4f, 3f, 4f);
camera.lookAt(0, 2f, 0);
camera.near = 1f;
camera.far = 500f;
camera.update();
cameraInputController = new CameraInputController(camera);
Gdx.input.setInputProcessor(cameraInputController);
// Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
logger.info("Loading models");
models = new HashMap<>();
ModelBuilder builder = new ModelBuilder();
models.put("box", builder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
G3dModelLoader loader = new G3dModelLoader(new JsonReader());
models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));
logger.info("Let there be light");
batch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.6f, 0.6f, 0.6f, 1f));
environment.add(new DirectionalLight().set(0.3f, 0.3f, 0.3f, -5f, -3f, -1f));
environment.add(new DirectionalLight().set(0.2f, 0.2f, 0.2f, 5f, 8f, 0f));
environment.add(new DirectionalLight().set(0.7f, 0.7f, 0.7f, -3f, -2f, -5f));
logger.info("Initializing Bullet");
Bullet.init();
logger.info("Creating simulation");
// create world & stuff?
spokeAngles = new SpokeAngles();
// spokeAngles.create2l2t();
// spokeAngles.createCrowFoot();
// spokeAngles.createNx(3);
// spokeAngles.createPer3mutation(new int[]{3, 14, 5, 0, 7, 2, 9, 4, 11, 6, 13, 8, 15, 10, 1, 12}); // 3x as well!
// spokeAngles.createPermutation(new int[]{14, 2, 3, 15, 7, 5, 6, 10, 4, 9, 8, 11, 12, 0, 1, 13});
// spokeAngles.createPermutation(new int[]{2, 0, 1, 5, 3, 8, 10, 4, 12, 6, 11, 7, 9, 15, 13, 14});
// spokeAngles.createPermutation(new int[]{0, 15, 3, 2, 4, 9, 6, 7, 8, 5, 10, 11, 12, 13, 14, 1});
spokeAngles.createRandom();
// spokeAngles.createBack();
// spokeAngles.createSingel();
simulation = new Simulation("sim1", models, spokeAngles, true);
rayResultCallback = new ClosestRayResultCallback(new Vector3(), new Vector3());
rayResultCallback.setCollisionFilterGroup(SimulationConstants.RAY_GROUP);
logger.info("Setup complete");
}
项目:gdx-bullet-gwt
文件:btCollisionObject.java
public Matrix4 getWorldTransform() {
com.badlogic.gdx.physics.bullet.linearmath.btTransform.getTransform(getWorldTransformm(), Bullet.TMP_Matrix4_1);
return Bullet.TMP_Matrix4_1;
}
项目:Alien-Ark
文件:Models.java
/**
* Needs an initialized com.badlogic.gdx.physics.bullet.Bullet.
*/
public static void init() {
loader = new ObjLoader();
param = new ObjLoader.ObjLoaderParameters(true);
BoundingBox boundingBox = new BoundingBox();
FUEL = load("models/fuel.obj");
FUEL.calculateBoundingBox(boundingBox);
FUEL_SHAPE = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.8f));
SHIELD = load("models/shield.obj");
SHIELD.calculateBoundingBox(boundingBox);
SHIELD_SHAPE = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.8f));
ARTIFACT_MODELS.put(ATTRIBUTE_SPEED, load("models/artifact_speed.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_INERTIA, load("models/artifact_inertia.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_LANDSLIDE, load("models/artifact_landslide.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_FUEL_CAPACITY, load("models/artifact_fuel.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_SHIELD_CAPACITY, load("models/artifact_shield.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_SCAN_RADIUS, load("models/artifact_radius.obj"));
ARTIFACT_MODELS.put(ATTRIBUTE_LUCK, load("models/artifact_luck.obj"));
ARTIFACT_MODELS.put(OPERATOR_PLUS, load("models/artifact_plus.obj"));
ARTIFACT_MODELS.put(OPERATOR_MINUS, load("models/artifact_minus.obj"));
ARTIFACT_MODELS.put(OPERATOR_MULTIPLY, load("models/artifact_multiply.obj"));
ARTIFACT_MODELS.put(OPERATOR_DIVIDE, load("models/artifact_divide.obj"));
ARTIFACT_MODELS.put(VALUE_100, load("models/artifact_100.obj"));
ARTIFACT_MODELS.put(VALUE_200, load("models/artifact_200.obj"));
ARTIFACT_MODELS.put(VALUE_500, load("models/artifact_500.obj"));
ARTIFACT_MODELS.put(VALUE_1000, load("models/artifact_1000.obj"));
ARTIFACT_MODELS.put(VALUE_2000, load("models/artifact_2000.obj"));
PLANET_PORTAL = load("models/planetPortal.obj");
PLANET_PORTAL_TORUS = load("models/portalTorus.obj");
PORTAL_STAND_COLLISION = Bullet.obtainStaticNodeShape(PLANET_PORTAL.nodes);
Model portalTorusCollisionModel = load("models/planetPortalCollisionTube.obj");
PORTAL_TUBE_COLLISION = Bullet.obtainStaticNodeShape(portalTorusCollisionModel.nodes);
Model portalTriggerModel = load("models/portalTrigger.obj");
PORTAL_TRIGGER_COLLISION = Bullet.obtainStaticNodeShape(portalTriggerModel.nodes);
RACE_WAY_POINT = load("models/race_waypoint.obj");
RACE_WAY_POINT.calculateBoundingBox(boundingBox);
//Model raceWayPointTrigger = load("models/race_waypoint_trigger.obj");
RACE_WAY_POINT_COLLISION = new btBoxShape(boundingBox.getDimensions(new Vector3()).scl(0.5f));
}