From: Svjatoslav Agejenko Date: Sat, 7 Jul 2018 22:31:20 +0000 (+0300) Subject: Code cleanup. Copyright update. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=cea6336f011484356f2d4294d45849f3c398e2e7;p=sixth-3d-demos.git Code cleanup. Copyright update. --- diff --git a/pom.xml b/pom.xml index d58b8b2..63a3c6a 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ eu.svjatoslav sixth-3d - 1.1 + 1.2-SNAPSHOT diff --git a/sixth-3d-demos.iml b/sixth-3d-demos.iml new file mode 100644 index 0000000..e5c814c --- /dev/null +++ b/sixth-3d-demos.iml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java index 2bbd237..7bcaed7 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/GridSpace.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/GridSpace.java deleted file mode 100755 index 5e9b53b..0000000 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/GridSpace.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - */ - -package eu.svjatoslav.sixth.e3d.examples; - -import eu.svjatoslav.sixth.e3d.geometry.Point3D; -import eu.svjatoslav.sixth.e3d.gui.ViewFrame; -import eu.svjatoslav.sixth.e3d.renderer.raster.Color; -import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection; -import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance; -import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon.SolidPolygon; -import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid3D; - -class GridSpace { - - private static void addRandomPolygon(final ShapeCollection geometryCollection) { - final Point3D polygonLocation = getRandomPoint(1000); - - final double polygonAverageSize = 30; - - final Point3D point1 = new Point3D(polygonLocation); - point1.add(getRandomPoint(polygonAverageSize)); - - final Point3D point2 = new Point3D(polygonLocation); - point2.add(getRandomPoint(polygonAverageSize)); - - final Point3D point3 = new Point3D(polygonLocation); - point3.add(getRandomPoint(polygonAverageSize)); - - final Color color = new Color(Math.random(), Math.random(), - Math.random(), 0.5d); - - final SolidPolygon polygon = new SolidPolygon(point1, point2, point3, - color); - geometryCollection.addShape(polygon); - } - - private static Point3D getRandomPoint(final double amplitude) { - return new Point3D((Math.random() * amplitude * 2d) - amplitude, - (Math.random() * amplitude * 2d) - amplitude, (Math.random() - * amplitude * 2d) - - amplitude); - } - - public static void main(final String[] args) { - - final ViewFrame viewFrame = new ViewFrame(); - - final ShapeCollection shapeCollection = viewFrame.getView() - .getContext().getRootShapeCollection(); - - // add grid - final LineAppearance appearance = new LineAppearance(5, new Color(100, - 100, 255, 60)); - - shapeCollection.addShape(new Grid3D(new Point3D(1000, -1000, -1000), - new Point3D(-1000, 1000, 1000), 300, appearance)); - - // add random polygons - for (int i = 0; i < 3000; i++) - addRandomPolygon(shapeCollection); - - } -} diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/OctreeDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/OctreeDemo.java index c26245f..0865ee7 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/OctreeDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/OctreeDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License @@ -27,7 +27,6 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.textcanvas.TextC import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid3D; import java.awt.event.KeyEvent; -import java.io.IOException; import java.util.Vector; public class OctreeDemo extends WorldNavigationTracker { @@ -40,7 +39,7 @@ public class OctreeDemo extends WorldNavigationTracker { private ShapeCollection shapeCollection; private ViewContext context; - public static void main(final String[] args) throws IOException { + public static void main(final String[] args) { new OctreeDemo().init(); } @@ -88,7 +87,7 @@ public class OctreeDemo extends WorldNavigationTracker { } } - private void init() throws IOException { + private void init() { final ViewFrame viewFrame = new ViewFrame(); context = viewFrame.getView().getContext(); diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/PointCloudDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/PointCloudDemo.java index d92a9d1..71b2855 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/PointCloudDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/PointCloudDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/RainingNumbersDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/RainingNumbersDemo.java index a077cb9..ea44ca6 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/RainingNumbersDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/RainingNumbersDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java new file mode 100755 index 0000000..3640e4b --- /dev/null +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/RandomPolygonsDemo.java @@ -0,0 +1,69 @@ +/* + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. + */ + +package eu.svjatoslav.sixth.e3d.examples; + +import eu.svjatoslav.sixth.e3d.geometry.Point3D; +import eu.svjatoslav.sixth.e3d.gui.ViewFrame; +import eu.svjatoslav.sixth.e3d.renderer.raster.Color; +import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon.SolidPolygon; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid3D; + +public class RandomPolygonsDemo { + + private static void addRandomPolygon(final ShapeCollection geometryCollection) { + final Point3D polygonLocation = getRandomPoint(1000); + + final double polygonAverageSize = 30; + + final Point3D point1 = new Point3D(polygonLocation); + point1.add(getRandomPoint(polygonAverageSize)); + + final Point3D point2 = new Point3D(polygonLocation); + point2.add(getRandomPoint(polygonAverageSize)); + + final Point3D point3 = new Point3D(polygonLocation); + point3.add(getRandomPoint(polygonAverageSize)); + + final Color color = new Color(Math.random(), Math.random(), + Math.random(), 0.5d); + + final SolidPolygon polygon = new SolidPolygon(point1, point2, point3, + color); + geometryCollection.addShape(polygon); + } + + private static Point3D getRandomPoint(final double amplitude) { + return new Point3D((Math.random() * amplitude * 2d) - amplitude, + (Math.random() * amplitude * 2d) - amplitude, (Math.random() + * amplitude * 2d) + - amplitude); + } + + public static void main(final String[] args) { + + final ViewFrame viewFrame = new ViewFrame(); + + final ShapeCollection shapeCollection = viewFrame.getView() + .getContext().getRootShapeCollection(); + + // add grid + final LineAppearance appearance = new LineAppearance(5, new Color(100, + 100, 255, 60)); + + shapeCollection.addShape(new Grid3D(new Point3D(1000, -1000, -1000), + new Point3D(-1000, 1000, 1000), 300, appearance)); + + // add random polygons + for (int i = 0; i < 3000; i++) + addRandomPolygon(shapeCollection); + + } +} diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/SphereDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/SphereDemo.java index 9a9b706..22b9dee 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/SphereDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/SphereDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java index 6f5d4d2..9f56342 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/Main.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/Main.java index 512f30c..6d0f1a8 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/Main.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/Main.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License @@ -18,12 +18,8 @@ class Main extends javax.swing.JFrame { private Main() { super(); initGUI(); - } - /** - * Auto-generated main method to display this JFrame - */ public static void main(final String[] args) { SwingUtilities.invokeLater(() -> { final Main inst = new Main(); diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java index 10178e3..30c7ee3 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License @@ -17,8 +17,7 @@ import java.io.IOException; class MenuPanel extends JPanel { private static final long serialVersionUID = 2012721856427052560L; - public MenuPanel() { - + MenuPanel() { final GroupLayout groupLayout = new GroupLayout(this); GroupLayout.SequentialGroup sequentialGroup = groupLayout.createSequentialGroup(); sequentialGroup.addComponent(new JLabel("Choose an example to launch:")); @@ -29,10 +28,11 @@ class MenuPanel extends JPanel { sequentialGroup.addComponent(new JButton(new ShowSinusMap())); sequentialGroup.addComponent(new JButton(new ShowTextEditors())); sequentialGroup.addComponent(new JButton(new ShowGameOfLife())); + sequentialGroup.addComponent(new JButton(new ShowRandomPolygons())); } private class ShowTextEditors extends AbstractAction { - public ShowTextEditors() { + ShowTextEditors() { putValue(NAME, "Text editors"); } @@ -94,6 +94,17 @@ class MenuPanel extends JPanel { } } + private class ShowRandomPolygons extends AbstractAction { + public ShowRandomPolygons() { + putValue(NAME, "Random polygons"); + } + + @Override + public void actionPerformed(final ActionEvent e) { + RandomPolygonsDemo.main(null); + } + } + private class ShowOctree extends AbstractAction { public ShowOctree() { putValue(NAME, "Volumetric Octree"); @@ -101,11 +112,7 @@ class MenuPanel extends JPanel { @Override public void actionPerformed(final ActionEvent e) { - try { - OctreeDemo.main(null); - } catch (final IOException e1) { - e1.printStackTrace(); - } + OctreeDemo.main(null); } } diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java index 81e7198..693c21d 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java @@ -7,7 +7,7 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.GlowingPoint; import java.util.ArrayList; import java.util.List; -public class Star extends GlowingPoint{ +public class Star extends GlowingPoint { public static final int STAR_SIZE = 10; public static final int UNIQUE_STARS_COUNT = 30; diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/package-info.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/package-info.java index 4946f36..7e9a3b3 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/package-info.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/package-info.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License