本文整理汇总了Java中com.jme3.bullet.collision.PhysicsCollisionEvent类的典型用法代码示例。如果您正苦于以下问题:Java PhysicsCollisionEvent类的具体用法?Java PhysicsCollisionEvent怎么用?Java PhysicsCollisionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysicsCollisionEvent类属于com.jme3.bullet.collision包,在下文中一共展示了PhysicsCollisionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
EntityId a = (EntityId)event.getObjectA().getUserObject();
EntityId b = (EntityId)event.getObjectB().getUserObject();
//change collision list of a
Collision collisionComponent = entityData.getComponent(a, Collision.class);
if(collisionComponent == null){
collisionComponent = new Collision(new HashSet<>());
}
Set<EntityId> collisions = collisionComponent.getCollisions();
collisions.add(b);
entityData.setComponent(a, new Collision(collisions));
//change collision list of b
collisionComponent = entityData.getComponent(b, Collision.class);
if(collisionComponent == null){
collisionComponent = new Collision(new HashSet<>());
}
collisions = collisionComponent.getCollisions();
collisions.add(a);
entityData.setComponent(b, new Collision(collisions));
}
示例2: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
if (space == null) {
return;
}
if (event.getObjectA() == this || event.getObjectB() == this) {
space.add(ghostObject);
ghostObject.setPhysicsLocation(getPhysicsLocation(vector));
space.addTickListener(this);
if (effect != null && spatial.getParent() != null) {
curTime = 0;
effect.setLocalTranslation(spatial.getLocalTranslation());
spatial.getParent().attachChild(effect);
effect.emitAllParticles();
}
space.remove(this);
spatial.removeFromParent();
}
}
示例3: 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);
}
示例4: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent pce) {
if ( !(pce.getNodeA().getUserData("entity") instanceof Actor && pce.getNodeB().getUserData("entity") instanceof Actor) ) return;
Actor first = (Actor) (pce.getNodeA().getUserData("entity"));
Actor second = (Actor) (pce.getNodeB().getUserData("entity"));
if(first instanceof Player && second instanceof Player)
return;
if(second instanceof Player)
playerCollision(first, (Player)second, pce);
else if(first instanceof Player)
playerCollision((Player)first, second, pce);
else
mobCollision(first, second, pce);
}
示例5: 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);
}
}
}
示例6: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
if ("Box".equals(event.getNodeA().getName()) || "Box".equals(event.getNodeB().getName())) {
if ("bullet".equals(event.getNodeA().getName()) || "bullet".equals(event.getNodeB().getName())) {
fpsText.setText("You hit the box!");
}
}
}
示例7: collide
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的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();
}
示例8: distributeEvents
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void distributeEvents() {
//add collision callbacks
synchronized (collisionEvents) {
for (Iterator<PhysicsCollisionEvent> it = collisionEvents.iterator(); it.hasNext();) {
PhysicsCollisionEvent physicsCollisionEvent = it.next();
for (PhysicsCollisionListener listener : collisionListeners) {
listener.collision(physicsCollisionEvent);
}
//recycle events
eventFactory.recycle(physicsCollisionEvent);
it.remove();
}
}
}
示例9: 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();
}
示例10: 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());
}
}
示例11: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
if ( event.getNodeA().equals(enemyShip) && event.getNodeB().getName().indexOf("enemy") == 0){
randomMoveVec = true;
} else if ( event.getNodeB().equals(enemyShip) && event.getNodeA().getName().indexOf("enemy") == 0){
randomMoveVec = true;
} else randomMoveVec = false;
}
示例12: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
// if ((event.getNodeA() != null && event.getNodeB() != null)){
// Spatial A = event.getNodeA();
// Spatial B = event.getNodeB();
//// System.out.println(A + " and " + B);
//// System.out.println(event.getLocalPointA());
// Geometry geoBullet;
//
// // Destroy Bullets if they collide with Asteroids
// if((A.getUserData("Type").equals("Bullet") ||
// B.getUserData("Type").equals("Bullet")) &&
// (A.getUserData("Type").equals("Asteroid") ||
// B.getUserData("Type").equals("Asteroid"))) {
//
// if(A.getUserData("Type").equals("Bullet")) geoBullet = (Geometry) A;
// else geoBullet = (Geometry) B;
//
// if(A.getUserData("Type").equals("Asteroid") ||
// B.getUserData("Type").equals("Asteroid")) {
// geoBullet.getControl(Bullet.class).destroy();
// }
// }
// geoBullet = null;
// A = null;
// B = null;
// }
}
示例13: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的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();
}
}
示例14: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的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;
}
}
}
示例15: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入依赖的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();
}
}