2 * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.gui.Avatar;
15 public class CameraView {
23 public CameraView(final Avatar avatar, final double zoom) {
24 computeCameraCoordinates(avatar, zoom);
27 private void computeCameraCoordinates(final Avatar avatar, final double zoom) {
28 camCenter = new Point3D(avatar.getLocation()).scaleDown(zoom);
30 upLeft = new Point3D(camCenter.x, camCenter.y, camCenter.z
31 + Camera.CAMERA_SIZE);
32 upRight = new Point3D(upLeft);
33 downLeft = new Point3D(upLeft);
34 downRight = new Point3D(upLeft);
36 final float viewAngle = (float) .6;
38 upLeft.rotate(camCenter, -viewAngle, -viewAngle);
39 upRight.rotate(camCenter, viewAngle, -viewAngle);
40 downLeft.rotate(camCenter, -viewAngle, viewAngle);
41 downRight.rotate(camCenter, viewAngle, viewAngle);
43 upLeft.rotate(camCenter, -avatar.getAngleXZ(), -avatar.getAngleYZ());
44 upRight.rotate(camCenter, -avatar.getAngleXZ(), -avatar.getAngleYZ());
45 downLeft.rotate(camCenter, -avatar.getAngleXZ(), -avatar.getAngleYZ());
46 downRight.rotate(camCenter, -avatar.getAngleXZ(), -avatar.getAngleYZ());