本文整理汇总了Java中com.badlogic.gdx.physics.bullet.collision.Collision类的典型用法代码示例。如果您正苦于以下问题:Java Collision类的具体用法?Java Collision怎么用?Java Collision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collision类属于com.badlogic.gdx.physics.bullet.collision包,在下文中一共展示了Collision类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:19,代码来源:WorldEntity.java
示例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;
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:27,代码来源:KinematicTest.java
示例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();
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:17,代码来源:KinematicTest.java
示例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);
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:19,代码来源:RayPickRagdollTest.java
示例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;
}
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:15,代码来源:VehicleComponent.java
示例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;
}
开发者ID:ncguy2,项目名称:Argent,代码行数:8,代码来源:BulletEntity.java
示例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);
}
开发者ID:ToxSickCoder,项目名称:Skyland,代码行数:15,代码来源:Builder.java
示例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;
}
开发者ID:ToxSickCoder,项目名称:Skyland,代码行数:15,代码来源:WorldGenerator.java
示例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);
}
开发者ID:ToxSickCoder,项目名称:Skyland,代码行数:16,代码来源:CloudGenerator.java
示例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);
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:34,代码来源:RayPickRagdollTest.java
示例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);
}
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:34,代码来源:InvisibleBody.java
示例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);
}
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:ConvexHullDistanceTest.java
示例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();
}
开发者ID:WarpOrganization,项目名称:warp,代码行数:7,代码来源:MovementScript.java
示例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;
}
开发者ID:ncguy2,项目名称:Argent,代码行数:7,代码来源:BulletEntity.java
示例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;
}
开发者ID:ncguy2,项目名称:Argent,代码行数:7,代码来源:BulletEntity.java
示例16: setup
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
protected void setup(String name, Model model, btRigidBody.btRigidBodyConstructionInfo constructionInfo) {
this.name = name;
modelInstance = new ModelInstance(model);
rigidBody = new btRigidBody(constructionInfo);
rigidBody.userData = this;
rigidBody.setActivationState(Collision.DISABLE_DEACTIVATION);
motionState = new MotionState(modelInstance.transform);
rigidBody.setMotionState(motionState);
getDefaultColors();
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:17,代码来源:Entity.java
示例17: create
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
@Override
public void create () {
super.create();
instructions = "Tap to shoot\nArrow keys to drive\nR to reset\nLong press to toggle debug mode\nSwipe for next test";
final Model chassisModel = objLoader.loadModel(Gdx.files.internal("data/car.obj"));
disposables.add(chassisModel);
chassisModel.materials.get(0).clear();
chassisModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.RED), ColorAttribute.createSpecular(Color.WHITE));
final Model wheelModel = objLoader.loadModel(Gdx.files.internal("data/wheel.obj"));
disposables.add(wheelModel);
wheelModel.materials.get(0).clear();
wheelModel.materials.get(0).set(ColorAttribute.createDiffuse(Color.BLACK), ColorAttribute.createSpecular(Color.WHITE),
FloatAttribute.createShininess(128));
Texture checkboard = new Texture(Gdx.files.internal("data/g3d/checkboard.png"));
final Model largeGroundModel = modelBuilder.createBox(
1000f,
2f,
1000f,
new Material(TextureAttribute.createDiffuse(checkboard), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute
.createShininess(16f)), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
largeGroundModel.manageDisposable(checkboard);
disposables.add(largeGroundModel);
world.addConstructor("largeground", new BulletConstructor(largeGroundModel, 0f));
BoundingBox bounds = new BoundingBox();
Vector3 chassisHalfExtents = new Vector3(chassisModel.calculateBoundingBox(bounds).getDimensions()).scl(0.5f);
Vector3 wheelHalfExtents = new Vector3(wheelModel.calculateBoundingBox(bounds).getDimensions()).scl(0.5f);
world.addConstructor("chassis", new BulletConstructor(chassisModel, 5f, new btBoxShape(chassisHalfExtents)));
world.addConstructor("wheel", new BulletConstructor(wheelModel, 0, null));
world.add("largeground", 0, -1f, 0f);
chassis = world.add("chassis", 0, 3f, 0);
wheels[0] = world.add("wheel", 0, 0, 0);
wheels[1] = world.add("wheel", 0, 0, 0);
wheels[2] = world.add("wheel", 0, 0, 0);
wheels[3] = world.add("wheel", 0, 0, 0);
// Create the vehicle
raycaster = new btDefaultVehicleRaycaster((btDynamicsWorld)world.collisionWorld);
tuning = new btVehicleTuning();
vehicle = new btRaycastVehicle(tuning, (btRigidBody)chassis.body, raycaster);
chassis.body.setActivationState(Collision.DISABLE_DEACTIVATION);
((btDynamicsWorld)world.collisionWorld).addVehicle(vehicle);
vehicle.setCoordinateSystem(0, 1, 2);
btWheelInfo wheelInfo;
Vector3 point = new Vector3();
Vector3 direction = new Vector3(0, -1, 0);
Vector3 axis = new Vector3(-1, 0, 0);
wheelInfo = vehicle.addWheel(point.set(chassisHalfExtents).scl(0.9f, -0.8f, 0.7f), direction, axis,
wheelHalfExtents.z * 0.3f, wheelHalfExtents.z, tuning, true);
wheelInfo = vehicle.addWheel(point.set(chassisHalfExtents).scl(-0.9f, -0.8f, 0.7f), direction, axis,
wheelHalfExtents.z * 0.3f, wheelHalfExtents.z, tuning, true);
wheelInfo = vehicle.addWheel(point.set(chassisHalfExtents).scl(0.9f, -0.8f, -0.5f), direction, axis,
wheelHalfExtents.z * 0.3f, wheelHalfExtents.z, tuning, false);
wheelInfo = vehicle.addWheel(point.set(chassisHalfExtents).scl(-0.9f, -0.8f, -0.5f), direction, axis,
wheelHalfExtents.z * 0.3f, wheelHalfExtents.z, tuning, false);
}
开发者ID:Matsemann,项目名称:eamaster,代码行数:63,代码来源:VehicleTest.java
示例18: GameModelBody
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
/**
* Creates a model with rigid body
*
* @param model Model to instantiate
* @param name Name of model
* @param location World position at which to place the model instance
* @param rotation The rotation of the model instance in degrees
* @param scale Scale of the model instance
* @param shape Collision shape with which to construct a rigid body
* @param mass Mass of the body
* @param belongsToFlag Flag for which collision layers this body belongs to
* @param collidesWithFlag Flag for which collision layers this body collides with
* @param callback If this body should trigger collision contact callbacks.
* @param noDeactivate If this body should never 'sleep'
*/
public GameModelBody(Model model,
String name,
Vector3 location,
Vector3 rotation,
Vector3 scale,
btCollisionShape shape,
float mass,
short belongsToFlag,
short collidesWithFlag,
boolean callback,
boolean noDeactivate) {
super(model, name, location, rotation, scale);
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);
if (mass > 0f) {
motionState = new PhysicsMotionState(modelInstance.transform);
body.setMotionState(motionState);
} else {
motionState = null;
}
body.setContactCallbackFlag(belongsToFlag);
if (callback) {
body.setCollisionFlags(body.getCollisionFlags()
| btCollisionObject.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
}
if (noDeactivate) {
body.setActivationState(Collision.DISABLE_DEACTIVATION);
}
body.setWorldTransform(modelInstance.transform);
}
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:63,代码来源:GameModelBody.java
示例19: ShipBehavior
import com.badlogic.gdx.physics.bullet.collision.Collision; //导入依赖的package包/类
public ShipBehavior(GameObject gameObject) {
super(gameObject);
gameObject.rigidBody.forceActivationState(Collision.DISABLE_DEACTIVATION);
}
开发者ID:fbcouch,项目名称:ahs-invaders,代码行数:5,代码来源:ShipBehavior.java
注:本文中的com.badlogic.gdx.physics.bullet.collision.Collision类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论