joonsrenderer 1.1.3-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/maven-wrapper.properties +1 -0
  4. data/CHANGELOG.md +3 -1
  5. data/Rakefile +1 -1
  6. data/docs/Gemfile +2 -0
  7. data/docs/_config.yml +3 -0
  8. data/docs/_includes/header.html +1 -1
  9. data/docs/_includes/top.html +11 -0
  10. data/docs/_layouts/default.html +6 -15
  11. data/docs/about.md +2 -2
  12. data/joonsrenderer.gemspec +2 -2
  13. data/lib/joonsrenderer/version.rb +1 -1
  14. data/pom.rb +4 -4
  15. data/pom.xml +7 -7
  16. data/src/{test/java/a_maintest.java → a_maintest.java} +1 -1
  17. data/src/main/java/SunflowGUI.java +294 -352
  18. data/src/main/java/org/sunflow/AsciiFileSunflowAPI.java +1 -1
  19. data/src/main/java/org/sunflow/BinaryFileSunflowAPI.java +1 -1
  20. data/src/main/java/org/sunflow/SunflowAPI.java +2 -2
  21. data/src/main/java/org/sunflow/core/GIEngine.java +3 -1
  22. data/src/main/java/org/sunflow/core/ImageSampler.java +3 -0
  23. data/src/main/java/org/sunflow/core/InstanceList.java +1 -1
  24. data/src/main/java/org/sunflow/core/IntersectionState.java +7 -6
  25. data/src/main/java/org/sunflow/core/ParameterList.java +3 -2
  26. data/src/main/java/org/sunflow/core/PhotonStore.java +1 -0
  27. data/src/main/java/org/sunflow/core/Ray.java +4 -3
  28. data/src/main/java/org/sunflow/core/TextureCache.java +1 -1
  29. data/src/main/java/org/sunflow/core/accel/BoundingIntervalHierarchy.java +1 -1
  30. data/src/main/java/org/sunflow/core/photonmap/CausticPhotonMap.java +1 -1
  31. data/src/main/java/org/sunflow/core/renderer/BucketRenderer.java +3 -1
  32. data/src/main/java/org/sunflow/image/writers/EXRBitmapWriter.java +28 -19
  33. data/src/main/java/org/sunflow/image/writers/PNGBitmapWriter.java +5 -0
  34. data/src/main/java/org/sunflow/image/writers/TGABitmapWriter.java +20 -14
  35. data/src/main/java/org/sunflow/system/BenchmarkFramework.java +2 -2
  36. data/src/main/java/org/sunflow/system/RenderGlobalsPanel.java +5 -4
  37. metadata +9 -8
  38. data/docs/_includes/head.html +0 -15
@@ -12,7 +12,7 @@ import org.sunflow.math.Matrix4;
12
12
 
13
13
  class AsciiFileSunflowAPI extends FileSunflowAPI {
14
14
 
15
- private OutputStream stream;
15
+ private final OutputStream stream;
16
16
 
17
17
  AsciiFileSunflowAPI(String filename) throws IOException {
18
18
  stream = new BufferedOutputStream(new FileOutputStream(filename));
@@ -12,7 +12,7 @@ import org.sunflow.math.Matrix4;
12
12
 
13
13
  class BinaryFileSunflowAPI extends FileSunflowAPI {
14
14
 
15
- private DataOutputStream stream;
15
+ private final DataOutputStream stream;
16
16
 
17
17
  BinaryFileSunflowAPI(String filename) throws FileNotFoundException {
18
18
  stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
@@ -639,7 +639,7 @@ public class SunflowAPI implements SunflowAPIInterface {
639
639
  if (filename == null) {
640
640
  return new SunflowAPI();
641
641
  }
642
- SunflowAPI api = null;
642
+ SunflowAPI api;
643
643
  if (filename.endsWith(".java")) {
644
644
  Timer t = new Timer();
645
645
  UI.printInfo(Module.API, "Compiling \"" + filename + "\" ...");
@@ -684,7 +684,7 @@ public class SunflowAPI implements SunflowAPIInterface {
684
684
  * @return <code>true</code> upon success, <code>false</code> otherwise
685
685
  */
686
686
  public static boolean translate(String filename, String outputFilename) {
687
- FileSunflowAPI api = null;
687
+ FileSunflowAPI api;
688
688
  try {
689
689
  if (outputFilename.endsWith(".sca")) {
690
690
  api = new AsciiFileSunflowAPI(outputFilename);
@@ -21,8 +21,10 @@ public interface GIEngine {
21
21
  public Color getGlobalRadiance(ShadingState state);
22
22
 
23
23
  /**
24
- * Initialize the engine. This is called before rendering begins.
24
+ * Initialize the engine.This is called before rendering begins.
25
25
  *
26
+ * @param options
27
+ * @param scene
26
28
  * @return <code>true</code> if the init phase succeeded, <code>false</code>
27
29
  * otherwise
28
30
  */
@@ -10,8 +10,11 @@ public interface ImageSampler {
10
10
  /**
11
11
  * Prepare the sampler for rendering an image of w x h pixels
12
12
  *
13
+ * @param options
14
+ * @param scene
13
15
  * @param w width of the image
14
16
  * @param h height of the image
17
+ * @return
15
18
  */
16
19
  public boolean prepare(Options options, Scene scene, int w, int h);
17
20
 
@@ -6,7 +6,7 @@ import org.sunflow.math.Matrix4;
6
6
 
7
7
  final class InstanceList implements PrimitiveList {
8
8
 
9
- private Instance[] instances;
9
+ private final Instance[] instances;
10
10
  private Instance[] lights;
11
11
 
12
12
  InstanceList() {
@@ -36,9 +36,9 @@ public final class IntersectionState {
36
36
  * Initializes all traversal stacks.
37
37
  */
38
38
  public IntersectionState() {
39
- for (int i = 0; i < stacks.length; i++) {
40
- for (int j = 0; j < stacks[i].length; j++) {
41
- stacks[i][j] = new StackNode();
39
+ for (StackNode[] stack : stacks) {
40
+ for (int j = 0; j < stack.length; j++) {
41
+ stack[j] = new StackNode();
42
42
  }
43
43
  }
44
44
  }
@@ -102,13 +102,14 @@ public final class IntersectionState {
102
102
  }
103
103
 
104
104
  /**
105
- * Record an intersection with the specified primitive id. The parent object
106
- * is assumed to be the current instance. The u and v parameters are used to
107
- * pinpoint the location on the surface if needed.
105
+ * Record an intersection with the specified primitive id.The parent object
106
+ is assumed to be the current instance. The u and v parameters are used to
107
+ pinpoint the location on the surface if needed.
108
108
  *
109
109
  * @param id primitive id of the intersected object
110
110
  * @param u u surface paramater of the intersection point
111
111
  * @param v v surface parameter of the intersection point
112
+ * @param w
112
113
  */
113
114
  public final void setIntersection(int id, float u, float v, float w) {
114
115
  instance = current;
@@ -36,13 +36,14 @@ public class ParameterList {
36
36
  * Creates an empty ParameterList.
37
37
  */
38
38
  public ParameterList() {
39
- list = new FastHashMap<String, Parameter>();
39
+ list = new FastHashMap<>();
40
40
  numVerts = numFaces = numFaceVerts = 0;
41
41
  }
42
42
 
43
43
  /**
44
- * Clears the list of all its members. If some members were never used, a
44
+ * Clears the list of all its members.If some members were never used, a
45
45
  * warning will be printed to remind the user something may be wrong.
46
+ * @param showUnused
46
47
  */
47
48
  public void clear(boolean showUnused) {
48
49
  if (showUnused) {
@@ -19,6 +19,7 @@ public interface PhotonStore {
19
19
  /**
20
20
  * Initialize this object for the specified scene size.
21
21
  *
22
+ * @param options
22
23
  * @param sceneBounds scene bounding box
23
24
  */
24
25
  void prepare(Options options, BoundingBox sceneBounds);
@@ -95,11 +95,12 @@ public final class Ray {
95
95
  }
96
96
 
97
97
  /**
98
- * Create a new ray by transforming the supplied one by the given matrix. If
99
- * the matrix is
100
- * <code>null</code>, the original ray is returned.
98
+ * Create a new ray by transforming the supplied one by the given matrix.If
99
+ the matrix is
100
+ <code>null</code>, the original ray is returned.
101
101
  *
102
102
  * @param m matrix to transform the ray by
103
+ * @return
103
104
  */
104
105
  public Ray transform(Matrix4 m) {
105
106
  if (m == null) {
@@ -11,7 +11,7 @@ import org.sunflow.system.UI.Module;
11
11
  */
12
12
  public final class TextureCache {
13
13
 
14
- private static HashMap<String, Texture> textures = new HashMap<String, Texture>();
14
+ private static final HashMap<String, Texture> textures = new HashMap<>();
15
15
 
16
16
  private TextureCache() {
17
17
  }
@@ -17,7 +17,7 @@ public class BoundingIntervalHierarchy implements AccelerationStructure {
17
17
  private int[] objects;
18
18
  private PrimitiveList primitives;
19
19
  private BoundingBox bounds;
20
- private int maxPrims;
20
+ private final int maxPrims;
21
21
 
22
22
  public BoundingIntervalHierarchy() {
23
23
  maxPrims = 2;
@@ -267,7 +267,7 @@ public final class CausticPhotonMap implements CausticPhotonMapInterface {
267
267
 
268
268
  int found;
269
269
  float px, py, pz;
270
- private int max;
270
+ private final int max;
271
271
  private boolean gotHeap;
272
272
  protected float[] dist2;
273
273
  protected Photon[] index;
@@ -34,7 +34,7 @@ public class BucketRenderer implements ImageSampler {
34
34
  private int bucketSize;
35
35
  private int bucketCounter;
36
36
  private int[] bucketCoords;
37
- private boolean dumpBuckets;
37
+ private final boolean dumpBuckets;
38
38
  // anti-aliasing
39
39
  private int minAADepth;
40
40
  private int maxAADepth;
@@ -67,6 +67,7 @@ public class BucketRenderer implements ImageSampler {
67
67
  dumpBuckets = false; // for debugging only - not user settable
68
68
  }
69
69
 
70
+ @Override
70
71
  public boolean prepare(Options options, Scene scene, int w, int h) {
71
72
  this.scene = scene;
72
73
  imageWidth = w;
@@ -142,6 +143,7 @@ public class BucketRenderer implements ImageSampler {
142
143
  return String.format("%s%d sample%s", depth < 0 ? "1/" : "", pixelAA * pixelAA, depth == 0 ? "" : "s");
143
144
  }
144
145
 
146
+ @Override
145
147
  public void render(Display display) {
146
148
  this.display = display;
147
149
  display.imageBegin(imageWidth, imageHeight, bucketSize);
@@ -48,27 +48,36 @@ public class EXRBitmapWriter implements BitmapWriter {
48
48
  @Override
49
49
  public final void configure(final String option, String value) {
50
50
  if (option.equals(COMPRESSION)) {
51
- if (value.equals("none")) {
52
- compression = NO_COMPRESSION;
53
- } else if (value.equals("rle")) {
54
- compression = RLE_COMPRESSION;
55
- } else if (value.equals("zip")) {
56
- compression = ZIP_COMPRESSION;
57
- } else {
58
- UI.printWarning(Module.IMG, "EXR - Compression type was not recognized - defaulting to zip");
59
- compression = ZIP_COMPRESSION;
51
+ switch (value) {
52
+ case "none":
53
+ compression = NO_COMPRESSION;
54
+ break;
55
+ case "rle":
56
+ compression = RLE_COMPRESSION;
57
+ break;
58
+ case "zip":
59
+ compression = ZIP_COMPRESSION;
60
+ break;
61
+ default:
62
+ UI.printWarning(Module.IMG, "EXR - Compression type was not recognized - defaulting to zip");
63
+ compression = ZIP_COMPRESSION;
64
+ break;
60
65
  }
61
66
  } else if (option.equals("channeltype")) {
62
- if (value.equals("float")) {
63
- channelType = FLOAT;
64
- channelSize = FLOAT_SIZE;
65
- } else if (value.equals("half")) {
66
- channelType = HALF;
67
- channelSize = HALF_SIZE;
68
- } else {
69
- UI.printWarning(Module.DISP, "EXR - Channel type was not recognized - defaulting to float");
70
- channelType = FLOAT;
71
- channelSize = FLOAT_SIZE;
67
+ switch (value) {
68
+ case "float":
69
+ channelType = FLOAT;
70
+ channelSize = FLOAT_SIZE;
71
+ break;
72
+ case "half":
73
+ channelType = HALF;
74
+ channelSize = HALF_SIZE;
75
+ break;
76
+ default:
77
+ UI.printWarning(Module.DISP, "EXR - Channel type was not recognized - defaulting to float");
78
+ channelType = FLOAT;
79
+ channelSize = FLOAT_SIZE;
80
+ break;
72
81
  }
73
82
  }
74
83
  }
@@ -14,17 +14,21 @@ public class PNGBitmapWriter implements BitmapWriter {
14
14
  private String filename;
15
15
  private BufferedImage image;
16
16
 
17
+ @Override
17
18
  public void configure(String option, String value) {
18
19
  }
19
20
 
21
+ @Override
20
22
  public void openFile(String filename) throws IOException {
21
23
  this.filename = filename;
22
24
  }
23
25
 
26
+ @Override
24
27
  public void writeHeader(int width, int height, int tileSize) throws IOException, UnsupportedOperationException {
25
28
  image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
26
29
  }
27
30
 
31
+ @Override
28
32
  public void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) throws IOException {
29
33
  for (int j = 0, index = 0; j < h; j++) {
30
34
  for (int i = 0; i < w; i++, index++) {
@@ -33,6 +37,7 @@ public class PNGBitmapWriter implements BitmapWriter {
33
37
  }
34
38
  }
35
39
 
40
+ @Override
36
41
  public void closeFile() throws IOException {
37
42
  ImageIO.write(image, "png", new File(filename));
38
43
  }
@@ -15,19 +15,23 @@ public class TGABitmapWriter implements BitmapWriter {
15
15
  private int width, height;
16
16
  private byte[] data;
17
17
 
18
+ @Override
18
19
  public void configure(String option, String value) {
19
20
  }
20
21
 
22
+ @Override
21
23
  public void openFile(String filename) throws IOException {
22
24
  this.filename = filename;
23
25
  }
24
26
 
27
+ @Override
25
28
  public void writeHeader(int width, int height, int tileSize) throws IOException, UnsupportedOperationException {
26
29
  this.width = width;
27
30
  this.height = height;
28
31
  data = new byte[width * height * 4]; // RGBA8
29
32
  }
30
33
 
34
+ @Override
31
35
  public void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) throws IOException {
32
36
  color = ColorEncoder.unlinearize(color); // gamma correction
33
37
  byte[] tileData = ColorEncoder.quantizeRGBA8(color, alpha);
@@ -43,21 +47,23 @@ public class TGABitmapWriter implements BitmapWriter {
43
47
  }
44
48
  }
45
49
 
50
+ @Override
46
51
  public void closeFile() throws IOException {
47
- // actually write the file from here
48
- OutputStream f = new BufferedOutputStream(new FileOutputStream(filename));
49
52
  // no id, no colormap, uncompressed 32bpp RGBA
50
- byte[] tgaHeader = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
51
- f.write(tgaHeader);
52
- // then the size info
53
- f.write(width & 0xFF);
54
- f.write((width >> 8) & 0xFF);
55
- f.write(height & 0xFF);
56
- f.write((height >> 8) & 0xFF);
57
- // bitsperpixel and filler
58
- f.write(32);
59
- f.write(0);
60
- f.write(data); // write image data bytes (already in BGRA order)
61
- f.close();
53
+ try ( // actually write the file from here
54
+ OutputStream f = new BufferedOutputStream(new FileOutputStream(filename))) {
55
+ // no id, no colormap, uncompressed 32bpp RGBA
56
+ byte[] tgaHeader = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
57
+ f.write(tgaHeader);
58
+ // then the size info
59
+ f.write(width & 0xFF);
60
+ f.write((width >> 8) & 0xFF);
61
+ f.write(height & 0xFF);
62
+ f.write((height >> 8) & 0xFF);
63
+ // bitsperpixel and filler
64
+ f.write(32);
65
+ f.write(0);
66
+ f.write(data); // write image data bytes (already in BGRA order)
67
+ }
62
68
  }
63
69
  }
@@ -8,8 +8,8 @@ import org.sunflow.system.UI.Module;
8
8
  */
9
9
  public class BenchmarkFramework {
10
10
 
11
- private Timer[] timers;
12
- private int timeLimit; // time limit in seconds
11
+ private final Timer[] timers;
12
+ private final int timeLimit; // time limit in seconds
13
13
 
14
14
  public BenchmarkFramework(int iterations, int timeLimit) {
15
15
  this.timeLimit = timeLimit;
@@ -64,6 +64,7 @@ public class RenderGlobalsPanel extends JTabbedPane {
64
64
 
65
65
  /**
66
66
  * Auto-generated main method to display this JPanel inside a new JFrame.
67
+ * @param args
67
68
  */
68
69
  public static void main(String[] args) {
69
70
  JFrame frame = new JFrame();
@@ -181,9 +182,9 @@ public class RenderGlobalsPanel extends JTabbedPane {
181
182
  jLabel5.setText("Min:");
182
183
  }
183
184
  {
184
- ComboBoxModel<String> minSamplingComboBoxModel = new DefaultComboBoxModel<String>(new String[]{
185
+ ComboBoxModel<String> minSamplingComboBoxModel = new DefaultComboBoxModel<>(new String[]{
185
186
  "Item One", "Item Two"});
186
- minSamplingComboBox = new JComboBox<String>();
187
+ minSamplingComboBox = new JComboBox<>();
187
188
  samplingPanel.add(minSamplingComboBox);
188
189
  minSamplingComboBox.setModel(minSamplingComboBoxModel);
189
190
  }
@@ -193,9 +194,9 @@ public class RenderGlobalsPanel extends JTabbedPane {
193
194
  jLabel6.setText("Max:");
194
195
  }
195
196
  {
196
- ComboBoxModel<String> maxSamplingComboxBoxModel = new DefaultComboBoxModel<String>(new String[]{
197
+ ComboBoxModel<String> maxSamplingComboxBoxModel = new DefaultComboBoxModel<>(new String[]{
197
198
  "Item One", "Item Two"});
198
- maxSamplingComboxBox = new JComboBox<String>();
199
+ maxSamplingComboxBox = new JComboBox<>();
199
200
  samplingPanel.add(maxSamplingComboxBox);
200
201
  maxSamplingComboxBox.setModel(maxSamplingComboxBoxModel);
201
202
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joonsrenderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - monkstone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-16 00:00:00.000000000 Z
11
+ date: 2019-04-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A realistic ray tracer for propane and JRubyArt
14
14
  email:
@@ -19,20 +19,22 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".gitignore"
21
21
  - ".mvn/extensions.xml"
22
+ - ".mvn/wrapper/maven-wrapper.properties"
22
23
  - CHANGELOG.md
23
24
  - Gemfile
24
25
  - LICENSE
25
26
  - README.md
26
27
  - Rakefile
27
28
  - docs/.gitignore
29
+ - docs/Gemfile
28
30
  - docs/_config.yml
29
31
  - docs/_includes/footer.html
30
- - docs/_includes/head.html
31
32
  - docs/_includes/header.html
32
33
  - docs/_includes/icon-github.html
33
34
  - docs/_includes/icon-github.svg
34
35
  - docs/_includes/icon-twitter.html
35
36
  - docs/_includes/icon-twitter.svg
37
+ - docs/_includes/top.html
36
38
  - docs/_layouts/default.html
37
39
  - docs/_layouts/page.html
38
40
  - docs/_layouts/post.html
@@ -55,13 +57,14 @@ files:
55
57
  - docs/feed.xml
56
58
  - docs/index.html
57
59
  - joonsrenderer.gemspec
58
- - lib/commons-compiler-3.0.6.jar
59
- - lib/janino-3.0.6.jar
60
+ - lib/commons-compiler-3.0.12.jar
61
+ - lib/janino-3.0.12.jar
60
62
  - lib/joonsrenderer.jar
61
63
  - lib/joonsrenderer.rb
62
64
  - lib/joonsrenderer/version.rb
63
65
  - pom.rb
64
66
  - pom.xml
67
+ - src/a_maintest.java
65
68
  - src/main/java/SunflowGUI.java
66
69
  - src/main/java/joons/JRFiller.java
67
70
  - src/main/java/joons/JRImagePanel.java
@@ -276,7 +279,6 @@ files:
276
279
  - src/main/java/org/sunflow/util/FastHashMap.java
277
280
  - src/main/java/org/sunflow/util/FloatArray.java
278
281
  - src/main/java/org/sunflow/util/IntArray.java
279
- - src/test/java/a_maintest.java
280
282
  homepage: https://ruby-processing.github.io/joonsrenderer/
281
283
  licenses:
282
284
  - GPL-3.0
@@ -296,8 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
298
  - !ruby/object:Gem::Version
297
299
  version: '0'
298
300
  requirements: []
299
- rubyforge_project:
300
- rubygems_version: 2.5.1
301
+ rubygems_version: 3.0.3
301
302
  signing_key:
302
303
  specification_version: 4
303
304
  summary: From Sketch to Ray Traced Image