projects
/
sixth-3d.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Code cleanup and formatting.
[sixth-3d.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
renderer
/
octree
/
raytracer
/
RayTracer.java
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
35ec06b
..
79ae21c
100755
(executable)
--- 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
@@
-107,36
+107,29
@@
public class RayTracer implements Runnable {
texture.resetResampledBitmapCache();
viewPanel.repaintDuringNextViewUpdate();
texture.resetResampledBitmapCache();
viewPanel.repaintDuringNextViewUpdate();
- // System.out.println("Raytracing done.");
- // System.out.println("New lights computed:" + computedLights);
}
}
- public int traceLight(final LightSource l, final int cubeX,
- final int cubeY, final int cubeZ) {
- return 0;
- }
-
- public int traceRay(final Ray r) {
+ private int traceRay(final Ray ray) {
- final int
re
= octreeVolume.traceCell(0, 0, 0,
- octreeVolume.masterCellSize, 0, r);
+ final int
intersectingCell
= octreeVolume.traceCell(0, 0, 0,
+ octreeVolume.masterCellSize, 0, r
ay
);
- if (
re
!= -1) {
+ if (
intersectingCell
!= -1) {
// if lightening not computed, compute it
// if lightening not computed, compute it
- if (octreeVolume.ce3[
re
] == -1)
+ if (octreeVolume.ce3[
intersectingCell
] == -1)
// if cell is larger than 1
// if cell is larger than 1
- if (r.hitCellSize > 1) {
+ if (r
ay
.hitCellSize > 1) {
// break it up
// break it up
- octreeVolume.breakSolidCell(
re
);
- return traceRay(r);
+ octreeVolume.breakSolidCell(
intersectingCell
);
+ return traceRay(r
ay
);
} else {
computedLights++;
float red = 30, green = 30, blue = 30;
for (final LightSource l : lights) {
} else {
computedLights++;
float red = 30, green = 30, blue = 30;
for (final LightSource l : lights) {
- final int xDist = (l.x - r.hitCellX);
- final int yDist = (l.y - r.hitCellY);
- final int zDist = (l.z - r.hitCellZ);
+ final int xDist = (l.x - r
ay
.hitCellX);
+ final int yDist = (l.y - r
ay
.hitCellY);
+ final int zDist = (l.z - r
ay
.hitCellZ);
double newRed = 0, newGreen = 0, newBlue = 0;
double tempRed, tempGreen, tempBlue;
double newRed = 0, newGreen = 0, newBlue = 0;
double tempRed, tempGreen, tempBlue;
@@
-145,12
+138,12
@@
public class RayTracer implements Runnable {
+ (yDist * yDist) + (zDist * zDist));
distance = (distance / 3) + 1;
+ (yDist * yDist) + (zDist * zDist));
distance = (distance / 3) + 1;
- final Ray r1 = new Ray(r
.hitCellX, r
.hitCellY
- - (float) 1.5, r.hitCellZ,
+ final Ray r1 = new Ray(r
ay.hitCellX, ray
.hitCellY
+ - (float) 1.5, r
ay
.hitCellZ,
- (float) l.x - (float) r.hitCellX, l.y
- - (r.hitCellY - (float) 1.5), (float) l.z
- - (float) r.hitCellZ);
+ (float) l.x - (float) r
ay
.hitCellX, l.y
+ - (r
ay
.hitCellY - (float) 1.5), (float) l.z
+ - (float) r
ay
.hitCellZ);
final int rt1 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r1);
final int rt1 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r1);
@@
-161,12
+154,12
@@
public class RayTracer implements Runnable {
newBlue = (l.color.b * l.brightness) / distance;
}
newBlue = (l.color.b * l.brightness) / distance;
}
- final Ray r2 = new Ray(r.hitCellX - (float) 1.5,
- r
.hitCellY, r
.hitCellZ,
+ final Ray r2 = new Ray(r
ay
.hitCellX - (float) 1.5,
+ r
ay.hitCellY, ray
.hitCellZ,
- l.x - (r.hitCellX - (float) 1.5), (float) l.y
- - (float) r.hitCellY, (float) l.z
- - (float) r.hitCellZ);
+ l.x - (r
ay
.hitCellX - (float) 1.5), (float) l.y
+ - (float) r
ay
.hitCellY, (float) l.z
+ - (float) r
ay
.hitCellZ);
final int rt2 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r2);
final int rt2 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r2);
@@
-184,12
+177,12
@@
public class RayTracer implements Runnable {
newBlue = tempBlue;
}
newBlue = tempBlue;
}
- final Ray r3 = new Ray(r
.hitCellX, r
.hitCellY,
- r.hitCellZ - (float) 1.5,
+ final Ray r3 = new Ray(r
ay.hitCellX, ray
.hitCellY,
+ r
ay
.hitCellZ - (float) 1.5,
- (float) l.x - (float) r.hitCellX, (float) l.y
- - (float) r.hitCellY, l.z
- - (r.hitCellZ - (float) 1.5));
+ (float) l.x - (float) r
ay
.hitCellX, (float) l.y
+ - (float) r
ay
.hitCellY, l.z
+ - (r
ay
.hitCellZ - (float) 1.5));
final int rt3 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r3);
final int rt3 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r3);
@@
-206,12
+199,12
@@
public class RayTracer implements Runnable {
newBlue = tempBlue;
}
newBlue = tempBlue;
}
- final Ray r4 = new Ray(r
.hitCellX, r
.hitCellY
- + (float) 1.5, r.hitCellZ,
+ final Ray r4 = new Ray(r
ay.hitCellX, ray
.hitCellY
+ + (float) 1.5, r
ay
.hitCellZ,
- (float) l.x - (float) r.hitCellX, l.y
- - (r.hitCellY + (float) 1.5), (float) l.z
- - (float) r.hitCellZ);
+ (float) l.x - (float) r
ay
.hitCellX, l.y
+ - (r
ay
.hitCellY + (float) 1.5), (float) l.z
+ - (float) r
ay
.hitCellZ);
final int rt4 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r4);
final int rt4 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r4);
@@
-228,12
+221,12
@@
public class RayTracer implements Runnable {
newBlue = tempBlue;
}
newBlue = tempBlue;
}
- final Ray r5 = new Ray(r.hitCellX + (float) 1.5,
- r
.hitCellY, r
.hitCellZ,
+ final Ray r5 = new Ray(r
ay
.hitCellX + (float) 1.5,
+ r
ay.hitCellY, ray
.hitCellZ,
- l.x - (r.hitCellX + (float) 1.5), (float) l.y
- - (float) r.hitCellY, (float) l.z
- - (float) r.hitCellZ);
+ l.x - (r
ay
.hitCellX + (float) 1.5), (float) l.y
+ - (float) r
ay
.hitCellY, (float) l.z
+ - (float) r
ay
.hitCellZ);
final int rt5 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r5);
final int rt5 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r5);
@@
-250,12
+243,12
@@
public class RayTracer implements Runnable {
newBlue = tempBlue;
}
newBlue = tempBlue;
}
- final Ray r6 = new Ray(r
.hitCellX, r
.hitCellY,
- r.hitCellZ + (float) 1.5,
+ final Ray r6 = new Ray(r
ay.hitCellX, ray
.hitCellY,
+ r
ay
.hitCellZ + (float) 1.5,
- (float) l.x - (float) r.hitCellX, (float) l.y
- - (float) r.hitCellY, l.z
- - (r.hitCellZ + (float) 1.5));
+ (float) l.x - (float) r
ay
.hitCellX, (float) l.y
+ - (float) r
ay
.hitCellY, l.z
+ - (r
ay
.hitCellZ + (float) 1.5));
final int rt6 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r6);
final int rt6 = octreeVolume.traceCell(0, 0, 0,
octreeVolume.masterCellSize, 0, r6);
@@
-277,7
+270,7
@@
public class RayTracer implements Runnable {
}
}
- final int cellColor = octreeVolume.ce2[
re
];
+ final int cellColor = octreeVolume.ce2[
intersectingCell
];
red = (red * ((cellColor & 0xFF0000) >> 16)) / 255;
green = (green * ((cellColor & 0xFF00) >> 8)) / 255;
red = (red * ((cellColor & 0xFF0000) >> 16)) / 255;
green = (green * ((cellColor & 0xFF00) >> 8)) / 255;
@@
-290,13
+283,13
@@
public class RayTracer implements Runnable {
if (blue > 255)
blue = 255;
if (blue > 255)
blue = 255;
- octreeVolume.ce3[
re
] = (((int) red) << 16)
+ octreeVolume.ce3[
intersectingCell
] = (((int) red) << 16)
+ (((int) green) << 8) + ((int) blue);
}
+ (((int) green) << 8) + ((int) blue);
}
- if (octreeVolume.ce3[
re
] == 0)
- return octreeVolume.ce2[
re
];
- return octreeVolume.ce3[
re
];
+ if (octreeVolume.ce3[
intersectingCell
] == 0)
+ return octreeVolume.ce2[
intersectingCell
];
+ return octreeVolume.ce3[
intersectingCell
];
}
// return (200 << 16) + (200 << 8) + 255;
}
// return (200 << 16) + (200 << 8) + 255;