本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}
}
示例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;
}
}
}
示例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();
}
}
示例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;
}
}
}
示例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);
}
示例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
}