• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CylinderCollisionShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createShape

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull CollisionShape createShape(@NotNull final VarTable vars) {
    final Vector3f halfExtents = vars.get(PROPERTY_HALF_EXTENTS);
    final Axis axis = vars.get(PROPERTY_AXIS);
    return new CylinderCollisionShape(halfExtents, axis.ordinal());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:CreateCylinderCollisionShapeAction.java


示例2: addLinkPhysics

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
private void addLinkPhysics(String name, Node parentNode,
        float mass, float radius, float height,
        float xOffset, float yOffset, float zOffset) {
    Node node = new Node(name + " collision center");
    node.setLocalTranslation(xOffset * SCALE, yOffset * SCALE, zOffset * SCALE);
    parentNode.attachChild(node);
    // make an upright cylinder
    vec.set(radius * SCALE, height / 2 * SCALE, radius * SCALE);
    CylinderCollisionShape cs = new CylinderCollisionShape(vec, 1);
    MyRigidBodyControl rbc = new MyRigidBodyControl(cs, mass * SCALE);
    node.addControl(rbc);
    physicsSpace.add(rbc);
    rbc.setKinematic(true);
    phyList.add(rbc);
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:16,代码来源:Robot.java


示例3: CylinderCollisionShapeTreeNode

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
public CylinderCollisionShapeTreeNode(@NotNull final CylinderCollisionShape element, final long objectId) {
    super(element, objectId);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:4,代码来源:CylinderCollisionShapeTreeNode.java


示例4: simpleInitApp

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的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 using the collision shape from sphere one
        Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
        physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
        rootNode.attachChild(physicsSphere2);
        getPhysicsSpace().add(physicsSphere2);

        // Add a physics box to the world
        Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
        physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
        physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
        rootNode.attachChild(physicsBox);
        getPhysicsSpace().add(physicsBox);

        // Add a physics cylinder to the world
        Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
        physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
        rootNode.attachChild(physicsCylinder);
        getPhysicsSpace().add(physicsCylinder);

        // 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));
        rootNode.attachChild(node2);
        getPhysicsSpace().add(node2);

        // the floor mesh, does not move (mass=0)
        Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
        rootNode.attachChild(node3);
        getPhysicsSpace().add(node3);

        // Join the physics objects with a Point2Point joint
//        PhysicsPoint2PointJoint joint=new PhysicsPoint2PointJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0));
//        PhysicsHingeJoint joint=new PhysicsHingeJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
//        getPhysicsSpace().add(joint);

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


示例5: simpleInitApp

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    physicsRootNode=new Node("PhysicsRootNode");
    rootNode.attachChild(physicsRootNode);

    // 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 using the collision shape from sphere one
    Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
    physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
    rootNode.attachChild(physicsSphere2);
    getPhysicsSpace().add(physicsSphere2);

    // Add a physics box to the world
    Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
    physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
    physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
    rootNode.attachChild(physicsBox);
    getPhysicsSpace().add(physicsBox);

    // Add a physics cylinder to the world
    Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
    physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
    rootNode.attachChild(physicsCylinder);
    getPhysicsSpace().add(physicsCylinder);

    // 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));
    rootNode.attachChild(node2);
    getPhysicsSpace().add(node2);

    // the floor mesh, does not move (mass=0)
    Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
    node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
    rootNode.attachChild(node3);
    getPhysicsSpace().add(node3);

    // Join the physics objects with a Point2Point joint
    HingeJoint joint=new HingeJoint(physicsSphere.getControl(RigidBodyControl.class), physicsBox.getControl(RigidBodyControl.class), new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
    getPhysicsSpace().add(joint);

    //save and load the physicsRootNode
    try {
        //remove all physics objects from physics space
        getPhysicsSpace().removeAll(physicsRootNode);
        physicsRootNode.removeFromParent();
        //export to byte array
        ByteArrayOutputStream bout=new ByteArrayOutputStream();
        BinaryExporter.getInstance().save(physicsRootNode, bout);
        //import from byte array
        ByteArrayInputStream bin=new ByteArrayInputStream(bout.toByteArray());
        BinaryImporter imp=BinaryImporter.getInstance();
        imp.setAssetManager(assetManager);
        Node newPhysicsRootNode=(Node)imp.load(bin);
        //add all physics objects to physics space
        getPhysicsSpace().addAll(newPhysicsRootNode);
        rootNode.attachChild(newPhysicsRootNode);
    } catch (IOException ex) {
        Logger.getLogger(TestPhysicsReadWrite.class.getName()).log(Level.SEVERE, null, ex);
    }

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


示例6: simpleInitApp

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的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));
        physicsSphere.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsSphere);
        getPhysicsSpace().add(physicsSphere);

        // Add a physics sphere to the world using the collision shape from sphere one
        Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
        physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
        physicsSphere2.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsSphere2);
        getPhysicsSpace().add(physicsSphere2);

        // Add a physics box to the world
        Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
        physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
        physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
        physicsBox.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsBox);
        getPhysicsSpace().add(physicsBox);

        // Add a physics cylinder to the world
        Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
        physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
        physicsCylinder.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(physicsCylinder);
        getPhysicsSpace().add(physicsCylinder);

        // 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).setApplyPhysicsLocal(true);
        rootNode.attachChild(node2);
        getPhysicsSpace().add(node2);

        // the floor mesh, does not move (mass=0)
        Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
        node3.getControl(RigidBodyControl.class).setApplyPhysicsLocal(true);
        rootNode.attachChild(node3);
        getPhysicsSpace().add(node3);

        // Join the physics objects with a Point2Point joint
//        PhysicsPoint2PointJoint joint=new PhysicsPoint2PointJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0));
//        PhysicsHingeJoint joint=new PhysicsHingeJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
//        getPhysicsSpace().add(joint);

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


示例7: build

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
@Override
    public Node build(BuildParameters params) {
        Node node = (Node) assets.loadModel("Models/SpiritStone.j3o");
        node.setLocalTranslation(params.location);

        for (Spatial childToScale : node.getChildren()) {
            childToScale.scale(4f);
        }

        node.setUserData(UserData.SPEED, 145f);
        node.setUserData(UserData.MASS, 600f);
        node.setUserData(UserData.DAMAGE, 0f);
        node.setUserData(UserData.IMPULSE_FACTOR, 0f);
        node.setUserData(UserData.INCAPACITATE_LENGTH, 0f);

        // TODO: Put sound effect that's different
//        if (world.isClient()) {
//            AudioNode sound = new AudioNode(assetManager, "Effects/Sound/MagmaBash.wav");
//            node.attachChild(sound);
//            sound.setPositional(true);
//            sound.setReverbEnabled(false);
//            sound.setVolume(1f);
//            sound.play();
//        }
        SphereCollisionShape collisionShape = new SphereCollisionShape(RADIUS);
        CSpiritStonePhysics physicsBody
                = new CSpiritStonePhysics(collisionShape,
                        (float) node.getUserData(UserData.MASS), world);
        node.addControl(physicsBody);
        physicsBody.setCollisionGroup(CollisionGroups.SPIRIT_STONE);
        physicsBody.removeCollideWithGroup(CollisionGroups.SPIRIT_STONE);
        physicsBody.addCollideWithGroup(CollisionGroups.CHARACTERS
                | CollisionGroups.PROJECTILES);
        physicsBody.setAngularDamping(1f);

        node.addControl(new CTimedExistence(duration, true));
        node.addControl(new CRotation(0f, 2f, 0f));
        node.addControl(new CSyncInterpolation());

        if (world.isServer()) {
            GhostControl ghost = new GhostControl(new CylinderCollisionShape(
                    new Vector3f(influenceRadius, 0.05f, influenceRadius), 1));
            ghost.setCollideWithGroups(CollisionGroups.CHARACTERS);
            ghost.setCollisionGroup(CollisionGroups.NONE);
            node.addControl(ghost);

            CAreaEffect cAreaOfEffect = new CAreaEffect(ghost);
            node.addControl(cAreaOfEffect);

            if (primary) {
                SpeedInfluence speedInfluence = new SpeedInfluence();
                speedInfluence.setConstant(1f);
                cAreaOfEffect.addInfluence(speedInfluence);
            } else {
                SlowInfluence slowInfluence = new SlowInfluence();
                slowInfluence.setSlowFactor(0.6f);
                cAreaOfEffect.addInfluence(slowInfluence);
            }

        }

        return node;
    }
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:64,代码来源:SpiritStone.java


示例8: build

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
@Override
public Node build(final BuildParameters params) {
    final Node node = (Node) assets.loadModel("Models/Circle.j3o");
    node.setLocalTranslation(params.location);

    for (Spatial child : node.getChildren()) {
        child.setCullHint(Spatial.CullHint.Always);
    }

    final float radius = 15f;
    node.scale(radius, 1f, radius);

    Material mat = new Material(assets,
            "Common/MatDefs/Misc/Unshaded.j3md");

    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    mat.setColor("Color", ColorRGBA.BlackNoAlpha);
    node.setMaterial(mat);
    CActionQueue actionQueue = new CActionQueue();
    node.addControl(actionQueue);

    float delay = Math.max(0.8f - params.age, 0f);
    actionQueue.enqueueAction(new ADelay(delay));

    final float remainTime = 1f;

    if (world.isServer()) {
        node.addControl(new CCircleVisibility(radius));

        GhostControl ghost = new GhostControl(new CylinderCollisionShape(
                new Vector3f(radius, 0.05f, radius), 1));
        ghost.setCollideWithGroups(CollisionGroups.CHARACTERS);
        node.addControl(ghost);

        CAreaEffect cAreaEffect = new CAreaEffect(ghost);
        node.addControl(cAreaEffect);

        actionQueue.enqueueAction(new AFinish(cAreaEffect, node));
    } else if (world.isClient()) {
        ParticleEmitter black = createBlack(radius / 15f, delay);
        node.attachChild(black);
        black.setLocalTranslation(0f, 1f, 0f);
        black.emitAllParticles();

        actionQueue.enqueueAction(new EntityAction() {
            @Override
            public boolean update(float tpf) {
                Vector3f worldTranslation = spatial.getWorldTranslation();

                ParticleEmitter cyan = createCyan(radius, remainTime);
                world.getWorldRoot().attachChild(cyan);
                cyan.setLocalTranslation(worldTranslation);
                cyan.move(0f, 1f, 0f);
                cyan.addControl(new CTimedExistence(5f));
                cyan.emitAllParticles();

                ParticleEmitter white = createWhite(radius, remainTime);
                world.getWorldRoot().attachChild(white);
                white.setLocalTranslation(worldTranslation);
                white.move(0f, 1f, 0f);
                white.addControl(new CTimedExistence(5f));
                white.emitAllParticles();

                AudioNode sound = new AudioNode(assets,
                        "Effects/Sound/MindPoison.wav");
                ((Node) spatial).attachChild(sound);
                sound.setPositional(true);
                sound.setReverbEnabled(false);
                sound.setVolume(2f);
                sound.play();

                return false;
            }
        });
    }

    return node;
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:79,代码来源:ElectricPull2.java


示例9: build

import com.jme3.bullet.collision.shapes.CylinderCollisionShape; //导入依赖的package包/类
@Override
public Node build(final BuildParameters params) {
    final Node node = (Node) assets.loadModel("Models/Circle.j3o");
    node.setLocalTranslation(params.location);

    for (Spatial child : node.getChildren()) {
        child.setCullHint(Spatial.CullHint.Always);
    }

    final float radius = 15f;
    node.scale(radius, 1f, radius);

    Material mat = new Material(assets,
            "Common/MatDefs/Misc/Unshaded.j3md");

    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    mat.setColor("Color", ColorRGBA.BlackNoAlpha);
    node.setMaterial(mat);
    CActionQueue actionQueue = new CActionQueue();
    node.addControl(actionQueue);

    float delay = Math.max(0.8f - params.age, 0f);
    actionQueue.enqueueAction(new ADelay(delay));

    final float remainTime = 1f;

    if (world.isServer()) {
        node.addControl(new CCircleVisibility(radius));

        GhostControl ghost = new GhostControl(new CylinderCollisionShape(
                new Vector3f(radius, 0.05f, radius), 1));
        ghost.setCollideWithGroups(CollisionGroups.CHARACTERS);
        node.addControl(ghost);

        CAreaEffect cAreaEffect = new CAreaEffect(ghost);
        node.addControl(cAreaEffect);

        actionQueue.enqueueAction(new AFinish(cAreaEffect, node,
                remainTime));
    } else if (world.isClient()) {
        ParticleEmitter black = createBlack(radius / 15f, delay);
        node.attachChild(black);
        black.setLocalTranslation(0f, 1f, 0f);
        black.emitAllParticles();

        actionQueue.enqueueAction(new EntityAction() {
            @Override
            public boolean update(float tpf) {
                Vector3f worldTranslation = spatial.getWorldTranslation();

                final ParticleEmitter purple = createPurple(radius, remainTime);
                world.getWorldRoot().attachChild(purple);
                purple.setLocalTranslation(worldTranslation);
                purple.move(0f, 1f, 0f);
                purple.addControl(new CTimedExistence(5f));
                purple.emitAllParticles();

                final ParticleEmitter white = createWhite(radius, remainTime);
                world.getWorldRoot().attachChild(white);
                white.setLocalTranslation(worldTranslation);
                white.move(0f, 1f, 0f);
                white.addControl(new CTimedExistence(5f));
                white.emitAllParticles();
                
                AudioNode sound = new AudioNode(assets,
                        "Effects/Sound/MindPoison.wav");
                ((Node) spatial).attachChild(sound);
                sound.setPositional(true);
                sound.setReverbEnabled(false);
                sound.setVolume(2f);
                sound.play();

                return false;
            }
        });
    }

    return node;
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:80,代码来源:MindPoison.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Syntax类代码示例发布时间:2022-05-23
下一篇:
Java WidgetExtension类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap