translation.set(tIn);
rotation.set(rIn);
viewRot.set(rotation);
viewTranslation.set(translation);
Vector3f cameraTrans = rotation.mult(offset);
// System.out.println("Camera trans "+cameraTrans );
translation.addLocal(cameraTrans);
// handle camera collision
if (COLLISION_GLOBAL_ENABLE && (collisionEnabled || collisionCheck)) {
Vector3f dir = new Vector3f(translation);
Vector3f target = new Vector3f(tIn);
target.addLocal(0, DEFAULT_OFFSET.y, 0);
dir.subtractLocal(target).normalizeLocal();
Ray ray = new Ray(target, dir);
PickInfo info = collisionSys.pickAllWorldRay(ray, true, false,
false, cameraComp);
for (int i = 0; i < info.size(); i++) {
// find the next picked object
PickDetails details = info.get(i);
// if the distance is less than the minimum, try the next
// info
if (details.getDistance() < MIN_DISTANCE) {
continue;
}
// if we are performing a collision check, see if the
// camera is closer than the collision
if (collisionCheck) {
if (target.distance(translation) <= details.getDistance()) {
// camera is closer than the nearest collision,
// re-enable collision
collisionEnabled = true;
}
// only check the first collision
break;
}
// if the collision is farther than where the camera would
// have been positioned or outside of range, we can stop and
// leave the camera as is
if (details.getDistance() >= MAX_DISTANCE ||
details.getDistance() >= target.distance(translation))
{
break;
}
// if we made it here, the collision is within range. Move