projects
/
sixth-3d-demos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Ignore IntelliJ and JRebel project files
[sixth-3d-demos.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
examples
/
RandomPolygonsDemo.java
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java
b/src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java
index
3640e4b
..
82210b0
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java
@@
-18,28
+18,38
@@
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid3D
public class RandomPolygonsDemo {
public class RandomPolygonsDemo {
+ private static final double POLYGON_AVERAGE_SIZE = 130;
+ private static final int POLYGON_COUNT = 1000;
+
private static void addRandomPolygon(final ShapeCollection geometryCollection) {
final Point3D polygonLocation = getRandomPoint(1000);
private static void addRandomPolygon(final ShapeCollection geometryCollection) {
final Point3D polygonLocation = getRandomPoint(1000);
- final double polygonAverageSize = 30;
-
final Point3D point1 = new Point3D(polygonLocation);
final Point3D point1 = new Point3D(polygonLocation);
- point1.add(getRandomPoint(
polygonAverageSize
));
+ point1.add(getRandomPoint(
POLYGON_AVERAGE_SIZE
));
final Point3D point2 = new Point3D(polygonLocation);
final Point3D point2 = new Point3D(polygonLocation);
- point2.add(getRandomPoint(
polygonAverageSize
));
+ point2.add(getRandomPoint(
POLYGON_AVERAGE_SIZE
));
final Point3D point3 = new Point3D(polygonLocation);
final Point3D point3 = new Point3D(polygonLocation);
- point3.add(getRandomPoint(
polygonAverageSize
));
+ point3.add(getRandomPoint(
POLYGON_AVERAGE_SIZE
));
- final Color color = new Color(Math.random(), Math.random(),
- Math.random(), 0.5d);
+ final Color color = new Color(
+ getColorChannelBrightness(),
+ getColorChannelBrightness(),
+ getColorChannelBrightness(),
+ 1);
final SolidPolygon polygon = new SolidPolygon(point1, point2, point3,
color);
geometryCollection.addShape(polygon);
}
final SolidPolygon polygon = new SolidPolygon(point1, point2, point3,
color);
geometryCollection.addShape(polygon);
}
+ /* I don't want very dark polygons, so ensure there is at least some
+ * brightness present. */
+ private static double getColorChannelBrightness() {
+ return Math.random() * 0.7 + 0.3f;
+ }
+
private static Point3D getRandomPoint(final double amplitude) {
return new Point3D((Math.random() * amplitude * 2d) - amplitude,
(Math.random() * amplitude * 2d) - amplitude, (Math.random()
private static Point3D getRandomPoint(final double amplitude) {
return new Point3D((Math.random() * amplitude * 2d) - amplitude,
(Math.random() * amplitude * 2d) - amplitude, (Math.random()
@@
-51,8
+61,8
@@
public class RandomPolygonsDemo {
final ViewFrame viewFrame = new ViewFrame();
final ViewFrame viewFrame = new ViewFrame();
- final ShapeCollection shapeCollection = viewFrame.getView()
- .get
Context().get
RootShapeCollection();
+ final ShapeCollection shapeCollection = viewFrame.getView
Panel
()
+ .getRootShapeCollection();
// add grid
final LineAppearance appearance = new LineAppearance(5, new Color(100,
// add grid
final LineAppearance appearance = new LineAppearance(5, new Color(100,
@@
-62,7
+72,7
@@
public class RandomPolygonsDemo {
new Point3D(-1000, 1000, 1000), 300, appearance));
// add random polygons
new Point3D(-1000, 1000, 1000), 300, appearance));
// add random polygons
- for (int i = 0; i <
3000
; i++)
+ for (int i = 0; i <
POLYGON_COUNT
; i++)
addRandomPolygon(shapeCollection);
}
addRandomPolygon(shapeCollection);
}