refactor(demos): adapt to new Transform API
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 20 Mar 2026 21:03:46 +0000 (23:03 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 20 Mar 2026 21:04:22 +0000 (23:04 +0200)
15 files changed:
doc/screenshots/life.png [deleted file]
doc/screenshots/mathematical formulas.png [deleted file]
doc/screenshots/raytracing fractal in voxel polygon hybrid scene.png [deleted file]
doc/screenshots/sinus heightmaps and sphere.png [deleted file]
doc/screenshots/text editors 2.png [deleted file]
doc/screenshots/text editors.png [deleted file]
src/main/java/eu/svjatoslav/sixth/e3d/examples/FillRateTest.java [deleted file]
src/main/java/eu/svjatoslav/sixth/e3d/examples/GraphDemo.java [deleted file]
src/main/java/eu/svjatoslav/sixth/e3d/examples/MinimalExample.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/ShadedShapesDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/TextEditorDemo2.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/LitSolidCubesTest.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/galaxy_demo/PointCloudDemo.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/life_demo/Main.java

diff --git a/doc/screenshots/life.png b/doc/screenshots/life.png
deleted file mode 100644 (file)
index 565f5ab..0000000
Binary files a/doc/screenshots/life.png and /dev/null differ
diff --git a/doc/screenshots/mathematical formulas.png b/doc/screenshots/mathematical formulas.png
deleted file mode 100644 (file)
index fab8469..0000000
Binary files a/doc/screenshots/mathematical formulas.png and /dev/null differ
diff --git a/doc/screenshots/raytracing fractal in voxel polygon hybrid scene.png b/doc/screenshots/raytracing fractal in voxel polygon hybrid scene.png
deleted file mode 100644 (file)
index 7094240..0000000
Binary files a/doc/screenshots/raytracing fractal in voxel polygon hybrid scene.png and /dev/null differ
diff --git a/doc/screenshots/sinus heightmaps and sphere.png b/doc/screenshots/sinus heightmaps and sphere.png
deleted file mode 100644 (file)
index 0d3e92b..0000000
Binary files a/doc/screenshots/sinus heightmaps and sphere.png and /dev/null differ
diff --git a/doc/screenshots/text editors 2.png b/doc/screenshots/text editors 2.png
deleted file mode 100644 (file)
index cb1733f..0000000
Binary files a/doc/screenshots/text editors 2.png and /dev/null differ
diff --git a/doc/screenshots/text editors.png b/doc/screenshots/text editors.png
deleted file mode 100644 (file)
index 8567b8b..0000000
Binary files a/doc/screenshots/text editors.png and /dev/null differ
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/FillRateTest.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/FillRateTest.java
deleted file mode 100644 (file)
index 74f415b..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
- * This project is released under Creative Commons Zero (CC0) license.
- */
-
-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.gui.Camera;
-import eu.svjatoslav.sixth.e3d.gui.FrameListener;
-import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
-import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
-import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationUserInputTracker;
-import eu.svjatoslav.sixth.e3d.math.Vertex;
-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.texturedpolygon.TexturedPolygon;
-import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
-import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.solid.SolidPolygonCube;
-import eu.svjatoslav.sixth.e3d.renderer.raster.texture.Texture;
-
-import java.awt.event.KeyEvent;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Fill-rate benchmark demo that tests the engine's rendering performance.
- * Creates a 16x16x16 grid of cubes (4096 total) that orbit around the center point.
- * The camera follows a wobbling orbital path while FPS statistics are printed to console.
- * 
- * <p>Key controls:
- * <ul>
- *   <li>Press 1 - Switch to solid color cubes (faster rendering)</li>
- *   <li>Press 2 - Switch to textured cubes (slower rendering, tests texture fill-rate)</li>
- * </ul>
- * 
- * @see SolidPolygonCube
- * @see TexturedPolygon
- */
-public class FillRateTest extends WorldNavigationUserInputTracker implements FrameListener {
-
-    /** Number of cubes along each axis of the grid. */
-    private static final int GRID_SIZE = 16;
-    /** Spacing between cube centers in world units. */
-    private static final double SPACING = 80;
-    /** Half-size of each cube. */
-    private static final double CUBE_SIZE = 25;
-    /** Distance of camera from center during orbit. */
-    private static final double ORBIT_DISTANCE = 1200;
-    /** Angular speed of camera orbit in radians per millisecond. */
-    private static final double ORBIT_SPEED = 0.0003;
-    /** Amplitude of vertical wobble during orbit. */
-    private static final double WOBBLE_AMPLITUDE = 800;
-    /** Number of unique textures to create for textured mode. */
-    private static final int TEXTURE_COUNT = 20;
-
-    private final ViewFrame viewFrame;
-    private final ViewPanel viewPanel;
-    private final ShapeCollection shapes;
-    private final Random random = new Random(42);
-    private final Camera camera;
-
-    private final List<Object> cubes = new ArrayList<>();
-    private final Texture[] textures = new Texture[TEXTURE_COUNT];
-    private final int[] cubeTextureIndices;
-
-    private boolean texturedMode = false;
-    private double orbitAngle = 0;
-
-    private long frameCount = 0;
-    private long fpsStartTime = System.currentTimeMillis();
-    private long totalFrameCount = 0;
-    private long appStartTime = System.currentTimeMillis();
-
-    /** Resets FPS statistics counters. */
-    private void resetFpsStats() {
-        frameCount = 0;
-        fpsStartTime = System.currentTimeMillis();
-        totalFrameCount = 0;
-        appStartTime = fpsStartTime;
-    }
-
-    /**
-     * Entry point for the fill-rate test demo.
-     * @param args command line arguments (ignored)
-     */
-    public static void main(String[] args) {
-        new FillRateTest();
-    }
-
-    /**
-     * Constructs the fill-rate test demo with a 1920x1080 window.
-     * Creates the cube grid and initializes camera orbit animation.
-     */
-    public FillRateTest() {
-        viewFrame = new ViewFrame(1920, 1080);
-        viewPanel = viewFrame.getViewPanel();
-        viewPanel.setFrameRate(0);
-        shapes = viewPanel.getRootShapeCollection();
-
-        viewPanel.addFrameListener(this);
-        viewPanel.getKeyboardFocusStack().pushFocusOwner(this);
-
-        camera = viewPanel.getCamera();
-
-        cubeTextureIndices = new int[GRID_SIZE * GRID_SIZE * GRID_SIZE];
-        for (int i = 0; i < cubeTextureIndices.length; i++) {
-            cubeTextureIndices[i] = random.nextInt(TEXTURE_COUNT);
-        }
-
-        createTextures();
-        createCubes(false);
-    }
-
-    /** Creates the pool of randomly colored glow textures. */
-    private void createTextures() {
-        for (int i = 0; i < TEXTURE_COUNT; i++) {
-            textures[i] = createGlowTexture(
-                    50 + random.nextInt(200),
-                    50 + random.nextInt(200),
-                    50 + random.nextInt(200)
-            );
-        }
-    }
-
-    /**
-     * Creates a glow texture with the specified RGB color.
-     * @param r red component (0-255)
-     * @param g green component (0-255)
-     * @param b blue component (0-255)
-     * @return a 64x64 texture with glowing border effect
-     */
-    private Texture createGlowTexture(int r, int g, int b) {
-        int texSize = 64;
-        Texture texture = new Texture(texSize, texSize, 2);
-
-        java.awt.Graphics2D gr = texture.graphics;
-        gr.setBackground(new java.awt.Color(r, g, b, 80));
-        gr.clearRect(0, 0, texSize, texSize);
-
-        int glowWidth = 6;
-        for (int i = 0; i < glowWidth; i++) {
-            int intensity = (int) (255.0 * (glowWidth - i) / glowWidth);
-            java.awt.Color glowColor = new java.awt.Color(
-                    Math.min(255, r + intensity),
-                    Math.min(255, g + intensity),
-                    Math.min(255, b + intensity),
-                    200 - i * 30
-            );
-            gr.setColor(glowColor);
-            gr.drawRect(i, i, texSize - 1 - 2 * i, texSize - 1 - 2 * i);
-        }
-
-        gr.dispose();
-        texture.resetResampledBitmapCache();
-        return texture;
-    }
-
-    /** Removes all cubes from the scene. */
-    private void clearCubes() {
-        for (Object cube : cubes) {
-            shapes.getShapes().remove(cube);
-        }
-        cubes.clear();
-    }
-
-    /**
-     * Creates the grid of cubes in the scene.
-     * @param textured if true, creates textured cubes; if false, creates solid-colored cubes
-     */
-    private void createCubes(boolean textured) {
-        clearCubes();
-        random.setSeed(42);
-
-        double offset = -(GRID_SIZE - 1) * SPACING / 2;
-        int idx = 0;
-
-        for (int x = 0; x < GRID_SIZE; x++) {
-            for (int y = 0; y < GRID_SIZE; y++) {
-                for (int z = 0; z < GRID_SIZE; z++) {
-                    double px = offset + x * SPACING;
-                    double py = offset + y * SPACING;
-                    double pz = offset + z * SPACING;
-
-                    if (textured) {
-                        Texture tex = textures[cubeTextureIndices[idx]];
-                        TexturedCube cube = new TexturedCube(
-                                new Point3D(px, py, pz),
-                                CUBE_SIZE,
-                                tex
-                        );
-                        shapes.addShape(cube);
-                        cubes.add(cube);
-                    } else {
-                        Color color = new Color(
-                                50 + random.nextInt(150),
-                                100 + random.nextInt(155),
-                                50 + random.nextInt(150),
-                                40
-                        );
-                        SolidPolygonCube cube = new SolidPolygonCube(
-                                new Point3D(px, py, pz),
-                                CUBE_SIZE,
-                                color
-                        );
-                        shapes.addShape(cube);
-                        cubes.add(cube);
-                    }
-                    idx++;
-                }
-            }
-        }
-    }
-
-    /**
-     * Called each frame to animate the camera orbit and track FPS.
-     * @param viewPanel the view panel rendering the scene
-     * @param millisecondsSinceLastFrame time elapsed since last frame
-     * @return true to continue rendering
-     */
-    @Override
-    public boolean onFrame(ViewPanel viewPanel, int millisecondsSinceLastFrame) {
-        orbitAngle += ORBIT_SPEED * millisecondsSinceLastFrame;
-
-        double x = Math.sin(orbitAngle) * ORBIT_DISTANCE;
-        double z = Math.cos(orbitAngle) * ORBIT_DISTANCE;
-        double y = Math.sin(orbitAngle * 1.8934) * WOBBLE_AMPLITUDE;
-
-        camera.getTransform().setTranslation(new Point3D(x, y, z));
-        camera.lookAt(new Point3D(0, 0, 0));
-
-        frameCount++;
-        totalFrameCount++;
-        long now = System.currentTimeMillis();
-        long elapsed = now - fpsStartTime;
-        if (elapsed >= 1000) {
-            int fps = (int) (frameCount * 1000 / elapsed);
-            long totalElapsed = now - appStartTime;
-            double avgFps = totalFrameCount * 1000.0 / totalElapsed;
-            System.out.println("current: " + fps + " average: " + String.format("%.2f", avgFps));
-            frameCount = 0;
-            fpsStartTime = now;
-        }
-
-        return true;
-    }
-
-    /**
-     * Handles keyboard input for switching between rendering modes.
-     * @param event the key event
-     * @param viewPanel the view panel
-     * @return true if the event was consumed
-     */
-    @Override
-    public boolean keyPressed(KeyEvent event, ViewPanel viewPanel) {
-        switch (event.getKeyCode()) {
-            case KeyEvent.VK_1:
-                if (texturedMode) {
-                    texturedMode = false;
-                    createCubes(false);
-                    resetFpsStats();
-                }
-                return true;
-            case KeyEvent.VK_2:
-                if (!texturedMode) {
-                    texturedMode = true;
-                    createCubes(true);
-                    resetFpsStats();
-                }
-                return true;
-        }
-        return super.keyPressed(event, viewPanel);
-    }
-
-    /**
-     * A cube composed of textured polygons.
-     * Each face is rendered as two triangles with UV coordinates for texture mapping.
-     */
-    private static class TexturedCube extends AbstractCompositeShape {
-
-        /**
-         * Constructs a textured cube at the specified position.
-         * @param center the center position of the cube
-         * @param size half-size of the cube (total width is 2*size)
-         * @param texture the texture to apply to all faces
-         */
-        public TexturedCube(Point3D center, double size, Texture texture) {
-            double s = size;
-            Point3D p1 = new Point3D(center.x - s, center.y - s, center.z - s);
-            Point3D p7 = new Point3D(center.x + s, center.y + s, center.z + s);
-
-            Point3D p2 = new Point3D(p7.x, p1.y, p1.z);
-            Point3D p3 = new Point3D(p7.x, p1.y, p7.z);
-            Point3D p4 = new Point3D(p1.x, p1.y, p7.z);
-            Point3D p5 = new Point3D(p1.x, p7.y, p1.z);
-            Point3D p6 = new Point3D(p7.x, p7.y, p1.z);
-            Point3D p8 = new Point3D(p1.x, p7.y, p7.z);
-
-            Point2D t00 = new Point2D(0, 0);
-            Point2D t10 = new Point2D(64, 0);
-            Point2D t01 = new Point2D(0, 64);
-            Point2D t11 = new Point2D(64, 64);
-
-            addTexturedFace(p1, p2, p3, p4, t00, t10, t11, t01, texture);
-            addTexturedFace(p5, p8, p7, p6, t00, t01, t11, t10, texture);
-            addTexturedFace(p1, p5, p6, p2, t00, t01, t11, t10, texture);
-            addTexturedFace(p3, p7, p8, p4, t00, t10, t11, t01, texture);
-            addTexturedFace(p1, p4, p8, p5, t00, t10, t11, t01, texture);
-            addTexturedFace(p2, p6, p7, p3, t00, t01, t11, t10, texture);
-
-            setBackfaceCulling(true);
-        }
-
-        /**
-         * Adds a quad face as two textured triangles.
-         * @param p1 first corner position
-         * @param p2 second corner position
-         * @param p3 third corner position
-         * @param p4 fourth corner position
-         * @param t1 texture coordinate for p1
-         * @param t2 texture coordinate for p2
-         * @param t3 texture coordinate for p3
-         * @param t4 texture coordinate for p4
-         * @param texture the texture to apply
-         */
-        private void addTexturedFace(Point3D p1, Point3D p2, Point3D p3, Point3D p4,
-                                     Point2D t1, Point2D t2, Point2D t3, Point2D t4,
-                                     Texture texture) {
-            TexturedPolygon tri1 = new TexturedPolygon(
-                    new Vertex(p1, t1),
-                    new Vertex(p2, t2),
-                    new Vertex(p3, t3),
-                    texture
-            );
-            tri1.setBackfaceCulling(true);
-
-            TexturedPolygon tri2 = new TexturedPolygon(
-                    new Vertex(p1, t1),
-                    new Vertex(p3, t3),
-                    new Vertex(p4, t4),
-                    texture
-            );
-            tri2.setBackfaceCulling(true);
-
-            addShape(tri1);
-            addShape(tri2);
-        }
-    }
-}
\ 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
deleted file mode 100755 (executable)
index 1be37ee..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Sixth 3D engine demos. Author: Svjatoslav Agejenko. 
- * This project is released under Creative Commons Zero (CC0) license.
- *
-*/
-
-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.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.Graph;
-import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.WireframeSphere;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Demo showing various mathematical function graphs rendered in 3D.
- * Displays sine, cosine, tangent, and composite function graphs arranged around
- * a central sphere, with two wobbly surfaces above and below.
- */
-public class GraphDemo {
-
-    /**
-     * Creates a new GraphDemo instance.
-     */
-    public GraphDemo() {
-    }
-
-    /** Frequency of the wave pattern in the wobbly surfaces. */
-    private static final double WAVE_FREQUENCY = 50d;
-    /** Amplitude of the wave pattern in the wobbly surfaces. */
-    private static final double WAVE_AMPLITUDE = 50d;
-    /** Color for the square plates in the wobbly surfaces. */
-    private static final Color SQUARE_PLATE_COLOR = new Color("88F7");
-    /** Scale factor for the graph rendering. */
-    private static final double GRAPH_SCALE = 50d;
-
-    /**
-     * Creates a single square plate at the specified position.
-     * @param shapeCollection the collection to add the plate to
-     * @param y the Y coordinate (elevation)
-     * @param x the X coordinate
-     * @param z the Z coordinate
-     */
-    private static void makeSquarePlate(final ShapeCollection shapeCollection,
-                                        final double y, final double x, final double z) {
-        final Point3D p1 = new Point3D(x, y, z);
-        final Point3D p2 = new Point3D(x + 20, y, z);
-        final Point3D p3 = new Point3D(x, y, z + 20);
-        final Point3D p4 = new Point3D(x + 20, y, z + 20);
-        final SolidPolygon polygon1 = new SolidPolygon(p1, p2, p3, SQUARE_PLATE_COLOR);
-        final SolidPolygon polygon2 = new SolidPolygon(p4, p2, p3, SQUARE_PLATE_COLOR);
-        shapeCollection.addShape(polygon1);
-        shapeCollection.addShape(polygon2);
-    }
-
-    /**
-     * Creates a wobbly surface composed of square plates arranged in a wave pattern.
-     * @param shapeCollection the collection to add plates to
-     * @param surfaceElevation the base Y elevation of the surface
-     */
-    private static void addWobblySurface(final ShapeCollection shapeCollection,
-                                         final double surfaceElevation) {
-        for (double x = -500; x < 500; x += 20)
-            for (double z = -500; z < 500; z += 20) {
-
-                // use Pythagorean theorem to compute distance from the center
-                final double distanceFromCenter = Math.sqrt((x * x) + (z * z));
-
-                double plateElevation = Math.sin(distanceFromCenter / WAVE_FREQUENCY) * WAVE_AMPLITUDE;
-
-                makeSquarePlate(shapeCollection, plateElevation + surfaceElevation, x,
-                        z);
-            }
-    }
-
-    /**
-     * Creates a graph of the cosine function.
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing y = cos(x)
-     */
-    private static Graph getCosineGraph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            final double y = Math.cos(x);
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "Cosine", location);
-    }
-
-    /**
-     * Creates a graph of y = sin(tan(x)).
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing the composite function
-     */
-    private static Graph getFormula1Graph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            final double y = Math.sin(Math.tan(x));
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "y = sin(tan(x))", location);
-    }
-
-    /**
-     * Creates a graph of y = (10-x)^2 / 30.
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing the parabola
-     */
-    private static Graph getFormula2Graph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            final double y = (Math.pow((10 - x), 2) / 30) - 2;
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "y = ( (10-x)^2 ) / 30", location);
-    }
-
-    /**
-     * Creates a graph of y = sin(x/2) + sin(x/1.26).
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing the composite sine wave
-     */
-    private static Graph getFormula3Graph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            final double y = Math.sin(x / 2) + Math.sin(x / 1.26);
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "y = sin(x/2) + sin(x/1.26)", location);
-    }
-
-    /**
-     * Creates a graph of the sine function.
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing y = sin(x)
-     */
-    private static Graph getSineGraph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            final double y = Math.sin(x);
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "Sine", location);
-    }
-
-    /**
-     * Creates a graph of the tangent function with clamped values.
-     * @param location the position of the graph in 3D space
-     * @return a Graph component showing y = tan(x) with clamped range
-     */
-    private static Graph getTangentGraph(final Point3D location) {
-        final List<Point2D> data = new ArrayList<>();
-        for (double x = 0; x < 20; x += 0.25) {
-            double y = Math.tan(x);
-
-            if (y > 2)
-                y = 2;
-            if (y < -2)
-                y = -2;
-
-            final Point2D p = new Point2D(x, y);
-            data.add(p);
-        }
-
-        return new Graph(GRAPH_SCALE, data, "Tangent", location);
-    }
-
-    /**
-     * Entry point for the graph demo.
-     * @param args command line arguments (ignored)
-     */
-    public static void main(final String[] args) {
-
-        final ViewFrame viewFrame = new ViewFrame();
-        final ShapeCollection geometryCollection = viewFrame.getViewPanel()
-                .getRootShapeCollection();
-
-        addMathFormulas(geometryCollection);
-        addSphere(geometryCollection);
-        addWobblySurface(geometryCollection, 200);
-        addWobblySurface(geometryCollection, -200);
-
-        setCameraLocation(viewFrame);
-        
-        // Ensure the render thread is started
-        viewFrame.getViewPanel().ensureRenderThreadStarted();
-    }
-
-    /**
-     * Adds a wireframe sphere at the center of the scene.
-     * @param geometryCollection the collection to add the sphere to
-     */
-    private static void addSphere(ShapeCollection geometryCollection) {
-        // add sphere
-        geometryCollection.addShape(new WireframeSphere(new Point3D(0, 0, 0),
-                100,
-                new LineAppearance(
-                        4,
-                        new Color(255,0, 0, 30))
-        ));
-    }
-
-    /**
-     * Adds all mathematical formula graphs to the scene.
-     * @param geometryCollection the collection to add graphs to
-     */
-    private static void addMathFormulas(ShapeCollection geometryCollection) {
-        int z = 1000;
-        Point3D location = new Point3D(-600, -300, z);
-        geometryCollection.addShape(getSineGraph(location));
-
-        location = new Point3D(600, -300, z);
-        geometryCollection.addShape(getFormula1Graph(location));
-
-        location = new Point3D(-600, 0, z);
-        geometryCollection.addShape(getCosineGraph(location));
-
-        location = new Point3D(600, 0, z);
-        geometryCollection.addShape(getFormula2Graph(location));
-
-        location = new Point3D(-600, 300, z);
-        geometryCollection.addShape(getTangentGraph(location));
-
-        location = new Point3D(600, 300, z);
-        geometryCollection.addShape(getFormula3Graph(location));
-    }
-
-    /**
-     * Sets the camera to an initial viewing position.
-     * @param viewFrame the view frame whose camera to configure
-     */
-    private static void setCameraLocation(ViewFrame viewFrame) {
-        viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, 0, -500));
-    }
-
-}
index af755e8..91c368c 100644 (file)
@@ -28,7 +28,7 @@ public class MinimalExample {
         ViewFrame viewFrame = new ViewFrame();
         ShapeCollection shapes = viewFrame.getViewPanel().getRootShapeCollection();
 
-        Transform boxTransform = new Transform(new Point3D(0, 0, 0), 0, 0);
+        Transform boxTransform = Transform.fromAngles(new Point3D(0, 0, 0), 0, 0);
         SolidPolygonRectangularBox box = new SolidPolygonRectangularBox(
                 new Point3D(-50, -50, -50),
                 new Point3D(50, 50, 50),
index 2969b4e..49f121a 100644 (file)
@@ -200,7 +200,7 @@ public class ShadedShapesDemo {
 
                 Point3D newPosition = new Point3D(x, y + 50, z);
                 orbitingLight.light.setPosition(newPosition);
-                orbitingLight.marker.setTransform(new eu.svjatoslav.sixth.e3d.math.Transform(newPosition, 0, 0));
+                orbitingLight.marker.setTransform(eu.svjatoslav.sixth.e3d.math.Transform.fromAngles(newPosition, 0, 0));
             }
             return true;
         }
index 450e100..49640dd 100644 (file)
@@ -14,6 +14,7 @@ import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.LookAndFeel;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
+import eu.svjatoslav.sixth.e3d.math.Quaternion;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
@@ -60,7 +61,7 @@ public class TextEditorDemo {
      * @param shapeCollection the collection to add the grid to
      */
     private static void addGrid(ShapeCollection shapeCollection) {
-        final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
+        final Transform transform = Transform.fromAngles(new Point3D(0, 100, 0), 0,
                 Math.PI / 2);
 
         final Rectangle rectangle = new Rectangle(2000);
@@ -95,6 +96,6 @@ public class TextEditorDemo {
     private static void setCameraLocation(ViewPanel viewPanel) {
         Camera camera = viewPanel.getCamera();
         camera.getTransform().setTranslation(new Point3D(500, -300, -800));
-        camera.getTransform().setRotation(0.6, -0.5);
+        camera.getTransform().getRotation().setQuaternion(Quaternion.fromAngles(0.6, -0.5));
     }
 }
index 79a183c..0539fb4 100644 (file)
@@ -14,6 +14,7 @@ import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.LookAndFeel;
 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
+import eu.svjatoslav.sixth.e3d.math.Quaternion;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
@@ -99,7 +100,7 @@ public class TextEditorDemo2 {
      * @param shapeCollection the collection to add the grid to
      */
     private static void addGrid(ShapeCollection shapeCollection) {
-        final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
+        final Transform transform = Transform.fromAngles(new Point3D(0, 100, 0), 0,
                 Math.PI / 2);
 
         final Rectangle rectangle = new Rectangle(10000);
@@ -123,13 +124,13 @@ public class TextEditorDemo2 {
         Transform transform = new Transform(new Point3D(x, -390, z-200));
         addTextEditor(viewPanel, shapeCollection, transform);
 
-        transform = new Transform(new Point3D(x, -390, z+200),Math.PI, 0);
+        transform = Transform.fromAngles(new Point3D(x, -390, z+200),Math.PI, 0);
         addTextEditor(viewPanel, shapeCollection, transform);
 
-        transform = new Transform(new Point3D(x-200, -390, z),Math.PI/2, 0);
+        transform = Transform.fromAngles(new Point3D(x-200, -390, z),Math.PI/2, 0);
         addTextEditor(viewPanel, shapeCollection, transform);
 
-        transform = new Transform(new Point3D(x+200, -390, z),Math.PI/2*3f, 0);
+        transform = Transform.fromAngles(new Point3D(x+200, -390, z),Math.PI/2*3f, 0);
         addTextEditor(viewPanel, shapeCollection, transform);
     }
 
@@ -193,6 +194,6 @@ public class TextEditorDemo2 {
     private static void setCameraLocation(ViewPanel viewPanel) {
         Camera camera = viewPanel.getCamera();
         camera.getTransform().setTranslation(new Point3D(500, -300, -800));
-        camera.getTransform().setRotation(0.6, -0.5);
+        camera.getTransform().getRotation().setQuaternion(Quaternion.fromAngles(0.6, -0.5));
     }
 }
index 0651938..c45246c 100644 (file)
@@ -177,7 +177,7 @@ public class LitSolidCubesTest implements BenchmarkTest {
 
                 Point3D newPos = new Point3D(x, y, z);
                 ol.light.setPosition(newPos);
-                ol.marker.setTransform(new eu.svjatoslav.sixth.e3d.math.Transform(newPos, 0, 0));
+                ol.marker.setTransform(eu.svjatoslav.sixth.e3d.math.Transform.fromAngles(newPos, 0, 0));
             }
             return true;
         }
index 731b35e..87b7c97 100644 (file)
@@ -34,7 +34,7 @@ public class PointCloudDemo {
         final ShapeCollection geometryCollection = viewFrame.getViewPanel()
                 .getRootShapeCollection();
 
-        Transform transform = new Transform(new Point3D(0, -1000, 1000), 0, 0);
+        Transform transform = Transform.fromAngles(new Point3D(0, -1000, 1000), 0, 0);
 
         // add galaxy
         geometryCollection.addShape(new Galaxy(500, 3, 10000, transform));
index 4258dc7..0c1b4b6 100644 (file)
@@ -6,6 +6,7 @@ import eu.svjatoslav.sixth.e3d.gui.Camera;
 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.WorldNavigationUserInputTracker;
+import eu.svjatoslav.sixth.e3d.math.Quaternion;
 import eu.svjatoslav.sixth.e3d.math.Transform;
 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
@@ -104,7 +105,7 @@ public class Main extends WorldNavigationUserInputTracker {
      */
     private Grid2D createGrid() {
         return new Grid2D(
-                new Transform(
+                Transform.fromAngles(
                         new Point3D( // Grid positioning:
                                 0, // center
                                 100, // below the main scene
@@ -130,7 +131,7 @@ public class Main extends WorldNavigationUserInputTracker {
      */
     private void setCameraOrientation(final Camera camera) {
         camera.getTransform().setTranslation(new Point3D(100, -50, -200));
-        camera.getTransform().setRotation(0.2f, -0.7f);
+        camera.getTransform().getRotation().setQuaternion(Quaternion.fromAngles(0.2f, -0.7f));
     }
 
 }