本文整理汇总了Java中com.badlogic.gdx.physics.bullet.collision.Collision类的典型用法代码示例。如果您正苦于以下问题:Java Collision类的具体用法?Java Collision怎么用?Java Collision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collision类属于com.badlogic.gdx.physics.bullet.collision包,在下文中一共展示了Collision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WorldEntity
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public WorldEntity(String name, ModelInstance instance, btRigidBody btRigidBody, boolean disableDeactivation) {
this.name = name;
this.instance = instance;
this.btRigidBody = btRigidBody;
btRigidBody.userData = this;
motionState = new MotionState(instance.transform);
btRigidBody.setMotionState(motionState);
logger.debug("Creating object '{}'", name);
if (disableDeactivation) {
logger.debug("Disabling deactivation for '{}'", name);
btRigidBody.setActivationState(Collision.DISABLE_DEACTIVATION);
}
getDefaultColors();
}
示例2: create
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public void create () {
super.create();
// Create the entities
world.add("ground", 0f, 0f, 0f).setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
0.25f + 0.5f * (float)Math.random(), 1f);
kinematicBox1 = world.add("staticbox", position1.x, position1.y, position1.z);
kinematicBox1.setColor(Color.RED);
kinematicBox1.body.setCollisionFlags(kinematicBox1.body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
kinematicBox2 = world.add("staticbox", position2.x, position2.y, position2.z);
kinematicBox2.setColor(Color.RED);
kinematicBox2.body.setCollisionFlags(kinematicBox2.body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
;
kinematicBox3 = world.add("staticbox", position3.x, position3.y, position3.z);
kinematicBox3.setColor(Color.RED);
kinematicBox3.body.setCollisionFlags(kinematicBox3.body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
;
// This makes bullet call btMotionState#getWorldTransform on every update:
kinematicBox3.body.setActivationState(Collision.DISABLE_DEACTIVATION);
angle = 360f;
}
示例3: render
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public void render () {
angle = angle + Gdx.graphics.getDeltaTime() * 360f / 5f;
kinematicBox3.transform.idt().rotate(Vector3.Y, 360f - 2f * angle).translate(position3);
if (angle >= 360f) {
angle = 0;
kinematicBox = (kinematicBox == kinematicBox1) ? kinematicBox2 : kinematicBox1;
position = (position == position1) ? position2 : position1;
}
kinematicBox.transform.idt().rotate(Vector3.Y, angle).translate(position);
// This makes bullet call btMotionState#getWorldTransform once:
kinematicBox.body.setActivationState(Collision.ACTIVE_TAG);
super.render();
}
示例4: touchUp
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
boolean result = false;
if (button == Buttons.LEFT) {
if (pickConstraint != null) {
((btDynamicsWorld)world.collisionWorld).removeConstraint(pickConstraint);
pickConstraint.dispose();
pickConstraint = null;
result = true;
}
if (pickedBody != null) {
pickedBody.forceActivationState(Collision.ACTIVE_TAG);
pickedBody.setDeactivationTime(0f);
pickedBody = null;
}
}
return result ? result : super.touchUp(screenX, screenY, pointer, button);
}
示例5: build
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public VehicleComponent build(btDynamicsWorld world, btCollisionShape chassisShape,
btRaycastVehicle.btVehicleTuning vehicleTuning, float mass, float friction, float restitution, short group, short[] masks) {
this.vehicleTuning = vehicleTuning;
build(chassisShape, mass, friction, restitution, group, masks);
getBody().setActivationState(Collision.DISABLE_DEACTIVATION);
vehicleRaycaster = new btDefaultVehicleRaycaster(world);
vehicle = new btRaycastVehicle(vehicleTuning, getBody(), vehicleRaycaster);
vehicle.setCoordinateSystem(0, 1, 2);
return this;
}
示例6: setDynamic
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public void setDynamic() {
if(body == null) return;
body.setCollisionFlags(CF_CUSTOM_MATERIAL_CALLBACK);
body.activate(true);
body.setActivationState(Collision.DISABLE_DEACTIVATION);
physicsState = DYNAMIC;
}
示例7: buildCave
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的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);
}
示例8: createKinematicIsland
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public static BulletEntity createKinematicIsland(BulletWorld world, Vector3 position, boolean landscape) {
BulletEntity island = world.add("island", position.x, position.y, position.z);
island.radius = 5; // not really the radius, but this should be always in the frustum
island.body.userData = new BulletUserData("island", island);
island.body.setCollisionFlags(island.body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
island.body.setActivationState(Collision.DISABLE_DEACTIVATION);
if (landscape) {
Vector3 islePosition = island.transform.getTranslation(new Vector3());
placeCave(islePosition);
plantTrees(world, islePosition);
}
return island;
}
示例9: createCloud
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
private void createCloud() {
float y, z;
do {
y = MathUtils.random(-40, 30);
z = MathUtils.random(-80, 80);
} while (y < 15 && y > -20 && z < 15 && z > -15);
clouds.add(cloud = world.add("cloud", -120, y, z));
cloud.radius = 7;
cloud.body.userData = new BulletUserData("cloud", cloud);
cloud.transform.rotate(0, 1, 0, 90);
cloud.body.setCollisionFlags(cloud.body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
cloud.body.setActivationState(Collision.DISABLE_DEACTIVATION);
}
示例10: touchDown
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
boolean result = false;
if (button == Buttons.LEFT) {
Ray ray = camera.getPickRay(screenX, screenY);
tmpV1.set(ray.direction).scl(10f).add(ray.origin);
ClosestRayResultCallback cb = new ClosestRayResultCallback(ray.origin, tmpV1);
world.collisionWorld.rayTest(ray.origin, tmpV1, cb);
if (cb.hasHit()) {
btRigidBody body = (btRigidBody)(cb.getCollisionObject());
if (body != null && !body.isStaticObject() && !body.isKinematicObject()) {
pickedBody = body;
body.setActivationState(Collision.DISABLE_DEACTIVATION);
cb.getHitPointWorld(tmpV);
tmpV.mul(body.getCenterOfMassTransform().inv());
pickConstraint = new btPoint2PointConstraint(body, tmpV);
btConstraintSetting setting = pickConstraint.getSetting();
setting.setImpulseClamp(30f);
setting.setTau(0.001f);
pickConstraint.setSetting(setting);
((btDynamicsWorld)world.collisionWorld).addConstraint(pickConstraint);
pickDistance = tmpV1.sub(camera.position).len();
result = true;
}
}
cb.dispose();
}
return result ? result : super.touchDown(screenX, screenY, pointer, button);
}
示例11: InvisibleBody
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public InvisibleBody(String name,
btCollisionShape shape,
float mass,
Matrix4 transform,
short belongsToFlag,
short collidesWithFlag,
boolean callback,
boolean noDeactivate) {
super(name);
this.mass = mass;
this.shape = shape;
this.belongsToFlag = belongsToFlag;
this.collidesWithFlag = collidesWithFlag;
if (mass > 0f) {
shape.calculateLocalInertia(mass, localInertia);
} else {
localInertia.set(0, 0, 0);
}
this.constructionInfo = new btRigidBody.btRigidBodyConstructionInfo(
mass, null, shape, localInertia);
body = new btRigidBody(constructionInfo);
body.setWorldTransform(transform);
body.setContactCallbackFlag(belongsToFlag);
if (callback) {
body.setCollisionFlags(body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
}
if (noDeactivate) {
body.setActivationState(Collision.DISABLE_DEACTIVATION);
}
}
示例12: calculateDistance
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public void calculateDistance (btCollisionObject colObjA, btCollisionObject colObjB) {
DistanceInternalResultCallback result = new DistanceInternalResultCallback();
Collision.setGContactBreakingThreshold(100f);
collisionWorld.contactPairTest(colObjA, colObjB, result);
Collision.setGContactBreakingThreshold(0.02f);
}
示例13: onInit
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public void onInit() {
input = remoteInputProperty.getRemoteInput();
physicsProperty.getRigidBody().setActivationState(Collision.DISABLE_DEACTIVATION);
physicsProperty.getRigidBody().activate();
}
示例14: setStatic
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public void setStatic() {
if(body == null) return;
body.setCollisionFlags(CF_STATIC_OBJECT);
body.setActivationState(Collision.DISABLE_DEACTIVATION);
physicsState = STATIC;
}
示例15: setKinematic
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public void setKinematic() {
if(body == null) return;
body.setCollisionFlags(CF_KINEMATIC_OBJECT);
body.setActivationState(Collision.DISABLE_DEACTIVATION);
physicsState = KINEMATIC;
}