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


Java PhysicsCollisionEvent.getNodeB方法代码示例

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


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

示例1: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    boolean isA = spatial == event.getNodeA();
    boolean isB = spatial == event.getNodeB();
    if (!isA && !isB) {
        return;
    }

    Spatial other = isA ? event.getNodeB() : event.getNodeA();

    CInfluenceInterface otherInterface =
            other.getControl(CInfluenceInterface.class);

    if (otherInterface == null) {
        return;
    }

    damage(other, otherInterface);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:20,代码来源:CGrenade.java

示例2: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
/**
 * Handle collision between player characters and course points.
 * @see PhysicsCollisionListener#collision(PhysicsCollisionEvent)
 */
public void collision(PhysicsCollisionEvent event) {
  Spatial nodeA = event.getNodeA();
  Spatial nodeB = event.getNodeB();

  Spatial player = null;
  Spatial coursePoint = null;
  // Determine which node is the player.
  if (nodeA != null
      && nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
      && (Boolean) nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
             && (Boolean) nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeB;
  }
  // Determine which node is the course point.
  if (nodeA != null
      && nodeA.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeB;
  }
  // If collision is player and course point, check if the course
  // point is the player's target.
  if (player != null && coursePoint != null) {
    int playerTarget
        = player.getUserData(CoursePath.PLAYER_TARGET_POINT_ATTR);
    int courseOrder = coursePoint.getUserData(CoursePath.COURSE_ORDER_ATTR);
    if (playerTarget == courseOrder) {
      // Target reached. Set next target.
      int totalCoursePoints = coursePath.getCoursePoints().length;
      player.setUserData(CoursePath.PLAYER_TARGET_POINT_ATTR,
                         (playerTarget + 1) % totalCoursePoints);
      player.setUserData(CoursePath.PLAYER_ON_COURSE_ATTR, true);
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:44,代码来源:CoursePointCollisionListener.java

示例3: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
	if (!Gripper.this.enabled) {
		return;
	}
    if (holding.size() > 0 || !checkDigitCollision) {
        return;
    }
    Spatial nodeA = event.getNodeA();
    Spatial nodeB = event.getNodeB();

    if (nodeA == leftFinger || nodeA == rightFinger) {
        if (nodeB == leftFinger || nodeB == rightFinger || nodeB == null) {
            return;
        }
        if (nodeA == leftFinger) {
        	leftContacts.put(event.getLocalPointA().z, nodeB);
        } else {
        	rightContacts.put(event.getLocalPointA().z, nodeB);
        }
    } else if (nodeB == leftFinger) {
    	if (nodeA == null) {
    		return;
    	}
    	leftContacts.put(event.getLocalPointB().z, nodeA);
    } else if (nodeB == rightFinger) {
    	if (nodeA == null) {
    		return;
    	}
    	rightContacts.put(event.getLocalPointB().z, nodeA);
    }
    
    fingerPressure += event.getAppliedImpulse();
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:34,代码来源:Gripper.java

示例4: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
    public void collision(PhysicsCollisionEvent event) {
        if (event.getNodeA()  == collisionChecker) {
            collisionTarget = event.getNodeB();
//            LOG.log(Level.INFO, "CollisionChaseCamera,Collision target(nodeB)={0}", event.getNodeB());
        } else if (event.getNodeB() == collisionChecker) {
            collisionTarget = event.getNodeA();
//            LOG.log(Level.INFO, "CollisionChaseCamera,Collision target(nodeA)={0}", event.getNodeB());
        }
        
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:12,代码来源:CollisionChaseCamera.java

示例5: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
public void collision(PhysicsCollisionEvent e) {
    // Check for collision with any microDrone and a bullet
    Spatial NodeA = e.getNodeA();
    Spatial NodeB = e.getNodeB();
  
    // Check for collision with a microDrone
    if(NodeA.getName().equals("microDrone")) { //check NodeA
        if(NodeB.getName().equals("bullet")) {
            shockwave.explode(NodeA.getWorldTranslation());
            bulletAppState.getPhysicsSpace().remove(e.getNodeA());
            e.getNodeA().removeFromParent();
            megaDrone.removeMinion(NodeA);
            boomSound.setLocalTranslation(NodeA.getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MicroDrone.points);
        } else if(NodeB.getName().equals("player")) {
             //TODO: make the player move or mess up the controls a bit or score

        }
    } else if(NodeB.getName().equals("microDrone")) {  //check NodeB
        if(NodeA.getName().equals("bullet")) {
            shockwave.explode(NodeA.getWorldTranslation());
            bulletAppState.getPhysicsSpace().remove(e.getNodeB());
            e.getNodeB().removeFromParent();
            megaDrone.removeMinion(NodeB);
            boomSound.setLocalTranslation(NodeB.getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeB.getName(), MicroDrone.points);
        } else if (NodeA.getName().equals("player")) {
             //TODO: make the player move or mess up the controls a bit or score
        }
    }
    
    // Check for infiltration of the mother ship's airspace
    if(megaDrone.getGhostControl().getOverlappingObjects().contains(playerNode.getControl(CharacterControl.class))) {
        MicroDrone m = megaDrone.createMicroDrone(ball_A, player.getPhysicsLocation());
        if(m != null) {
            Vector3f v = playerNode.getWorldTranslation().
                    subtract(megaDrone.getSpatial().getWorldTranslation()).normalize();
            m.getRigidBodyControl().setPhysicsLocation(megaDrone.getSpatial().getWorldTranslation().add(v.mult(10f)));
            rootNode.attachChild(m.getGeo());
            bulletAppState.getPhysicsSpace().add(m.getRigidBodyControl()); 
        }
    }
    
    // Check for bullet hitting megaDrone
    if(NodeA.getName().equals("megaDrone") && NodeB.getName().equals("bullet")) {
        megaDrone.hit();
        if(megaDrone.gethealth() > 0) {
            megaDroneHitSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            megaDroneHitSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.hitPoint);
        } else {
            boomSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.killPoint);
        }
        
    } else if(NodeB.getName().equals("megaDrone") && NodeA.getName().equals("bullet")) {
        megaDrone.hit();
        if(megaDrone.gethealth() > 0) {
            megaDroneHitSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            megaDroneHitSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.hitPoint);
        } else {
            boomSound.setLocalTranslation(megaDrone.getSpatial().getWorldTranslation());
            boomSound.playInstance();
            stateManager.getState(GuiAppState.class).showHitObject(NodeA.getName(), MegaDrone.killPoint);
        }
    }
    
    // Remove the bullet physics control from the world
    if(NodeA.getName().equals("bullet")) {
        bulletAppState.getPhysicsSpace().remove(e.getNodeA());
        NodeA.removeFromParent();
    } else if(NodeB.getName().equals("bullet")) {
        bulletAppState.getPhysicsSpace().remove(e.getNodeB());
        NodeB.removeFromParent();       
    }
}
 
开发者ID:melombuki,项目名称:JMonkeyGame,代码行数:81,代码来源:PlayAppState.java

示例6: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    if (event.getNodeA() == null || event.getNodeB() == null) {
        return;
    }

    Spatial wallA = null;
    Spatial wallB = null;

    if (event.getObjectA().getCollisionGroup() == CollisionGroups.WALLS) {
        wallA = event.getNodeA();
    }

    if (event.getObjectB().getCollisionGroup() == CollisionGroups.WALLS) {
        wallB = event.getNodeB();
    }

    CInfluenceInterface characterA
            = event.getNodeA().getControl(CInfluenceInterface.class);
    CInfluenceInterface characterB
            = event.getNodeB().getControl(CInfluenceInterface.class);

    CProjectile projectileA = event.getNodeA().getControl(CProjectile.class);
    CProjectile projectileB = event.getNodeB().getControl(CProjectile.class);

    CSpiritStonePhysics ssPhysicsA
            = event.getNodeA().getControl(CSpiritStonePhysics.class);
    CSpiritStonePhysics ssPhysicsB
            = event.getNodeB().getControl(CSpiritStonePhysics.class);

    CSkyDrop skyDrop = event.getNodeA().getControl(CSkyDrop.class);
    if (skyDrop == null) {
        skyDrop = event.getNodeB().getControl(CSkyDrop.class);
    }
    if (skyDrop != null) {
        skyDrop.onGroundCollision();
    }

    if (projectileA != null) {
        if (projectileA.getSpatial().getParent() == null) {
            return;
        }

        if (characterB != null) {
            projectileCharacterCollision(projectileA, characterB);
        } else if (wallB != null) {
            projectileWallCollision(projectileA, wallB);
        } else if (ssPhysicsB != null) {
            projectileWallCollision(projectileA,
                    (Spatial) ssPhysicsB.getUserObject());
        }
    }
    if (projectileB != null) {
        if (projectileB.getSpatial().getParent() == null) {
            return;
        }

        if (characterA != null) {
            projectileCharacterCollision(projectileB, characterA);
        } else if (wallA != null) {
            projectileWallCollision(projectileB, wallA);
        } else if (ssPhysicsA != null) {
            projectileWallCollision(projectileB,
                    (Spatial) ssPhysicsA.getUserObject());
        }
    }

}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:69,代码来源:ServerWorldCollisionListener.java

示例7: collision

import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
    boolean isA = myStone == event.getNodeA();
    boolean isB = myStone == event.getNodeB();
    if (!isA && !isB) {
        return;
    }

    Spatial other = isA ? event.getNodeB() : event.getNodeA();

    if (other == null) {
        return;
    }

    int myCollisionGroup = isA ? event.getObjectA().getCollisionGroup()
            : event.getObjectB().getCollisionGroup();

    if (myCollisionGroup == CollisionGroups.NONE) {
        return;
    }

    PhysicsCollisionObject otherPhysics = isA ? event.getObjectB()
            : event.getObjectA();
    int otherCollisionGroup = otherPhysics.getCollisionGroup();

    CSpiritStonePhysics stonePhysics =
            myStone.getControl(CSpiritStonePhysics.class);

    int stoneId = myStone.getUserData(UserData.ENTITY_ID);

    Integer otherTeamId = other.getUserData(UserData.TEAM_ID);
    if (otherTeamId == null) {
        if (stonePhysics.isPunched()) {
            world.removeEntity(stoneId, RemovalReasons.COLLISION);
        } else {
        }
        return;
    }
    int myTeamId = myStone.getUserData(UserData.TEAM_ID);

    CInfluenceInterface influenceInterface =
            other.getControl(CInfluenceInterface.class);
    if (influenceInterface != null && stonePhysics.isPunched()
            && !otherTeamId.equals(myTeamId)) {

        CActionQueue cQueue = other.getControl(CActionQueue.class);
        EntityAction currentAction = cQueue.getCurrent();

        int ownerId = myStone.getUserData(UserData.PLAYER_ID);
        int playerEntityId = PlayerData
                .getIntData(ownerId, PlayerData.ENTITY_ID);
        Spatial playerEntity = world.getEntity(playerEntityId);

        if (currentAction != null && currentAction instanceof ATrance) {
            ((ATrance) currentAction).activate(playerEntity);
            world.removeEntity(stoneId, RemovalReasons.COLLISION);
            return;
        }

        CInfluenceInterface playerInterface =
                playerEntity.getControl(CInfluenceInterface.class);

        CharacterInteraction.harm(playerInterface, influenceInterface,
                M1_COMBINATION_DAMAGE, null, true);
        world.removeEntity(stoneId, RemovalReasons.COLLISION);
    } else if (stonePhysics.isPunched()
            && otherCollisionGroup == CollisionGroups.WALLS) {
        world.removeEntity(stoneId, RemovalReasons.COLLISION);
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:71,代码来源:SpiritStoneCollisionListener.java


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