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

Java PhysicsCollisionObject类代码示例

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

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



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

示例1: physicsTick

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
public void physicsTick(PhysicsSpace space, float f) {
    //get all overlapping objects and apply impulse to them
    for (Iterator<PhysicsCollisionObject> it = ghostObject.getOverlappingObjects().iterator(); it.hasNext();) {            
        PhysicsCollisionObject physicsCollisionObject = it.next();
        if (physicsCollisionObject instanceof PhysicsRigidBody) {
            PhysicsRigidBody rBody = (PhysicsRigidBody) physicsCollisionObject;
            rBody.getPhysicsLocation(vector2);
            vector2.subtractLocal(vector);
            float force = explosionRadius - vector2.length();
            force *= forceFactor;
            force = force > 0 ? force : 0;
            vector2.normalizeLocal();
            vector2.multLocal(force);
            ((PhysicsRigidBody) physicsCollisionObject).applyImpulse(vector2, Vector3f.ZERO);
        }
    }
    space.removeTickListener(this);
    space.remove(ghostObject);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:BombControl.java


示例2: buildPlayer

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
private void buildPlayer() {
    spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
    CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft);
    spaceCraft.setShadowMode(ShadowMode.CastAndReceive);
    spaceCraft.setLocalTranslation(new Vector3f(-140, 14, -23));
    spaceCraft.setLocalRotation(new Quaternion(new float[]{0, 0.01f, 0}));

    hoverControl = new PhysicsHoverControl(colShape, 500);
    hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02);

    spaceCraft.addControl(hoverControl);


    rootNode.attachChild(spaceCraft);
    getPhysicsSpace().add(hoverControl);

    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    spaceCraft.addControl(chaseCam);

    flyCam.setEnabled(false);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:TestHoveringTank.java


示例3: add

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * adds an object to the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to add
 */
public void add(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(this);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(this);
    } else if (obj instanceof PhysicsCollisionObject) {
        addCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        addJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space."));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:PhysicsSpace.java


示例4: remove

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:PhysicsSpace.java


示例5: controlUpdate

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
@Override
protected void controlUpdate(float tpf) {
    List<PhysicsCollisionObject> collisionObjects
            = ghost.getOverlappingObjects();
    for (PhysicsCollisionObject collisionObject : collisionObjects) {
        if (collisionObject.getUserObject() instanceof Spatial) {
            Spatial spatial = (Spatial) collisionObject.getUserObject();
            Integer entityId = spatial.getUserData(UserData.ENTITY_ID);
            if (collidedWith.contains(entityId)) {
                continue;
            }

            collidedWith.add(entityId);
            collisionEffect(spatial);
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:18,代码来源:Firewalk.java


示例6: isExplode

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
public boolean isExplode() {

        List<PhysicsCollisionObject> collision = ghost.getOverlappingObjects();
                for (int i = 0; i < collision.size(); i++) {
                    if(collision.get(i) instanceof SaGhost){
                        SaGhost sa = (SaGhost) collision.get(i);
                        if(sa.getSa().isIsShield()){
                            sa.getSa().setIsShield(false);
                            
                            shieldBroke.playInstance();
                            continue;
                        }
                        sa.getSa().die();
                    } else if(collision.get(i) instanceof WormGhost) {
                        WormGhost worm = (WormGhost) collision.get(i);
                        worm.getWorm().die();
                    }
                }
        return isExplode;
    }
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:21,代码来源:Explosion.java


示例7: remove

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * removes an object from the physics space
 * @param obj the PhysicsControl or Spatial with PhysicsControl to remove
 */
public void remove(Object obj) {
    if (obj instanceof PhysicsControl) {
        ((PhysicsControl) obj).setPhysicsSpace(null);
    } else if (obj instanceof Spatial) {
        Spatial node = (Spatial) obj;
        PhysicsControl control = node.getControl(PhysicsControl.class);
        control.setPhysicsSpace(null);
    } else if (obj instanceof PhysicsCollisionObject) {
        removeCollisionObject((PhysicsCollisionObject) obj);
    } else if (obj instanceof PhysicsJoint) {
        removeJoint((PhysicsJoint) obj);
    } else if (obj == null) {
        return;
    } else {
        throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space."+obj));
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:22,代码来源:PhysicsSpace.java


示例8: attachPhysicsSelection

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
protected void attachPhysicsSelection(Spatial geom) {
    PhysicsCollisionObject control = geom.getControl(RigidBodyControl.class);
    if (control == null) {
        control = geom.getControl(VehicleControl.class);
    }
    if (control == null) {
        control = geom.getControl(GhostControl.class);
    }
    if (control == null) {
        control = geom.getControl(CharacterControl.class);
    }
    if (control == null) {
        return;
    }
    Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape());
    if (selectionGeometry != null) {
        selectionGeometry.setMaterial(blueMat);
        selectionGeometry.setLocalTransform(geom.getWorldTransform());
        toolsNode.attachChild(selectionGeometry);
        selectionShape = selectionGeometry;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:SceneToolController.java


示例9: makePhysics

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


示例10: handleResult

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * Handle the result from the dialog.
 *
 * @param vars the table with variables.
 */
@FXThread
private void handleResult(@NotNull final VarTable vars) {

    final TreeNode<?> treeNode = getNode();
    final PhysicsCollisionObject element = (PhysicsCollisionObject) treeNode.getElement();
    final CollisionShape shape = createShape(vars);
    final CollisionShape currentShape = element.getCollisionShape();

    final NodeTree<?> nodeTree = getNodeTree();
    final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
    changeConsumer.execute(new ChangeCollisionShapeOperation(shape, currentShape, element));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:AbstractCreateShapeAction.java


示例11: simpleInitApp

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


示例12: makeMissile

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


示例13: collide

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
public void collide(Bone bone, PhysicsCollisionObject object, PhysicsCollisionEvent event) {

        if (object.getUserObject() != null && object.getUserObject() instanceof Geometry) {
            Geometry geom = (Geometry) object.getUserObject();
            if ("Floor".equals(geom.getName())) {
                return;
            }
        }

        ragdoll.setRagdollMode();

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


示例14: getOverlappingObjects

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * Another Object is overlapping with this GhostNode,
 * if and if only there CollisionShapes overlaps.
 * They could be both regular PhysicsRigidBodys or PhysicsGhostObjects.
 * @return All CollisionObjects overlapping with this GhostNode.
 */
public List<PhysicsCollisionObject> getOverlappingObjects() {
    overlappingObjects.clear();
    for (com.bulletphysics.collision.dispatch.CollisionObject collObj : gObject.getOverlappingPairs()) {
        overlappingObjects.add((PhysicsCollisionObject) collObj.getUserPointer());
    }
    return overlappingObjects;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:PhysicsGhostObject.java


示例15: getGroundObject

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
/**
 * returns the object this wheel is in contact with or null if no contact
 * @return the PhysicsCollisionObject (PhysicsRigidBody, PhysicsGhostObject)
 */
public PhysicsCollisionObject getGroundObject() {
    if (wheelInfo.raycastInfo.groundObject == null) {
        return null;
    } else if (wheelInfo.raycastInfo.groundObject instanceof RigidBody) {
        System.out.println("RigidBody");
        return (PhysicsRigidBody) ((RigidBody) wheelInfo.raycastInfo.groundObject).getUserPointer();
    } else {
        return null;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:VehicleWheel.java


示例16: setOverlapFilterCallback

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
private void setOverlapFilterCallback() {
    OverlapFilterCallback callback = new OverlapFilterCallback() {

        public boolean needBroadphaseCollision(BroadphaseProxy bp, BroadphaseProxy bp1) {
            boolean collides = (bp.collisionFilterGroup & bp1.collisionFilterMask) != 0;
            if (collides) {
                collides = (bp1.collisionFilterGroup & bp.collisionFilterMask) != 0;
            }
            if (collides) {
                assert (bp.clientObject instanceof com.bulletphysics.collision.dispatch.CollisionObject && bp.clientObject instanceof com.bulletphysics.collision.dispatch.CollisionObject);
                com.bulletphysics.collision.dispatch.CollisionObject colOb = (com.bulletphysics.collision.dispatch.CollisionObject) bp.clientObject;
                com.bulletphysics.collision.dispatch.CollisionObject colOb1 = (com.bulletphysics.collision.dispatch.CollisionObject) bp1.clientObject;
                assert (colOb.getUserPointer() != null && colOb1.getUserPointer() != null);
                PhysicsCollisionObject collisionObject = (PhysicsCollisionObject) colOb.getUserPointer();
                PhysicsCollisionObject collisionObject1 = (PhysicsCollisionObject) colOb1.getUserPointer();
                if ((collisionObject.getCollideWithGroups() & collisionObject1.getCollisionGroup()) > 0
                        || (collisionObject1.getCollideWithGroups() & collisionObject.getCollisionGroup()) > 0) {
                    PhysicsCollisionGroupListener listener = collisionGroupListeners.get(collisionObject.getCollisionGroup());
                    PhysicsCollisionGroupListener listener1 = collisionGroupListeners.get(collisionObject1.getCollisionGroup());
                    if (listener != null) {
                        return listener.collide(collisionObject, collisionObject1);
                    } else if (listener1 != null) {
                        return listener1.collide(collisionObject, collisionObject1);
                    }
                    return true;
                } else {
                    return false;
                }
            }
            return collides;
        }
    };
    dynamicsWorld.getPairCache().setOverlapFilterCallback(callback);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:PhysicsSpace.java


示例17: addCollisionObject

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
public void addCollisionObject(PhysicsCollisionObject obj) {
    if (obj instanceof PhysicsGhostObject) {
        addGhostObject((PhysicsGhostObject) obj);
    } else if (obj instanceof PhysicsRigidBody) {
        addRigidBody((PhysicsRigidBody) obj);
    } else if (obj instanceof PhysicsVehicle) {
        addRigidBody((PhysicsVehicle) obj);
    } else if (obj instanceof PhysicsCharacter) {
        addCharacter((PhysicsCharacter) obj);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:PhysicsSpace.java


示例18: removeCollisionObject

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
public void removeCollisionObject(PhysicsCollisionObject obj) {
    if (obj instanceof PhysicsGhostObject) {
        removeGhostObject((PhysicsGhostObject) obj);
    } else if (obj instanceof PhysicsRigidBody) {
        removeRigidBody((PhysicsRigidBody) obj);
    } else if (obj instanceof PhysicsCharacter) {
        removeCharacter((PhysicsCharacter) obj);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:PhysicsSpace.java


示例19: attachPhysicsSelection

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
protected void attachPhysicsSelection(Spatial geom) {
    PhysicsCollisionObject control = geom.getControl(RigidBodyControl.class);
    if (control == null) {
        control = geom.getControl(VehicleControl.class);
    }
    if (control == null) {
        control = geom.getControl(GhostControl.class);
    }
    if (control == null) {
        control = geom.getControl(CharacterControl.class);
    }
    if (control == null) {
        return;
    }
    final Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape());
    if (selectionGeometry != null) {
        selectionGeometry.setMaterial(blueMat);
        selectionGeometry.setLocalTransform(geom.getWorldTransform());
        selectionShape = selectionGeometry;
        SceneApplication.getApplication().enqueue(new Callable<Object>() {

            public Object call() throws Exception {
                toolsNode.attachChild(selectionGeometry);
                return null;
            }
        });
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:29,代码来源:SceneToolController.java


示例20: collision

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if (hasCollided) {
        return;
    }
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }

    PhysicsCollisionObject otherObject =
            event.getObjectA().getUserObject() == spatial
            ? event.getObjectB()
            : event.getObjectA();

    int otherCollisionGroup = otherObject.getCollisionGroup();
    if (otherCollisionGroup != CollisionGroups.CHARACTERS
            && otherCollisionGroup != CollisionGroups.WALLS
            && otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
        return;
    }
    
    // This filters away shields
    if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
        Spatial targetSpatial = (Spatial) otherObject.getUserObject();
        if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
            return;
        }
    }

    hasCollided = true;

    if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
        collidedWith = (Spatial) otherObject.getUserObject();
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:38,代码来源:ACharge.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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