X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Frenderer%2Foctree%2Fraytracer%2FRayTracer.java;h=d389a82d46d590c007699b433c7fedc9a8ac91fb;hp=8f7923fe6c1e7487f84deead715fd602c2836bce;hb=3f589bbc56ebfb1bd35b538b8a77d4019396b5aa;hpb=cad5276b56cfbd0b194dbacb894fea20b9dd5b15 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/raytracer/RayTracer.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/raytracer/RayTracer.java index 8f7923f..d389a82 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/raytracer/RayTracer.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/octree/raytracer/RayTracer.java @@ -4,6 +4,7 @@ */ package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer; +import eu.svjatoslav.sixth.e3d.geometry.Point3D; import eu.svjatoslav.sixth.e3d.gui.ViewPanel; import eu.svjatoslav.sixth.e3d.renderer.octree.OctreeVolume; import eu.svjatoslav.sixth.e3d.renderer.raster.Color; @@ -81,11 +82,15 @@ public class RayTracer implements Runnable { final double cy3 = cy1 + ((y3p * x) / width); final double cz3 = cz1 + ((z3p * x) / width); - final Ray r = new Ray(cameraView.cameraCenter.x, - cameraView.cameraCenter.y, cameraView.cameraCenter.z, cx3 - - cameraView.cameraCenter.x, cy3 + final Ray r = new Ray( + new Point3D(cameraView.cameraCenter.x, + cameraView.cameraCenter.y, + cameraView.cameraCenter.z), + new Point3D( + cx3 - cameraView.cameraCenter.x, cy3 - cameraView.cameraCenter.y, cz3 - - cameraView.cameraCenter.z); + - cameraView.cameraCenter.z) + ); final int c = traceRay(r); final Color color = new Color(c); @@ -133,12 +138,16 @@ public class RayTracer implements Runnable { + (yDist * yDist) + (zDist * zDist)); distance = (distance / 3) + 1; - final Ray r1 = new Ray(ray.hitCellX, ray.hitCellY - - (float) 1.5, ray.hitCellZ, + final Ray r1 = new Ray( + new Point3D( + ray.hitCellX, + ray.hitCellY - (float) 1.5, + ray.hitCellZ), - (float) l.location.x - (float) ray.hitCellX, l.location.y + new Point3D((float) l.location.x - (float) ray.hitCellX, l.location.y - (ray.hitCellY - (float) 1.5), (float) l.location.z - - (float) ray.hitCellZ); + - (float) ray.hitCellZ) + ); final int rt1 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r1); @@ -149,12 +158,16 @@ public class RayTracer implements Runnable { newBlue = (l.color.b * l.brightness) / distance; } - final Ray r2 = new Ray(ray.hitCellX - (float) 1.5, - ray.hitCellY, ray.hitCellZ, + final Ray r2 = new Ray( + new Point3D( + ray.hitCellX - (float) 1.5, + ray.hitCellY, ray.hitCellZ), + new Point3D( l.location.x - (ray.hitCellX - (float) 1.5), (float) l.location.y - (float) ray.hitCellY, (float) l.location.z - - (float) ray.hitCellZ); + - (float) ray.hitCellZ) + ); final int rt2 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r2); @@ -172,12 +185,15 @@ public class RayTracer implements Runnable { newBlue = tempBlue; } - final Ray r3 = new Ray(ray.hitCellX, ray.hitCellY, - ray.hitCellZ - (float) 1.5, - + final Ray r3 = new Ray( + new Point3D ( + ray.hitCellX, ray.hitCellY, + ray.hitCellZ - (float) 1.5), + new Point3D( (float) l.location.x - (float) ray.hitCellX, (float) l.location.y - (float) ray.hitCellY, l.location.z - - (ray.hitCellZ - (float) 1.5)); + - (ray.hitCellZ - (float) 1.5)) + ); final int rt3 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r3); @@ -194,12 +210,17 @@ public class RayTracer implements Runnable { newBlue = tempBlue; } - final Ray r4 = new Ray(ray.hitCellX, ray.hitCellY - + (float) 1.5, ray.hitCellZ, + final Ray r4 = new Ray( + new Point3D( + ray.hitCellX, + ray.hitCellY+ (float) 1.5, + ray.hitCellZ), + new Point3D( (float) l.location.x - (float) ray.hitCellX, l.location.y - (ray.hitCellY + (float) 1.5), (float) l.location.z - - (float) ray.hitCellZ); + - (float) ray.hitCellZ) + ); final int rt4 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r4); @@ -216,12 +237,16 @@ public class RayTracer implements Runnable { newBlue = tempBlue; } - final Ray r5 = new Ray(ray.hitCellX + (float) 1.5, - ray.hitCellY, ray.hitCellZ, + final Ray r5 = new Ray( + new Point3D( + ray.hitCellX + (float) 1.5, + ray.hitCellY, ray.hitCellZ), + new Point3D( l.location.x - (ray.hitCellX + (float) 1.5), (float) l.location.y - (float) ray.hitCellY, (float) l.location.z - - (float) ray.hitCellZ); + - (float) ray.hitCellZ) + ); final int rt5 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r5); @@ -238,12 +263,16 @@ public class RayTracer implements Runnable { newBlue = tempBlue; } - final Ray r6 = new Ray(ray.hitCellX, ray.hitCellY, - ray.hitCellZ + (float) 1.5, + final Ray r6 = new Ray( + new Point3D( + ray.hitCellX, ray.hitCellY, + ray.hitCellZ + (float) 1.5), + + new Point3D( (float) l.location.x - (float) ray.hitCellX, (float) l.location.y - (float) ray.hitCellY, l.location.z - - (ray.hitCellZ + (float) 1.5)); + - (ray.hitCellZ + (float) 1.5))); final int rt6 = octreeVolume.traceCell(0, 0, 0, octreeVolume.masterCellSize, 0, r6);