use of com.jme3.bullet.collision.PhysicsRayTestResult in project jmonkeyengine by jMonkeyEngine.
the class TestPhysicsRayCast method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
List<PhysicsRayTestResult> rayTest = bulletAppState.getPhysicsSpace().rayTest(cam.getLocation(), cam.getLocation().add(cam.getDirection()));
if (rayTest.size() > 0) {
PhysicsRayTestResult get = rayTest.get(0);
PhysicsCollisionObject collisionObject = get.getCollisionObject();
//do stuff
fpsText.setText(collisionObject.getUserObject().toString());
}
}
use of com.jme3.bullet.collision.PhysicsRayTestResult in project jmonkeyengine by jMonkeyEngine.
the class BetterCharacterControl method checkCanUnDuck.
/**
* This checks if the character can go from ducked to unducked state by
* doing a ray test.
*/
protected boolean checkCanUnDuck() {
TempVars vars = TempVars.get();
Vector3f location = vars.vect1;
Vector3f rayVector = vars.vect2;
location.set(localUp).multLocal(FastMath.ZERO_TOLERANCE).addLocal(this.location);
rayVector.set(localUp).multLocal(height + FastMath.ZERO_TOLERANCE).addLocal(location);
List<PhysicsRayTestResult> results = space.rayTest(location, rayVector);
vars.release();
for (PhysicsRayTestResult physicsRayTestResult : results) {
if (!physicsRayTestResult.getCollisionObject().equals(rigidBody)) {
return false;
}
}
return true;
}
use of com.jme3.bullet.collision.PhysicsRayTestResult in project jmonkeyengine by jMonkeyEngine.
the class BetterCharacterControl method checkOnGround.
/**
* This checks if the character is on the ground by doing a ray test.
*/
protected void checkOnGround() {
TempVars vars = TempVars.get();
Vector3f location = vars.vect1;
Vector3f rayVector = vars.vect2;
float height = getFinalHeight();
location.set(localUp).multLocal(height).addLocal(this.location);
rayVector.set(localUp).multLocal(-height - 0.1f).addLocal(location);
List<PhysicsRayTestResult> results = space.rayTest(location, rayVector);
vars.release();
for (PhysicsRayTestResult physicsRayTestResult : results) {
if (!physicsRayTestResult.getCollisionObject().equals(rigidBody)) {
onGround = true;
return;
}
}
onGround = false;
}
Aggregations