private final Camera camera;
private final Texture texture;
private final ViewPanel viewPanel;
- private OctreeVolume octreeVolume;
- private Vector<LightSource> lights;
+ private final OctreeVolume octreeVolume;
+ private final Vector<LightSource> lights;
private int computedLights;
public RayTracer(final Texture texture, final OctreeVolume octreeVolume,
final CameraView cameraView = camera.getCameraView();
// calculate vertical vectors
- final double x1p = cameraView.downLeft.x - cameraView.upLeft.x;
- final double y1p = cameraView.downLeft.y - cameraView.upLeft.y;
- final double z1p = cameraView.downLeft.z - cameraView.upLeft.z;
+ final double x1p = cameraView.bottomLeft.x - cameraView.topLeft.x;
+ final double y1p = cameraView.bottomLeft.y - cameraView.topLeft.y;
+ final double z1p = cameraView.bottomLeft.z - cameraView.topLeft.z;
- final double x2p = cameraView.downRight.x - cameraView.upRight.x;
- final double y2p = cameraView.downRight.y - cameraView.upRight.y;
- final double z2p = cameraView.downRight.z - cameraView.upRight.z;
+ final double x2p = cameraView.bottomRight.x - cameraView.topRight.x;
+ final double y2p = cameraView.bottomRight.y - cameraView.topRight.y;
+ final double z2p = cameraView.bottomRight.z - cameraView.topRight.z;
long nextBitmapUpdate = System.currentTimeMillis()
+ PROGRESS_UPDATE_FREQUENCY_MILLIS;
for (int y = 0; y < height; y++) {
- final double cx1 = cameraView.upLeft.x + ((x1p * y) / height);
- final double cy1 = cameraView.upLeft.y + ((y1p * y) / height);
- final double cz1 = cameraView.upLeft.z + ((z1p * y) / height);
+ final double cx1 = cameraView.topLeft.x + ((x1p * y) / height);
+ final double cy1 = cameraView.topLeft.y + ((y1p * y) / height);
+ final double cz1 = cameraView.topLeft.z + ((z1p * y) / height);
- final double cx2 = cameraView.upRight.x + ((x2p * y) / height);
- final double cy2 = cameraView.upRight.y + ((y2p * y) / height);
- final double cz2 = cameraView.upRight.z + ((z2p * y) / height);
+ final double cx2 = cameraView.topRight.x + ((x2p * y) / height);
+ final double cy2 = cameraView.topRight.y + ((y2p * y) / height);
+ final double cz2 = cameraView.topRight.z + ((z2p * y) / height);
// calculate horisontal vector
final double x3p = cx2 - cx1;
final double cy3 = cy1 + ((y3p * x) / width);
final double cz3 = cz1 + ((z3p * x) / width);
- final Ray r = new Ray(cameraView.camCenter.x,
- cameraView.camCenter.y, cameraView.camCenter.z, cx3
- - cameraView.camCenter.x, cy3
- - cameraView.camCenter.y, cz3
- - cameraView.camCenter.z);
+ final Ray r = new Ray(cameraView.cameraCenter.x,
+ cameraView.cameraCenter.y, cameraView.cameraCenter.z, cx3
+ - cameraView.cameraCenter.x, cy3
+ - cameraView.cameraCenter.y, cz3
+ - cameraView.cameraCenter.z);
final int c = traceRay(r);
final Color color = new Color(c);