From: Svjatoslav Agejenko Date: Sat, 29 May 2021 00:00:47 +0000 (+0300) Subject: Code refactoring X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=fd099c489d7f4df2624c07d1d3ba24f658b147a7;p=sixth-3d-demos.git Code refactoring --- diff --git a/doc/index.html b/doc/index.html index a39aff7..a1dd806 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,249 +1,288 @@ - - + + + + + + Sixth 3D engine demos - - - - - - - - + + - + -
-

Sixth 3D engine demos

+
+

Sixth 3D engine demos

+ -
-

1 General

+
+

1 General

-
  • Other software projects hosted at svjatoslav.eu -
  • +
  • Other software projects hosted at svjatoslav.eu
  • -
    -

    1.1 Source code

    +
    +

    1.1 Source code

    -
    -

    2 Overview

    +
    +

    2 Overview

    Goal of this project is to show off capabilities and API usage of @@ -251,7 +290,7 @@ Goal of this project is to show off capabilities and API usage of

    -All example scenes in this repository render at interactive +All example scenes in this repository render at interactive framerates.

    @@ -264,60 +303,59 @@ To start demo application, use command:

     java -jar sixth-3d-demos.jar
    -
     
    -
    -

    3 Navigating in space

    +
    +

    3 Navigating in space

    - +
    -+-+ - - + + - - + + - - + + - - + +
    keyresultkeyresult
    cursor keysmove: left, right, forward, backwardcursor keysmove: left, right, forward, backward
    mouse scroll wheelmove: up, downmouse scroll wheelmove: up, down
    dragging with mouselook arounddragging with mouselook around
    -
    -

    4 Example scenes in this repository

    +
    +

    4 Example scenes in this repository

    -
    -

    4.1 Raytracing through voxels

    +
    +

    4.1 Raytracing through voxels

    -
    -

    raytracing fractal in voxel polygon hybrid scene.png +

    +

    raytracing fractal in voxel polygon hybrid scene.png

    -
    +

    Test scene that is generated simultaneously using: @@ -325,16 +363,12 @@ Test scene that is generated simultaneously using:

    • conventional polygons
        -
      • for realtime navigation, and -
      • -
      -
    • +
    • for realtime navigation, and
    • +
  • voxels
      -
    • for on-demand raytracing -
    • -
    -
  • +
  • for on-demand raytracing
  • +

    @@ -346,8 +380,8 @@ datastructure.

    -
    -

    4.2 Conway's Game of Life

    +
    +

    4.2 Conway's Game of Life

    The Game of Life, also known simply as Life, is a cellular automaton @@ -355,30 +389,24 @@ devised by the British mathematician John Horton Conway in 1970.

    + -
    -

    life.png +

    +

    life.png

    -
    +

    Current application projects 2D game grid/matrix onto three @@ -389,64 +417,61 @@ history (previous iterations) using glowing dots suspended in space.

    Usage:

    - +
    -+-+ - - + + - - + + - - + + - - + + - - + +
    keyresultkeyresult
    mouse click on the cell (cell)toggles cell statemouse click on the cell (cell)toggles cell state
    <space>next iteration<space>next iteration
    ENTERnext iteeration with the historyENTERnext iteeration with the history
    "c"clear the matrix"c"clear the matrix
    -
    -

    4.3 Text editors

    +
    +

    4.3 Text editors

    -
    -

    text editors.png +

    +

    text editors.png

    -
    +

    Initial test for creating user interfaces in 3D and:

      -
    • window focus handling -
    • -
    • picking objecs using mouse -
    • -
    • redirecting keyboard input to focused window -
    • +
    • window focus handling
    • +
    • picking objecs using mouse
    • +
    • redirecting keyboard input to focused window
    @@ -478,48 +503,41 @@ again, window must be unfocused first using ESC key.
  • Improve focus handling:
    • Perhaps add shortcut to navigate world without exiting entire -stack of focus. -
    • -
    • Possibility to retain and reuse recently focused elements. -
    • +stack of focus. +
    • Possibility to retain and reuse recently focused elements.
    • Store user location in the world and view direction with the focused window. So that when returning focus to far away object, -user is redirected also to proper location in the world. -
    • -
    -
  • +user is redirected also to proper location in the world. +
  • Possibility to store recently visited locations in the world and -return to them. -
  • - - +return to them. +
    -
    -

    4.4 Mathematical formulas

    +
    +

    4.4 Mathematical formulas

    -
    -

    mathematical formulas.png +

    +

    mathematical formulas.png

    -
    +
    • TODO: instead of projecting 2D visualizations onto 3D space, -visualize some formula using all 3 dimensions avaliable. -
    • +visualize some formula using all 3 dimensions avaliable.
    -
    -

    4.5 Sinus heightmaps and sphere

    +
    +

    4.5 Sinus heightmaps and sphere

    -
    -

    sinus heightmaps and sphere.png +

    +

    sinus heightmaps and sphere.png

    -
    +

    Simple test scene. Easy to implement and looks nice. @@ -527,34 +545,11 @@ Simple test scene. Easy to implement and looks nice.

    -
    -
    -

    Author: Svjatoslav Agejenko

    -

    Created: 2020-04-20 Mon 22:25

    -

    Emacs 26.1 (Org-mode 9.1.9)

    +
    +

    Author: Svjatoslav Agejenko

    +

    Created: 2021-05-29 Sat 02:31

    +

    Validate

    -
    diff --git a/doc/index.org b/doc/index.org index f883834..3d21043 100644 --- a/doc/index.org +++ b/doc/index.org @@ -1,15 +1,5 @@ #+TITLE: Sixth 3D engine demos -* (document settings) :noexport: -** use dark style for TWBS-HTML exporter -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: -#+HTML_HEAD: - * General - This program is free software: released under Creative Commons Zero (CC0) license diff --git a/pom.xml b/pom.xml index c6697bf..b8c8b20 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ svjatoslav.eu - http://svjatoslav.eu + https://svjatoslav.eu 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 3639c10..f644c3a 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java @@ -16,7 +16,6 @@ import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon.SolidPo import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.Graph; import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.WireframeSphere; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -135,7 +134,7 @@ public class GraphDemo { return new Graph(scale, data, "Tangent", location); } - public static void main(final String[] args) throws IOException { + public static void main(final String[] args) { final ViewFrame viewFrame = new ViewFrame(); final ShapeCollection geometryCollection = viewFrame.getViewPanel() 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 fa8630d..1bcdfb3 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java @@ -9,6 +9,7 @@ package eu.svjatoslav.sixth.e3d.examples; import eu.svjatoslav.sixth.e3d.geometry.Point2D; import eu.svjatoslav.sixth.e3d.geometry.Point3D; import eu.svjatoslav.sixth.e3d.geometry.Rectangle; +import eu.svjatoslav.sixth.e3d.gui.Avatar; import eu.svjatoslav.sixth.e3d.gui.ViewFrame; import eu.svjatoslav.sixth.e3d.gui.ViewPanel; import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent; @@ -60,8 +61,9 @@ public class TextEditorDemo { } private static void setAvatarLocation(ViewPanel viewPanel) { - viewPanel.getAvatar().setLocation(new Point3D(500, -300, -800)); - viewPanel.getAvatar().setAngleXZ(0.6); - viewPanel.getAvatar().setAngleYZ(-0.5); + Avatar avatar = viewPanel.getAvatar(); + avatar.setLocation(new Point3D(500, -300, -800)); + avatar.setAngleXZ(0.6); + avatar.setAngleYZ(-0.5); } } 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 1499174..0a60798 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 @@ -10,7 +10,6 @@ import eu.svjatoslav.sixth.e3d.examples.*; import javax.swing.*; import java.awt.event.ActionEvent; -import java.io.IOException; class MenuPanel extends JPanel { private static final long serialVersionUID = 2012721856427052560L; @@ -28,7 +27,7 @@ class MenuPanel extends JPanel { sequentialGroup.addComponent(new JButton(new ShowRandomPolygons())); } - private class ShowTextEditors extends AbstractAction { + private static class ShowTextEditors extends AbstractAction { ShowTextEditors() { putValue(NAME, "Text editors"); } @@ -40,7 +39,7 @@ class MenuPanel extends JPanel { } - private class ShowRain extends AbstractAction { + private static class ShowRain extends AbstractAction { ShowRain() { putValue(NAME, "Raining numbers"); } @@ -51,7 +50,7 @@ class MenuPanel extends JPanel { } } - private class ShowPointCloud extends AbstractAction { + private static class ShowPointCloud extends AbstractAction { ShowPointCloud() { putValue(NAME, "Pointcloud galaxy"); } @@ -62,22 +61,18 @@ class MenuPanel extends JPanel { } } - private class ShowMathGraphs extends AbstractAction { + private static class ShowMathGraphs extends AbstractAction { ShowMathGraphs() { putValue(NAME, "Mathematical graphs"); } @Override public void actionPerformed(final ActionEvent e) { - try { - GraphDemo.main(null); - } catch (final IOException e1) { - e1.printStackTrace(); - } + GraphDemo.main(null); } } - private class ShowRandomPolygons extends AbstractAction { + private static class ShowRandomPolygons extends AbstractAction { ShowRandomPolygons() { putValue(NAME, "Random polygons"); } @@ -88,7 +83,7 @@ class MenuPanel extends JPanel { } } - private class ShowOctree extends AbstractAction { + private static class ShowOctree extends AbstractAction { ShowOctree() { putValue(NAME, "Volumetric Octree"); } @@ -99,7 +94,7 @@ class MenuPanel extends JPanel { } } - private class ShowGameOfLife extends AbstractAction { + private static class ShowGameOfLife extends AbstractAction { ShowGameOfLife() { putValue(NAME, "Game of Life"); } diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Cell.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Cell.java index 9b14866..fb78e4b 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Cell.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Cell.java @@ -56,7 +56,7 @@ class Cell extends AbstractCompositeShape implements } private void createCellShape() { - final double halfSize = SIZE / 2; + final double halfSize = SIZE / 2f; // define 4 points corresponding to cell borders final Point3D p1 = new Point3D(-halfSize, 0, -halfSize);