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


Java PhysicsCollisionEvent类代码示例

本文整理汇总了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));
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:22,代码来源:CollisionSystem.java

示例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();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:BombControl.java

示例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);
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:20,代码来源:CGrenade.java

示例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);
}
 
开发者ID:GSam,项目名称:Game-Project,代码行数:18,代码来源:ActorCollisionManager.java

示例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);
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:44,代码来源:CoursePointCollisionListener.java

示例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!");
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:TestCollisionListener.java

示例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();

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

示例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();
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:PhysicsSpace.java

示例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();
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:34,代码来源:Gripper.java

示例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());
        }
        
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:12,代码来源:CollisionChaseCamera.java

示例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;
    
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:9,代码来源:NPCControl.java

示例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;
//        }
        
      }
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:31,代码来源:ShipWeaponControl.java

示例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();
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:38,代码来源:ACharge.java

示例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;
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:36,代码来源:Disc.java

示例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();
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:34,代码来源:CMovementForcer.java


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