use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class BresenhamYUpGridTracer method startWalk.
public void startWalk(final Ray walkRay) {
// store ray
this.walkRay.set(walkRay);
// simplify access to direction
Vector3f direction = this.walkRay.getDirection();
// Move start point to grid space
Vector3f start = this.walkRay.getOrigin().subtract(gridOrigin);
gridLocation.x = (int) (start.x / gridSpacing.x);
gridLocation.y = (int) (start.z / gridSpacing.z);
Vector3f ooDirection = new Vector3f(1.0f / direction.x, 1, 1.0f / direction.z);
// Check which direction on the X world axis we are moving.
if (direction.x > TOLERANCE) {
distToNextXIntersection = ((gridLocation.x + 1) * gridSpacing.x - start.x) * ooDirection.x;
distBetweenXIntersections = gridSpacing.x * ooDirection.x;
stepXDirection = 1;
} else if (direction.x < -TOLERANCE) {
distToNextXIntersection = (start.x - (gridLocation.x * gridSpacing.x)) * -direction.x;
distBetweenXIntersections = -gridSpacing.x * ooDirection.x;
stepXDirection = -1;
} else {
distToNextXIntersection = Float.MAX_VALUE;
distBetweenXIntersections = Float.MAX_VALUE;
stepXDirection = 0;
}
// Check which direction on the Z world axis we are moving.
if (direction.z > TOLERANCE) {
distToNextZIntersection = ((gridLocation.y + 1) * gridSpacing.z - start.z) * ooDirection.z;
distBetweenZIntersections = gridSpacing.z * ooDirection.z;
stepZDirection = 1;
} else if (direction.z < -TOLERANCE) {
distToNextZIntersection = (start.z - (gridLocation.y * gridSpacing.z)) * -direction.z;
distBetweenZIntersections = -gridSpacing.z * ooDirection.z;
stepZDirection = -1;
} else {
distToNextZIntersection = Float.MAX_VALUE;
distBetweenZIntersections = Float.MAX_VALUE;
stepZDirection = 0;
}
// Reset some variables
rayLocation.set(start);
rayLength = 0.0f;
stepDirection = Direction.None;
}
use of com.jme3.terrain.geomipmap.picking.BresenhamYUpGridTracer.Direction in project jmonkeyengine by jMonkeyEngine.
the class VRGuiManager method rotateScreenTo.
/**
* Rotate the GUI to the given direction.
* @param dir the direction to rotate to.
* @param tpf the time per frame.
*/
private void rotateScreenTo(Quaternion dir, float tpf) {
dir.getRotationColumn(2, look).negateLocal();
dir.getRotationColumn(0, left).negateLocal();
orient.fromAxes(left, dir.getRotationColumn(1, up), look);
Quaternion rot = tempq.fromRotationMatrix(orient);
if (posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH) {
VRUtil.stripToYaw(rot);
}
if (guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL) {
// mix pos & dir with current pos & dir
EoldDir.nlerp(rot, tpf * guiPositioningElastic);
guiQuadNode.setLocalRotation(EoldDir);
} else {
guiQuadNode.setLocalRotation(rot);
}
}
Aggregations