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


Java PhysicsCollisionObject.getUserObject方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: collision

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    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;
        }
    }

    if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
        Spatial otherSpatial = (Spatial) otherObject.getUserObject();
        if (!spatial.getUserData(UserData.TEAM_ID).equals(otherSpatial.getUserData(UserData.TEAM_ID))) {
            enemy = otherSpatial;
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:36,代码来源:Disc.java

示例5: 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;
    }
    if (otherObject.getUserObject() == ignored) {
        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,代码行数:34,代码来源:CMovementForcer.java

示例6: BulletControl

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入方法依赖的package包/类
public BulletControl(Vector3f bornPlace, Geometry bullet, BulletAppState state, CollisionShape shape, SimpleApplication asm) {

        this.bullet = bullet;
        this.bullet.setUserData("Type", "Bullet");
        this.state = state;
        this.bornPlace = bornPlace.clone();
        this.asm = asm;
        
        hit = 1000f;
        
        vecMove = bullet.getLocalRotation().mult(Vector3f.UNIT_Z).normalizeLocal().mult(7f);        
        bulletLength = 100f;
        work = true;
        
//        // testRay
//        Geometry geoRay = new Geometry("line", new Line(bullet.getLocalTranslation().clone(), bullet.getLocalTranslation().add(bullet.getLocalRotation().mult(Vector3f.UNIT_Z).normalizeLocal().mult(bulletLength))));
//        Material mat_bullet = new Material(asm.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
//        mat_bullet.setColor("Color", ColorRGBA.Red);
//        geoRay.setMaterial(mat_bullet);
//        asm.getRootNode().attachChild(geoRay);
        
        List<PhysicsRayTestResult> rayTest = this.state.getPhysicsSpace().rayTest(this.bornPlace.add(bullet.getLocalRotation().mult(Vector3f.UNIT_Z).normalizeLocal()), this.bornPlace.add(bullet.getLocalRotation().mult(Vector3f.UNIT_Z).normalizeLocal().mult(bulletLength)));
        if (rayTest.size() > 0) {
            for (Object obj : rayTest) {
            PhysicsRayTestResult getObject = (PhysicsRayTestResult) obj;
            float fl = getObject.getHitFraction();
            PhysicsCollisionObject collisionObject = getObject.getCollisionObject();
            Spatial spThis = (Spatial) collisionObject.getUserObject();
            
            if (fl < hit && !spThis.getUserData("Type").equals("Player")) {
                hit = fl;
                sp = spThis;
            } 
            
            }

            System.out.println(rayTest.size());
            
          if (!sp.getUserData("Type").equals("Bullet") && !sp.getUserData("Type").equals("Player") 
                  && !sp.getUserData("Type").equals("Shit")) { 
              
//            float hit = getObject.getHitFraction();            
            System.out.println(hit);
        Vector3f vecHit = this.bornPlace.add(bullet.getLocalRotation().clone().mult(Vector3f.UNIT_Z).normalizeLocal().mult(bulletLength * hit));    
        
        
        contactPoint = vecHit;    
              
             }
           }        
        
    }
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:53,代码来源:BulletControl.java

示例7: collision

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    // TODO: This was copied from ACharge almost exactly. It might be time
    // to write common method for this?
    if (hasCollided) {
        return;
    }
    if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
            || (event.getObjectA().getUserObject()
            == event.getObjectB().getUserObject())) {
        return;
    }

    Spatial spatial = (Spatial) ghost.getUserObject();

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

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

    Spatial collidedWith = (Spatial) otherObject.getUserObject();
    EntityAction aCurrent
            = collidedWith.getControl(CActionQueue.class).getCurrent();

    if (aCurrent instanceof ATrance) {
        ((ATrance) aCurrent).activate(spatial);
        ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
        return;
    }

    hasCollided = true;

    Vector3f impulse = collidedWith.getLocalTranslation()
            .subtract(spatial.getLocalTranslation()).setY(0f)
            .normalizeLocal().multLocal(25000f);

    collidedWith.getControl(CCharacterPhysics.class).applyImpulse(impulse);
    CharacterInteraction.harm(spatial.getControl(CInfluenceInterface.class),
            collidedWith.getControl(CInfluenceInterface.class),
            100f, null, true);

    ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:53,代码来源:ElectroCharge.java

示例8: physicsTick

import com.jme3.bullet.collision.PhysicsCollisionObject; //导入方法依赖的package包/类
@Override
public void physicsTick(PhysicsSpace space, float tpf) {
    // HACK
    CActionQueue actionQueue = getSpatial().getControl(CActionQueue.class);
    if (actionQueue != null && actionQueue.getCurrent() instanceof ADelay) {
        return;
    }

    int myTeamId = spatial.getUserData(UserData.TEAM_ID);
    List<PhysicsCollisionObject> collisionObjects
            = ghostControl.getOverlappingObjects();

    for (PhysicsCollisionObject collisionObject : collisionObjects) {
        if (!(collisionObject.getUserObject() instanceof Spatial)) {
            continue;
        }
        Spatial other = (Spatial) collisionObject.getUserObject();
        CInfluenceInterface targetInterface
                = other.getControl(CInfluenceInterface.class);

        if (targetInterface == null) {
            continue;
        }

        int othersPlayerId = other.getUserData(UserData.PLAYER_ID);
        int othersTeamId = PlayerData.getIntData(othersPlayerId,
                PlayerData.TEAM_ID);
        boolean sameTeam = myTeamId == othersTeamId;
        for (Influence influence : influences) {
            if (sameTeam && influence.isFriendly()) {
                targetInterface.addInfluence(influence);
            } else if (!sameTeam && !influence.isFriendly()) {
                targetInterface.addInfluence(influence);
            }
        }

        if (!enteredPlayers.containsKey(targetInterface)
                && !enterBuffs.isEmpty()) {
            enteredPlayers.put(targetInterface, false);
            if (sameTeam) {
                CharacterInteraction.help(ownerInterface, targetInterface,
                        0f, enterBuffs);
            } else {
                CharacterInteraction.harm(ownerInterface, targetInterface,
                        0f, enterBuffs, false);
            }
        }
    }
    // TODO: Add way to inflict exitBuffs
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:51,代码来源:CAreaEffect.java


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