本文整理汇总了Java中com.jme3.bullet.collision.shapes.CapsuleCollisionShape类的典型用法代码示例。如果您正苦于以下问题:Java CapsuleCollisionShape类的具体用法?Java CapsuleCollisionShape怎么用?Java CapsuleCollisionShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CapsuleCollisionShape类属于com.jme3.bullet.collision.shapes包,在下文中一共展示了CapsuleCollisionShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCharacter
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private void createCharacter(){
character = entityData.createEntity();
entityData.setComponents(character,
//some view stuff
new PhysicsToViewLocation(new Vector3f(0, -CHARACTER_STEP_HEIGHT/2, 0)),
new PhysicsToViewRotation(),
new UnshadedColor(ColorRGBA.Red),
new CapsuleView(CHARACTER_RADIUS, CHARACTER_HEIGHT-2*CHARACTER_RADIUS),
//basic properties of the capsule
new Friction(0),
new Factor(new Vector3f(1,1,1), new Vector3f(0,0,0)),
new RigidBody(false, CHARACTER_MASS),
new CustomShape(new CapsuleCollisionShape(CHARACTER_RADIUS, CHARACTER_CAPSULE_HEIGHT)),
//base character definition
new PhysicsCharacter(),
//drag force for max speed
new SimpleDrag(DRAG_FACTOR),
//jump system
new JumpState(false),
new JumpCount(0),
//initial zero move force
new MoveForce(new Vector2f()),
new WarpPosition(new Vector3f(0, 5, 0), new Quaternion()));
}
示例2: simpleInitApp
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
setupKeys();
// Add a physics character to the world
physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f,1.8f), .1f);
physicsCharacter.setPhysicsLocation(new Vector3f(3, 6, 0));
Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
model.scale(0.25f);
model.addControl(physicsCharacter);
getPhysicsSpace().add(physicsCharacter);
rootNode.attachChild(model);
}
示例3: Sa
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
public Sa(Spatial s) {
super(s);
setName("Sa");
CapsuleCollisionShape capsule = new CapsuleCollisionShape(PLACE_HOLDER, PLACE_HOLDER * .8f);
saChar = new SaGhost(capsule, this);
AnimControl animationControl = s.getControl(AnimControl.class);
animationControl.addListener(this);
GhostControl ghost = new GhostControl(capsule);
animationChannel = animationControl.createChannel();
addControl(saChar);
addControl(ghost);
speed = (float) (BASIC_V * 0.6);
}
示例4: makePhysics
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
@Override
protected void makePhysics(PhysicsSpace physicsSpace) {
// intialise the real physics control
CollisionShape cs = new CapsuleCollisionShape(1.5f,5f,1);
physics = new ForceCharacterControl(cs,4);
//physics.setGravity(-200f);
physics.setGravity(200f);
physics.setFallSpeed(200f);
physics.setJumpSpeed(50f);
geometry.addControl(physics);
// create the ghost control
ghost = new GhostControl(cs);
geometry.addControl(ghost);
// put the ghost physics in a different group actor don't collide with themselves
geometry.getControl(GhostControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_07);
geometry.getControl(GhostControl.class).removeCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
geometry.getControl(GhostControl.class).addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_07);
physicsSpace.add(ghost);
physicsSpace.add(physics);
physicsSpace.addTickListener(physicsTickListener);
}
示例5: init
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
@Override
public void init() {
PhysicsCharacter character = get(PhysicsCharacter.class);
float characterCapsuleHeight = character.getHeight()-2*character.getRadius()-character.getStepHeight();
float dragFactor = character.getMass()*character.getAcceleration()/(character.getMaxSpeed()*character.getMaxSpeed());
set(new Friction(0));
set(new Factor(new Vector3f(1,1,1), new Vector3f(0,0,0)));
set(new RigidBody(false, character.getMass()));
set(new CustomShape(new CapsuleCollisionShape(character.getRadius(), characterCapsuleHeight)));
set(new SimpleDrag(dragFactor));
set(new PhysicsCharacterState(false, false));
set(new PhysicsCharacterJumpCount(0));
set(new PhysicsCharacterMovement());
}
示例6: update
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
@Override
public void update() {
PhysicsCharacter character = get(PhysicsCharacter.class);
float characterCapsuleHeight = character.getHeight()-2*character.getRadius()-character.getStepHeight();
float dragFactor = character.getMass()*character.getAcceleration()/(character.getMaxSpeed()*character.getMaxSpeed());
set(new RigidBody(false, character.getMass()));
set(new CustomShape(new CapsuleCollisionShape(character.getRadius(), characterCapsuleHeight)));
set(new SimpleDrag(dragFactor));
}
示例7: createShape
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) {
final float height = vars.getFloat(PROPERTY_HEIGHT);
final float radius = vars.getFloat(PROPERTY_RADIUS);
return new CapsuleCollisionShape(radius, height);
}
示例8: getShape
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
/**
* Gets a new collision shape based on the current scale parameter. The created
* collisionshape is a capsule collision shape that is attached to a compound
* collision shape with an offset to set the object center at the bottom of the
* capsule.
*
* @return
*/
protected CollisionShape getShape() {
//TODO: cleanup size mess..
CapsuleCollisionShape collisionShape = new CapsuleCollisionShape(getFinalRadius(), (getFinalHeight() - (2 * getFinalRadius())));
// BoxCollisionShape collisionShape = new BoxCollisionShape(new Vector3f(getFinalRadius(), getFinalHeight() - (2 * getFinalRadius()), getFinalRadius()));
CompoundCollisionShape compoundCollisionShape = new CompoundCollisionShape();
Vector3f addLocation = new Vector3f(0, (getFinalHeight() / 2.0f), 0);
compoundCollisionShape.addChildShape(collisionShape, addLocation);
return compoundCollisionShape;
}
示例9: getShape
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
/**
* Gets a new collision shape based on the current scale parameter. The
* created collisionshape is a capsule collision shape that is attached to a
* compound collision shape with an offset to set the object center at the
* bottom of the capsule.
*
* @return
*/
protected CollisionShape getShape() {
//TODO: cleanup size mess..
CapsuleCollisionShape capsuleCollisionShape = new CapsuleCollisionShape(getFinalRadius(), (getFinalHeight() - (2 * getFinalRadius())));
CompoundCollisionShape compoundCollisionShape = new CompoundCollisionShape();
Vector3f addLocation = new Vector3f(0, (getFinalHeight() / 2.0f), 0);
compoundCollisionShape.addChildShape(capsuleCollisionShape, addLocation);
return compoundCollisionShape;
}
示例10: createCharacter
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private void createCharacter() {
CapsuleCollisionShape capsule = new CapsuleCollisionShape(1.5f, 2f);
character = new CharacterControl(capsule, 0.01f);
model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
model.setLocalScale(0.5f);
model.addControl(character);
character.setPhysicsLocation(new Vector3f(-140, 10, -10));
rootNode.attachChild(model);
getPhysicsSpace().add(character);
}
示例11: createLimb
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private Node createLimb(float width, float height, Vector3f location, boolean rotate) {
int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y;
CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis);
Node node = new Node("Limb");
RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1);
node.setLocalTranslation(location);
node.addControl(rigidBodyControl);
return node;
}
示例12: initPlayer
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private void initPlayer(){
playerControl = new CharacterControl(new CapsuleCollisionShape((cubesSettings.getBlockSize() / 2), cubesSettings.getBlockSize() * 2), 0.05f);
playerControl.setJumpSpeed(25);
playerControl.setFallSpeed(20);
playerControl.setGravity(70);
playerControl.setPhysicsLocation(new Vector3f(5, terrainSize.getY() + 5, 5).mult(cubesSettings.getBlockSize()));
bulletAppState.getPhysicsSpace().add(playerControl);
}
示例13: J3ONPC
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
public J3ONPC(Node animatedMesh, String actorName, String actorId) {
this.attachChild(animatedMesh);
if (actorName == null) {
this.actorName = "npc" + (id++);
} else {
this.actorName = actorName;
}
this.actorId = actorId;
this.setUserData("walkSpeed", walkSpeed);
this.setUserData("camOffset", new Vector3f(0, 1.0f, 0));
animatedMesh.setLocalTranslation(0, -0.7f, 0);
animatedMesh.rotate(0, FastMath.PI, 0);
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(0.3f, 1.0f, 1);
CharacterControl character_phys = new CharacterControl(capsuleShape, 0.4f);
character_phys.setJumpSpeed(5);
character_phys.setFallSpeed(2);
character_phys.setGravity(4);
character_phys.setUseViewDirection(false);
character_phys.setMaxSlope(45 * FastMath.DEG_TO_RAD);
// Attach physical properties to model and PhysicsSpace
this.addControl(character_phys);
initAnimation(animatedMesh);
}
示例14: start
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private void start() {
CCharacterPhysics physics = spatial.getControl(CCharacterPhysics.class);
CapsuleCollisionShape shape = physics.getCapsuleShape();
shape.setScale(new Vector3f(1.5f, 1f, 1.5f));
ghost = new GhostControl(shape);
ghost.setCollisionGroup(CollisionGroups.NONE);
ghost.setCollideWithGroups(CollisionGroups.CHARACTERS
| CollisionGroups.WALLS | CollisionGroups.SPIRIT_STONE);
ghostNode = new Node("Ghost Node");
((Node) spatial).attachChild(ghostNode);
ghostNode.addControl(ghost);
ghost.setUserObject(spatial);
physics.getPhysicsSpace().add(ghost);
physics.getPhysicsSpace().addCollisionListener(this);
}
示例15: createCharacter
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; //导入依赖的package包/类
private void createCharacter() {
CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);
character = new CharacterControl(capsule, 0.01f);
model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
//model.setLocalScale(0.5f);
model.addControl(character);
character.setPhysicsLocation(new Vector3f(-140, 15, -10));
rootNode.attachChild(model);
getPhysicsSpace().add(character);
}