本文整理汇总了Java中com.jme3.bullet.collision.shapes.BoxCollisionShape类的典型用法代码示例。如果您正苦于以下问题:Java BoxCollisionShape类的具体用法?Java BoxCollisionShape怎么用?Java BoxCollisionShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoxCollisionShape类属于com.jme3.bullet.collision.shapes包,在下文中一共展示了BoxCollisionShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupJoint
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public void setupJoint() {
Node holderNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.1f, .1f, .1f)), 0);
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, 0, 0f));
rootNode.attachChild(holderNode);
getPhysicsSpace().add(holderNode);
Node hammerNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.3f, .3f, .3f)), 1);
hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -1, 0f));
rootNode.attachChild(hammerNode);
getPhysicsSpace().add(hammerNode);
//immovable
collisionNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.3f, .3f, .3f)), 0);
collisionNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1.8f, 0, 0f));
rootNode.attachChild(collisionNode);
getPhysicsSpace().add(collisionNode);
//ghost node
ghostControl = new GhostControl(new SphereCollisionShape(0.7f));
hammerNode.addControl(ghostControl);
getPhysicsSpace().add(ghostControl);
joint = new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f, -1, 0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);
getPhysicsSpace().add(joint);
}
示例2: scanSpatial
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
private void scanSpatial(Spatial model) {
AnimControl animControl = model.getControl(AnimControl.class);
Map<Integer, List<Float>> pointsMap = null;
if (weightThreshold == -1.0f) {
pointsMap = RagdollUtils.buildPointMap(model);
}
skeleton = animControl.getSkeleton();
skeleton.resetAndUpdate();
for (int i = 0; i < skeleton.getRoots().length; i++) {
Bone childBone = skeleton.getRoots()[i];
if (childBone.getParent() == null) {
logger.log(Level.INFO, "Found root bone in skeleton {0}", skeleton);
baseRigidBody = new PhysicsRigidBody(new BoxCollisionShape(Vector3f.UNIT_XYZ.mult(0.1f)), 1);
baseRigidBody.setKinematic(mode == Mode.Kinetmatic);
boneRecursion(model, childBone, baseRigidBody, 1, pointsMap);
}
}
}
示例3: ShipWeaponControl
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public ShipWeaponControl(SimpleApplication asm, Node ship) {
shipNode = ship;
this.asm = asm;
shape = new BoxCollisionShape(new Vector3f(0.15f, 0.15f, 0.5f));
bullets = new Node("bullets");
bulletTimer = 0f;
fire = false;
// Setup Bullet
Box b = new Box(Vector3f.ZERO, 0.15f, 0.15f, 0.5f);
bullet = new Geometry("Box", b);
Material mat_bullet = new Material(asm.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat_bullet.setColor("Color", ColorRGBA.Red);
bullet.setMaterial(mat_bullet);
this.asm.getRootNode().attachChild(bullets);
// add ourselves as collision listener
bulletApp = asm.getStateManager().getState(BulletAppState.class);
bulletApp.getPhysicsSpace().addCollisionListener(this);
}
示例4: setShip
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
private void setShip() {
Box b = new Box(Vector3f.ZERO, 0.5f, 0.5f, 1);
Geometry geomShip = new Geometry("Box", b);
geomShip.setUserData("Type", "Player");
ship.attachChild(geomShip);
ship.setUserData("Type", "Player");
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
ship.setMaterial(mat);
CollisionShape colShape = new BoxCollisionShape(new Vector3f(1.0f, 1.0f, 1.0f));
colShape.setMargin(0.05f);
shipControl = new ShipPhysicsControl(colShape, 1, bulletAppState);
shipControl.setDamping(0.75f, 0.999f);
shipControl.setFriction(0.2f);
shipControl.setAngularFactor(0.1f);
ship.addControl(shipControl);
bulletAppState.getPhysicsSpace().add(shipControl);
shipControl.setEnabled(true);
// shipControl.setGravity(new Vector3f(0, 0, 0));
}
示例5: Explosion
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public Explosion(Vector3f position, AssetManager a, Node rootNode) {
setName("Explode");
this.position = position;
this.assetManager = a;
this.rootNode = rootNode;
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(PLACE_HOLDER-1, PLACE_HOLDER, PLACE_HOLDER-1));
ghost = new GhostControl(box);
addControl(ghost);
ghost.setPhysicsLocation(position);
explode();
shieldBroke = new AudioNode(assetManager, "Sounds/shield broke.wav",false);
shieldBroke.setLooping(false);
shieldBroke.setPositional(false);
shieldBroke.setVolume(.9f);
}
示例6: create
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public static Mesh create(CustomShape shape, CustomShapeFactory customShapeFactory){
Object object = customShapeFactory.getShape(shape.getDefinition());
if(object instanceof BoxCollisionShape){
return createBox(((BoxCollisionShape)shape.getDefinition()).getHalfExtents());
}
if(object instanceof SphereCollisionShape){
return createSphere(((SphereCollisionShape)shape.getDefinition()).getRadius());
}
Logger.getLogger(BodyView.Factory.class.getName()).info("Can't create mesh for definition: "+object);
return null;
}
示例7: simpleInitApp
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.1f);
setupKeys();
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat2.getAdditionalRenderState().setWireframe(true);
mat2.setColor("Color", ColorRGBA.Red);
// An obstacle mesh, does not move (mass=0)
Node node2 = new Node();
node2.setName("mesh");
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO, 4, 4, 0.1f)), 0));
rootNode.attachChild(node2);
getPhysicsSpace().add(node2);
// The floor, does not move (mass=0)
Node node3 = new Node();
node3.setLocalTranslation(new Vector3f(0f, -6, 0f));
node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0));
rootNode.attachChild(node3);
getPhysicsSpace().add(node3);
}
示例8: simpleInitApp
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
// Mesh to be shared across several boxes.
Box boxGeom = new Box(Vector3f.ZERO, 1f, 1f, 1f);
// CollisionShape to be shared across several boxes.
CollisionShape shape = new BoxCollisionShape(new Vector3f(1, 1, 1));
Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, shape, 1);
physicsBox.setName("box0");
physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
rootNode.attachChild(physicsBox);
getPhysicsSpace().add(physicsBox);
Node physicsBox1 = PhysicsTestHelper.createPhysicsTestNode(assetManager, shape, 1);
physicsBox1.setName("box1");
physicsBox1.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0, 40, 0));
rootNode.attachChild(physicsBox1);
getPhysicsSpace().add(physicsBox1);
Node physicsBox2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
physicsBox2.setName("box0");
physicsBox2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.5f, 80, -.8f));
rootNode.attachChild(physicsBox2);
getPhysicsSpace().add(physicsBox2);
// the floor, does not move (mass=0)
Node node = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(100, 1, 100)), 0);
node.setName("floor");
node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
rootNode.attachChild(node);
getPhysicsSpace().add(node);
initGhostObject();
}
示例9: initGhostObject
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
private void initGhostObject() {
Vector3f halfExtents = new Vector3f(3, 4.2f, 1);
ghostControl = new GhostControl(new BoxCollisionShape(halfExtents));
Node node=new Node("Ghost Object");
node.addControl(ghostControl);
rootNode.attachChild(node);
getPhysicsSpace().add(ghostControl);
}
示例10: makeMissile
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public void makeMissile() {
Vector3f pos = spaceCraft.getWorldTranslation().clone();
Quaternion rot = spaceCraft.getWorldRotation();
Vector3f dir = rot.getRotationColumn(2);
Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
missile.scale(0.5f);
missile.rotate(0, FastMath.PI, 0);
missile.updateGeometricState();
BoundingBox box = (BoundingBox) missile.getWorldBound();
final Vector3f extent = box.getExtent(null);
BoxCollisionShape boxShape = new BoxCollisionShape(extent);
missile.setName("Missile");
missile.rotate(rot);
missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
missile.setLocalRotation(hoverControl.getPhysicsRotation());
missile.setShadowMode(ShadowMode.Cast);
RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
control.setLinearVelocity(dir.mult(100));
control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
missile.addControl(control);
rootNode.attachChild(missile);
getPhysicsSpace().add(missile);
}
示例11: initFloor
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public void initFloor() {
Box floorBox = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);
floorBox.scaleTextureCoordinates(new Vector2f(3, 6));
Geometry floor = new Geometry("floor", floorBox);
floor.setMaterial(mat3);
floor.setShadowMode(ShadowMode.Receive);
floor.setLocalTranslation(0, -0.1f, 0);
floor.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(10f, 0.1f, 5f)), 0));
this.rootNode.attachChild(floor);
this.getPhysicsSpace().add(floor);
}
示例12: setupJoint
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public void setupJoint() {
Node holderNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f));
rootNode.attachChild(holderNode);
getPhysicsSpace().add(holderNode);
Node hammerNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1);
hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,-1,0f));
rootNode.attachChild(hammerNode);
getPhysicsSpace().add(hammerNode);
joint=new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1,0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);
getPhysicsSpace().add(joint);
}
示例13: createSingleBoxShape
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
/**
* Uses the bounding box of the supplied spatial to create a BoxCollisionShape
* @param spatial
* @return BoxCollisionShape with the size of the spatials BoundingBox
*/
private static BoxCollisionShape createSingleBoxShape(Spatial spatial, Spatial parent) {
spatial.setModelBound(new BoundingBox());
//TODO: using world bound here instead of "local world" bound...
BoxCollisionShape shape = new BoxCollisionShape(
((BoundingBox) spatial.getWorldBound()).getExtent(new Vector3f()));
return shape;
}
示例14: doCheckVehicle
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
public boolean doCheckVehicle(Node rootNode) {
VehicleControl control = rootNode.getControl(VehicleControl.class);
if (control == null) {
vehicleControl = new VehicleControl(new BoxCollisionShape(Vector3f.UNIT_XYZ), 200);
// vehicleControl.createDebugShape(SceneApplication.getApplication().getAssetManager());
rootNode.addControl(vehicleControl);
return true;
} else {
vehicleControl = control;
// vehicleControl.createDebugShape(SceneApplication.getApplication().getAssetManager());
return false;
}
}
示例15: getCollisionShape
import com.jme3.bullet.collision.shapes.BoxCollisionShape; //导入依赖的package包/类
@Override
public CollisionShape getCollisionShape(Spatial spatial) {
return new BoxCollisionShape(extents);
// remove20170308
// CollisionShape collisionShape;
// if (spatial instanceof Geometry) {
// Mesh mesh = ((Geometry) spatial).getMesh();
// if (mesh instanceof Box) {
// collisionShape = new BoxCollisionShape(new Vector3f(((Box) mesh).getXExtent(), ((Box) mesh).getYExtent(), ((Box) mesh).getZExtent()));
// return collisionShape;
// }
// }
// return CollisionShapeFactory.createBoxShape(spatial);
}