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


Java SphereCollisionShape类代码示例

本文整理汇总了Java中com.jme3.bullet.collision.shapes.SphereCollisionShape的典型用法代码示例。如果您正苦于以下问题:Java SphereCollisionShape类的具体用法?Java SphereCollisionShape怎么用?Java SphereCollisionShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SphereCollisionShape类属于com.jme3.bullet.collision.shapes包,在下文中一共展示了SphereCollisionShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //create a new debug view state
    //you have to add the same CustomShapeFactory which you have added to the BulletSystem
    //if no factory is given to the constructor the default factory will be used (CollisionShapeFactory)
    ESDebugViewState debugView = new ESDebugViewState(entityData, getRootNode());
    getStateManager().attach(debugView);

    EntityId sphere = entityData.createEntity();
    entityData.setComponents(sphere,
            new CustomShape(new SphereCollisionShape(0.5f)),
            new RigidBody(false, 10),
            new WarpPosition(new Vector3f(0, 15, 0), Quaternion.DIRECTION_Z.clone()));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new BoxShape(new Vector3f(5f, 0.1f, 5f)),
            new RigidBody(false, 0));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:20,代码来源:DebugViewExample.java

示例2: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的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: setupJoint

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的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);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:TestAttachGhostObject.java

示例4: onAction

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("shoot") && !keyPressed) {
                Geometry bulletg = new Geometry("bullet", bullet);
                bulletg.setMaterial(mat2);
                bulletg.setShadowMode(ShadowMode.CastAndReceive);
                bulletg.setLocalTranslation(cam.getLocation());
                
                SphereCollisionShape bulletCollisionShape = new SphereCollisionShape(0.4f);
                RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
//                RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1);
                bulletNode.setLinearVelocity(cam.getDirection().mult(25));
                bulletg.addControl(bulletNode);
                rootNode.attachChild(bulletg);
                getPhysicsSpace().add(bulletNode);
            }
            if (name.equals("gc") && !keyPressed) {
                System.gc();
            }
        }
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:TestBrickWall.java

示例5: AlienShip

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
public AlienShip(String name, Material mat, Node target, AssetManager assetManager) {
    s =  assetManager.loadModel("Models/Mothership/drone.j3o");
    s.setLocalTranslation(0f, -1f, 0f);
    s.setLocalScale(0.3f);
    s.setName(name);
    
    // Store handle to the target to pass to alien
    this.target = target;
    
    // Set up the minion queue
    alien = new HashSet<Alien>();
    gball = new HashSet<Gumball>();
    
    // Creates a rough approximation of the shape and makes it float at Y = 35 
    control = new DroneControl(new SphereCollisionShape(innerRadius), 3f, target, 15f);
    control.setLinearDamping(0.7f);
    control.setAngularDamping(1.0f);
    control.setFriction(0f);
    
    // Set up the ghost control as a proximity detector
    gControl = new GhostControl(new SphereCollisionShape(outterRadius));
    
    s.addControl(control);
    s.addControl(gControl);
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:26,代码来源:AlienShip.java

示例6: MegaDrone

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
public MegaDrone(String name, Material mat, Node target, AssetManager assetManager) {
    s =  assetManager.loadModel("Models/Mothership/Mothership.j3o");
    s.setLocalTranslation(0f, -1f, 0f);
    s.setLocalScale(6f);
    s.setName(name);
    
    // Store handle to the target to pass to minions
    this.target = target;
    
    // Set up the minion queue
    minions = new HashSet<MicroDrone>();
    
    // Creates a rough approximation of the shape and makes it float at Y = 35 
    control = new DroneControl(new SphereCollisionShape(innerRadius), 3f, target, 35f);
    control.setLinearDamping(0.7f);
    control.setAngularDamping(1.0f);
    control.setFriction(0f);
    
    // Set up the ghost control as a proximity detector
    gControl = new GhostControl(new SphereCollisionShape(outterRadius));
    
    s.addControl(control);
    s.addControl(gControl);
}
 
开发者ID:melombuki,项目名称:JMonkeyGame,代码行数:25,代码来源:MegaDrone.java

示例7: Worm

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
public Worm(Spatial s, float speedRatio, byte smartLv) {
    super(s);
    setName("Worm");
    SphereCollisionShape capsule = new SphereCollisionShape(PLACE_HOLDER);
    wormChar = new WormGhost(capsule, this);

    AnimControl animationControl = s.getControl(AnimControl.class);
    animationControl.addListener(this);

    animationChannel = s.getControl(AnimControl.class).createChannel();
    addControl(wormChar);

    speed = (float) (PLACE_HOLDER / TIMES_PER_CELL + .05f) * speedRatio * 0.5f;
    this.smartLv = smartLv;
    if (smartLv == 10) {
        IGNORE_FRAME = 3;
    } else if (smartLv == 8) {
        IGNORE_FRAME = 7;
    } else if (smartLv == 6) {
        IGNORE_FRAME = 14;
    } else {
        IGNORE_FRAME = 40;
    }
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:25,代码来源:Worm.java

示例8: create

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的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;
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:12,代码来源:ESDebugViewState.java

示例9: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    
    // Add a physics sphere to the world
    Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
    physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
    rootNode.attachChild(physicsSphere);
    getPhysicsSpace().add(physicsSphere);

    // Add a physics sphere to the world
    Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
    physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
    physicsSphere2.getControl(RigidBodyControl.class).addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_02);
    rootNode.attachChild(physicsSphere2);
    getPhysicsSpace().add(physicsSphere2);

    // an obstacle mesh, does not move (mass=0)
    Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
    node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
    node2.getControl(RigidBodyControl.class).setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02);
    node2.getControl(RigidBodyControl.class).setCollideWithGroups(PhysicsCollisionObject.COLLISION_GROUP_02);
    rootNode.attachChild(node2);
    getPhysicsSpace().add(node2);

    // the floor, does not move (mass=0)
    Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Box(Vector3f.ZERO, 100f, 0.2f, 100f)), 0);
    node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
    rootNode.attachChild(node3);
    getPhysicsSpace().add(node3);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:34,代码来源:TestCollisionGroups.java

示例10: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的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);

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:TestCcd.java

示例11: prepareBullet

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
private void prepareBullet() {
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    matBullet = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    matBullet.setColor("Color", ColorRGBA.Green);
    matBullet.setColor("m_GlowColor", ColorRGBA.Green);
    getPhysicsSpace().addCollisionListener(this);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:TestWalkingChar.java

示例12: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);

    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));

    initMaterial();
    initWall();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 6f, 6f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(15);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
    inputManager.addListener(actionListener, "gc");

    rootNode.setShadowMode(ShadowMode.Off);
    bsr = new BasicShadowRenderer(assetManager, 256);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    viewPort.addProcessor(bsr);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:TestBrickWall.java

示例13: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的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.4f);

    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());

    // add ourselves as collision listener
    getPhysicsSpace().addCollisionListener(this);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:TestCollisionListener.java

示例14: simpleInitApp

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
        stateManager.attach(bulletAppState);
        bullet = new Sphere(32, 32, 0.4f, true, false);
        bullet.setTextureMode(TextureMode.Projected);
        bulletCollisionShape = new SphereCollisionShape(0.4f);

        brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth);
        brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
//        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
        initMaterial();
        initTower();
        initFloor();
        initCrossHairs();
        this.cam.setLocation(new Vector3f(0, 25f, 8f));
        cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
        cam.setFrustumFar(80);
        inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(actionListener, "shoot");
        rootNode.setShadowMode(ShadowMode.Off);
        bsr = new PssmShadowRenderer(assetManager, 2048, 3);
        bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
        bsr.setLambda(0.55f);
        bsr.setShadowIntensity(0.6f);
        bsr.setCompareMode(CompareMode.Hardware);
        bsr.setFilterMode(FilterMode.Bilinear);
        viewPort.addProcessor(bsr);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:TestBrickTower.java

示例15: Gumball

import com.jme3.bullet.collision.shapes.SphereCollisionShape; //导入依赖的package包/类
public Gumball(String name, Material mat, Node target) {
    s = new Sphere(32, 32, radius);
    g = new Geometry(name, s);
    g.setMaterial(mat);
    g.setName("gumball");
    //sp=assetManager.loadModel("Models/Mothership/Alien.j3o");
    //sp.setName(name);
    
    // Greater radius than geo radius makes for much hit better detection
    control = new DroneControl(new SphereCollisionShape(radius + 0.1f), 1f, target);
    control.setImpulse(Vector3f.UNIT_XYZ.mult(0.2f));
    control.setLinearDamping(0.8f);
    g.addControl(control);
    //sp.addControl(control);
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:16,代码来源:Gumball.java


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