本文整理汇总了Java中com.badlogic.gdx.physics.bullet.Bullet类的典型用法代码示例。如果您正苦于以下问题:Java Bullet类的具体用法?Java Bullet怎么用?Java Bullet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bullet类属于com.badlogic.gdx.physics.bullet包,在下文中一共展示了Bullet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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();
}
示例2: reconstructBody
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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);
}
示例3: SimulationRunner
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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");
}
示例4: onInit
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
@Override
protected void onInit() {
logger.info("initializing physics");
new SharedLibraryLoader().load("gdx");
Bullet.init();
createPhysicsWorld();
rayTestSolver.setWorld(mainWorld);
}
示例5: initPhysics
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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;
}
示例6: buildComplexCollisionMesh
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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);
}
示例7: show
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
@Override
public void show() {
Bullet.init();
init3d();
initScene2d();
initRayCastListener();
}
示例8: buildCave
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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);
}
示例9: generateBaseWorld
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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;
}
示例10: init
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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;
}
示例11: GameObjectBlueprint
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
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);
}
示例12: initPhysics
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
/**
* 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);
}
}
}
}
示例13: create
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
@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();
}
}
示例14: getCollisionShape
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
public btCollisionShape getCollisionShape() {
if (collisionShape == null) {
collisionShape = Bullet.obtainStaticNodeShape(get().nodes);
}
return collisionShape;
}
示例15: create
import com.badlogic.gdx.physics.bullet.Bullet; //导入依赖的package包/类
@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);
}