当前位置: 首页>>代码示例>>Java>>正文


Java CapsuleCollisionShape类代码示例

本文整理汇总了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()));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:25,代码来源:CustomCharacterExample.java

示例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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:TestPhysicsCharacter.java

示例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);
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:17,代码来源:Sa.java

示例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);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:26,代码来源:Actor.java

示例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());
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:15,代码来源:PhysicsCharacterLogic.java

示例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));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:10,代码来源:PhysicsCharacterLogic.java

示例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);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:CreateCapsuleCollisionShapeAction.java

示例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;
    }
 
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:18,代码来源:AdvancedCharacterControl.java

示例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;
}
 
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:17,代码来源:BetterCharacterControl.java

示例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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:TestWalkingChar.java

示例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;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:TestRagDoll.java

示例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);
}
 
开发者ID:jMonkeyEngine-Contributions,项目名称:cubes,代码行数:9,代码来源:TestPhysics.java

示例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);

}
 
开发者ID:samynk,项目名称:DArtE,代码行数:31,代码来源:J3ONPC.java

示例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);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:16,代码来源:CMovementForcer.java

示例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);
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:11,代码来源:TestWalkingChar.java


注:本文中的com.jme3.bullet.collision.shapes.CapsuleCollisionShape类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。