ViewFrame viewFrame = new ViewFrame();
ShapeCollection shapes = viewFrame.getViewPanel().getRootShapeCollection();
- Transform boxTransform = Transform.fromAngles(new Point3D(0, 0, 0), 0, 0);
+ viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, -100, -300));
+
+ Transform boxTransform = Transform.fromAngles(0, 0, 0, 0, 0, 0);
SolidPolygonRectangularBox box = new SolidPolygonRectangularBox(
new Point3D(-50, -50, -50),
new Point3D(50, 50, 50),
box.setTransform(boxTransform);
shapes.addShape(box);
- viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, -100, -300));
-
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
}
\ No newline at end of file
import eu.svjatoslav.sixth.e3d.renderer.octree.IntegerPoint;
import eu.svjatoslav.sixth.e3d.renderer.octree.OctreeVolume;
import eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.RaytracingCamera;
-import eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.LightSource;
import eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.RayTracer;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
+import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.GlowingPoint;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.LightSourceMarker;
private static final double magnification = 5;
private final LineAppearance gridAppearance = new LineAppearance(40, new Color(255,
0, 0, 60));
- private final Vector<LightSource> lights = new Vector<>();
+ private final Vector<eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.LightSource> lights = new Vector<>();
private OctreeVolume octreeVolume;
private ShapeCollection shapeCollection;
private ViewPanel viewPanel;
}
/**
- * Adds a light source to both the visual scene and the raytracer.
- * @param location position of the light
+ * Adds a light source to both the raytracer and rasterizer lighting systems.
+ * @param location position in octree space (will be scaled by magnification for display)
* @param color color of the light
* @param brightness intensity of the light
*/
- private void addLight(final Point3D location, final Color color,
- final float brightness) {
+ private void addLightToBothSystems(final Point3D location, final Color color,
+ final float brightness) {
shapeCollection.addShape(new LightSourceMarker(new Point3D(location)
.scaleUp(magnification), color));
- final LightSource lightSource = new LightSource(location, color,
- brightness);
+ lights.add(new eu.svjatoslav.sixth.e3d.renderer.octree.raytracer.LightSource(
+ location, color, brightness));
- lights.add(lightSource);
+ viewPanel.getLightingManager().addLight(new LightSource(
+ new Point3D(location).scaleUp(magnification), color, brightness * 50));
}
/** Creates a colorful spiral pattern of voxels in the octree. */
putRect(
new IntegerPoint( x - size, y - size, z - size),
new IntegerPoint( x + size, y + size, z + size),
- new Color((int) c1, (int) c2, (int) c3, 100));
+ new Color((int) c1, (int) c2, (int) c3, 200));
if (size > 1) {
fractal(x, y - (size * 3), z, size / 2, step + 1);
final ViewFrame viewFrame = new ViewFrame();
viewPanel = viewFrame.getViewPanel();
- viewPanel.getCamera().getTransform().setTranslation(new Point3D(0, -30, -300));
+ viewPanel.getCamera().getTransform().set(104.13, -65.04, -370.53, 0.12, 0.14, 0);
+
+ viewPanel.getLightingManager().setAmbientLight(new Color(50, 50, 50));
octreeVolume = new OctreeVolume();
new Point3D(-10000, -10000, -10000), new Point3D(10000, 10000,
10000), 4000, gridAppearance));
- // yellow light
- addLight(new Point3D(20, -450, 240), new Color(255, 255, 255, 255), 100);
-
- // red light
- addLight(new Point3D(-150, -116, 141), new Color(255, 0, 0, 255), 10);
+ addLightToBothSystems(new Point3D(20, -450, 240), new Color(255, 255, 255), 100);
+ addLightToBothSystems(new Point3D(-150, -116, 141), new Color(255, 0, 0), 10);
dotSpiral();
viewPanel.getKeyboardFocusStack().pushFocusOwner(this);
viewPanel.repaintDuringNextViewUpdate();
-
- // Ensure the render thread is started
- viewPanel.ensureRenderThreadStarted();
}
/**
* @param color the color to fill
*/
private void putRect(IntegerPoint p1, IntegerPoint p2, final Color color) {
-
- shapeCollection
- .addShape(new SolidPolygonRectangularBox(
- new Point3D(p1).scaleUp(magnification),
- new Point3D(p2).scaleUp(magnification), color));
-
+ final SolidPolygonRectangularBox box = new SolidPolygonRectangularBox(
+ new Point3D(p1).scaleUp(magnification),
+ new Point3D(p2).scaleUp(magnification), color);
+ box.setShadingEnabled(true);
+ shapeCollection.addShape(box);
octreeVolume.fillRectangle(p1, p2, color);
}
private void run() {
final ViewFrame viewFrame = new ViewFrame();
+ viewFrame.getViewPanel().getCamera().getTransform().set(-129.75, 228.27, -220.69, -0.55, 0.54, 0);
+
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
viewFrame.getViewPanel().addFrameListener(this);
- // Ensure the render thread is started
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
}
final ViewFrame viewFrame = new ViewFrame();
+ viewFrame.getViewPanel().getCamera().getTransform().set(-52.96, -239.61, -1293.29, -0.09, -0.36, 0);
+
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
for (int i = 0; i < POLYGON_COUNT; i++)
addRandomPolygon(shapeCollection);
- // Ensure the render thread is started
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
}
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
+import eu.svjatoslav.sixth.e3d.math.Transform;
import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource;
import java.util.List;
import java.util.Random;
+import static eu.svjatoslav.sixth.e3d.math.Transform.fromAngles;
+
/**
* Demo showing a shaded sphere, cube, pyramid, and cylinder with multiple colored light sources.
* Ten light sources orbit around the shapes on different paths to demonstrate dynamic lighting.
final ViewPanel viewPanel = viewFrame.getViewPanel();
final ShapeCollection shapes = viewPanel.getRootShapeCollection();
+ viewPanel.getCamera().getTransform().setTranslation(new Point3D(200, -250, -900));
+
// Use the global lighting manager from ViewPanel
viewPanel.getLightingManager().setAmbientLight(new Color(25, 25, 25));
cylinder.setShadingEnabled(true);
shapes.addShape(cylinder);
- // Camera
- viewPanel.getCamera().getTransform().setTranslation(new Point3D(200, -250, -900));
-
final MultiLightAnimator animator = new MultiLightAnimator(orbitingLights);
viewPanel.addFrameListener(animator);
viewPanel.repaintDuringNextViewUpdate();
-
- // Ensure the render thread is started
- viewPanel.ensureRenderThreadStarted();
}
/**
Point3D newPosition = new Point3D(x, y + 50, z);
orbitingLight.light.setPosition(newPosition);
- orbitingLight.marker.setTransform(eu.svjatoslav.sixth.e3d.math.Transform.fromAngles(newPosition, 0, 0));
+ orbitingLight.marker.setTransform(fromAngles(
+ newPosition.x, newPosition.y, newPosition.z, 0, 0, 0));
}
return true;
}
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
+ viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, 0, -500));
+
addSphere(geometryCollection);
addWobblySurface(geometryCollection, 200);
addWobblySurface(geometryCollection, -200);
-
- setCameraLocation(viewFrame);
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
/**
));
}
- /**
- * 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));
- }
-
}
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.Camera;
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;
final ViewFrame viewFrame = new ViewFrame();
final ViewPanel viewPanel = viewFrame.getViewPanel();
+ viewPanel.getCamera().getTransform().set(500, -300, -800, 0.6, -0.5, 0);
+
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
- setCameraLocation(viewPanel);
-
addGrid(shapeCollection);
addTextEditors(viewPanel, shapeCollection);
- // Ensure the render thread is started
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
/**
* @param shapeCollection the collection to add the grid to
*/
private static void addGrid(ShapeCollection shapeCollection) {
- final Transform transform = Transform.fromAngles(new Point3D(0, 100, 0), 0,
- Math.PI / 2);
+ final Transform transform = Transform.fromAngles(0, 100, 0, 0, Math.PI / 2, 0);
final Rectangle rectangle = new Rectangle(2000);
final LineAppearance appearance = new LineAppearance(10, new Color(
}
}
- /**
- * Sets the camera to an initial viewing position.
- * @param viewPanel the view panel whose camera to configure
- */
- private static void setCameraLocation(ViewPanel viewPanel) {
- Camera camera = viewPanel.getCamera();
- camera.getTransform().setTranslation(new Point3D(500, -300, -800));
- camera.getTransform().getRotation().set(Quaternion.fromAngles(0.6, -0.5));
- }
}
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.Camera;
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;
import java.net.URISyntaxException;
import java.util.stream.Collectors;
+import static eu.svjatoslav.sixth.e3d.math.Transform.fromAngles;
+import static java.lang.Math.PI;
+
/**
* "Text Editor City" demo showing a 3D city of text editor components.
* Creates a grid of buildings where each building has four text editor panels
final ViewFrame viewFrame = new ViewFrame();
final ViewPanel viewPanel = viewFrame.getViewPanel();
+ viewPanel.getCamera().getTransform().set(500, -300, -800, 0.6, -0.5, 0);
+
final ShapeCollection shapeCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
- setCameraLocation(viewPanel);
-
addGrid(shapeCollection);
addCity(viewPanel, shapeCollection);
- // Ensure the render thread is started
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
/**
* @param shapeCollection the collection to add the grid to
*/
private static void addGrid(ShapeCollection shapeCollection) {
- final Transform transform = Transform.fromAngles(new Point3D(0, 100, 0), 0,
- Math.PI / 2);
+ final Transform transform = fromAngles(0, 100, 0, 0, PI / 2, 0);
final Rectangle rectangle = new Rectangle(10000);
final LineAppearance appearance = new LineAppearance(10, new Color(
* @throws IOException if demo text file cannot be read
*/
private void addBuilding(ViewPanel viewPanel, ShapeCollection shapeCollection, double x, double z) throws URISyntaxException, IOException {
- Transform transform = new Transform(new Point3D(x, -390, z-200));
- addTextEditor(viewPanel, shapeCollection, transform);
+ addTextEditor(viewPanel, shapeCollection, new Transform(new Point3D(x, -390, z-200)));
- transform = Transform.fromAngles(new Point3D(x, -390, z+200),Math.PI, 0);
- addTextEditor(viewPanel, shapeCollection, transform);
+ addTextEditor(viewPanel, shapeCollection, fromAngles(x, -390, z+200, PI, 0, 0));
- transform = Transform.fromAngles(new Point3D(x-200, -390, z),Math.PI/2, 0);
- addTextEditor(viewPanel, shapeCollection, transform);
+ addTextEditor(viewPanel, shapeCollection, fromAngles(x-200, -390, z, PI/2, 0, 0));
- transform = Transform.fromAngles(new Point3D(x+200, -390, z),Math.PI/2*3f, 0);
- addTextEditor(viewPanel, shapeCollection, transform);
+ addTextEditor(viewPanel, shapeCollection, fromAngles(x+200, -390, z, PI/2*3f, 0, 0));
}
/**
}
}
- /**
- * Sets the camera to an initial viewing position for the city scene.
- * @param viewPanel the view panel whose camera to configure
- */
- private static void setCameraLocation(ViewPanel viewPanel) {
- Camera camera = viewPanel.getCamera();
- camera.getTransform().setTranslation(new Point3D(500, -300, -800));
- camera.getTransform().getRotation().set(Quaternion.fromAngles(0.6, -0.5));
- }
}
ViewPanel viewPanel = viewFrame.getViewPanel();
ShapeCollection shapes = viewPanel.getRootShapeCollection();
+ viewPanel.getCamera().getTransform().setTranslation(new Point3D(0, 0, -500));
+
double size = 150;
Point3D upperCenter = new Point3D(0, -size, 0);
shapes.addShape(triangle);
- viewPanel.getCamera().getTransform().setTranslation(new Point3D(0, 0, -500));
-
- viewPanel.ensureRenderThreadStarted();
+ viewPanel.repaintDuringNextViewUpdate();
}
}
\ No newline at end of file
viewPanel = viewFrame.getViewPanel();
viewPanel.setFrameRate(0);
shapes = viewPanel.getRootShapeCollection();
+
+ camera = viewPanel.getCamera();
+ camera.getTransform().set(0, -500, -800, 0, -0.5, 0);
+
viewPanel.addFrameListener(this);
viewPanel.getKeyboardFocusStack().pushFocusOwner(this);
- camera = viewPanel.getCamera();
- viewPanel.ensureRenderThreadStarted();
+ viewPanel.repaintDuringNextViewUpdate();
}
private void registerTests() {
+++ /dev/null
-/*
- * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
- * This project is released under Creative Commons Zero (CC0) license.
- */
-
-package eu.svjatoslav.sixth.e3d.examples.diamondsquare_demo;
-
-import eu.svjatoslav.sixth.e3d.geometry.Point3D;
-import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
-import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
-import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
-import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
-import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource;
-import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightingManager;
-import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.LightSourceMarker;
-
-/**
- * Demo showing a procedurally generated mountain landscape using the diamond-square algorithm.
- * Three colored light sources (warm orange, cool cyan, neutral white) illuminate the terrain
- * from above, demonstrating dynamic flat shading.
- */
-public class DiamondSquareLandscape {
-
- /**
- * Entry point for the diamond-square landscape demo.
- * @param args command line arguments (ignored)
- */
- public static void main(final String[] args) {
- final ViewFrame viewFrame = new ViewFrame();
- ViewPanel viewPanel = viewFrame.getViewPanel();
-
- final ShapeCollection shapes = viewPanel.getRootShapeCollection();
-
- setLights(viewFrame, shapes);
-
- shapes.addShape(new DiamondSquareTerrain(129, 0.0, 300.0, 42));
-
- viewPanel.getCamera().getTransform()
- .setTranslation(new Point3D(0, -600, -800));
-
- viewPanel.ensureRenderThreadStarted();
- }
-
- // TODO: add javadoc here
- private static void setLights(ViewFrame viewFrame, ShapeCollection shapes) {
- LightingManager lightingManager = viewFrame.getViewPanel().getLightingManager();
- lightingManager.setAmbientLight(new Color(250, 150, 100));
-
- final LightSource warmLight = new LightSource(
- new Point3D(-400, -500, 0),
- new Color(255, 180, 100),
- 190.0
- );
- final LightSource coolLight = new LightSource(
- new Point3D(400, -500, 0),
- new Color(100, 200, 255),
- 220.0
- );
- final LightSource neutralLight = new LightSource(
- new Point3D(0, -600, 300),
- new Color(255, 255, 255),
- 250.0
- );
-
- lightingManager.addLight(warmLight);
- lightingManager.addLight(coolLight);
- lightingManager.addLight(neutralLight);
-
- shapes.addShape(new LightSourceMarker(warmLight.getPosition(), new Color(255, 180, 100)));
- shapes.addShape(new LightSourceMarker(coolLight.getPosition(), new Color(100, 200, 255)));
- shapes.addShape(new LightSourceMarker(neutralLight.getPosition(), new Color(255, 255, 255)));
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+
+package eu.svjatoslav.sixth.e3d.examples.diamondsquare_demo;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
+import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
+import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
+import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource;
+import eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightingManager;
+import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.LightSourceMarker;
+
+/**
+ * Demo showing a procedurally generated mountain landscape using the diamond-square algorithm.
+ * Three colored light sources (warm orange, cool cyan, neutral white) illuminate the terrain
+ * from above, demonstrating dynamic flat shading.
+ */
+public class TerrainDemo {
+
+ /**
+ * Entry point for the terrain demo.
+ * @param args command line arguments (ignored)
+ */
+ public static void main(final String[] args) {
+ final ViewFrame viewFrame = new ViewFrame();
+ ViewPanel viewPanel = viewFrame.getViewPanel();
+
+ viewPanel.getCamera().getTransform().set(-307.96, -847.50, -768.20, -0.52, -0.66, 0);
+
+ final ShapeCollection shapes = viewPanel.getRootShapeCollection();
+
+ setLights(viewFrame, shapes);
+
+ shapes.addShape(new DiamondSquareTerrain(129, 0.0, 300.0, 42));
+
+ viewPanel.repaintDuringNextViewUpdate();
+ }
+
+ /**
+ * Sets up the lighting for the terrain scene.
+ * @param viewFrame the view frame containing the lighting manager
+ * @param shapes the shape collection to add light source markers to
+ */
+ private static void setLights(ViewFrame viewFrame, ShapeCollection shapes) {
+ LightingManager lightingManager = viewFrame.getViewPanel().getLightingManager();
+ lightingManager.setAmbientLight(new Color(250, 150, 100));
+
+ final LightSource warmLight = new LightSource(
+ new Point3D(-400, -500, 0),
+ new Color(255, 180, 100),
+ 190.0
+ );
+ final LightSource coolLight = new LightSource(
+ new Point3D(400, -500, 0),
+ new Color(100, 200, 255),
+ 220.0
+ );
+ final LightSource neutralLight = new LightSource(
+ new Point3D(0, -600, 300),
+ new Color(255, 255, 255),
+ 250.0
+ );
+
+ lightingManager.addLight(warmLight);
+ lightingManager.addLight(coolLight);
+ lightingManager.addLight(neutralLight);
+
+ shapes.addShape(new LightSourceMarker(warmLight.getPosition(), new Color(255, 180, 100)));
+ shapes.addShape(new LightSourceMarker(coolLight.getPosition(), new Color(100, 200, 255)));
+ shapes.addShape(new LightSourceMarker(neutralLight.getPosition(), new Color(255, 255, 255)));
+ }
+}
\ No newline at end of file
final ViewFrame viewFrame = new ViewFrame();
+ viewFrame.getViewPanel().getCamera().getTransform().set(-1099.85, -2862.44, 144.32, -1.09, -0.60, 0);
+
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
- Transform transform = Transform.fromAngles(new Point3D(0, -1000, 1000), 0, 0);
+ Transform transform = Transform.fromAngles(0, -1000, 1000, 0, 0, 0);
// add galaxy
geometryCollection.addShape(new Galaxy(500, 3, 10000, transform));
- // Ensure the render thread is started
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
}
final ShapeCollection geometryCollection = viewFrame.getViewPanel()
.getRootShapeCollection();
+ viewFrame.getViewPanel().getCamera().getTransform().set(-613.58, -408.70, -351.41, -0.60, -0.54, -0.00);
+
addMathFormulas(geometryCollection);
addSurfaceGraph(geometryCollection);
-
- setCameraLocation(viewFrame);
- viewFrame.getViewPanel().ensureRenderThreadStarted();
+ viewFrame.getViewPanel().repaintDuringNextViewUpdate();
}
/**
geometryCollection.addShape(surface);
}
- /**
- * 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));
- }
-
}
\ No newline at end of file
package eu.svjatoslav.sixth.e3d.examples.launcher;
-import eu.svjatoslav.sixth.e3d.examples.diamondsquare_demo.DiamondSquareLandscape;
+import eu.svjatoslav.sixth.e3d.examples.diamondsquare_demo.TerrainDemo;
import eu.svjatoslav.sixth.e3d.examples.SineHeightmap;
import eu.svjatoslav.sixth.e3d.examples.graph_demo.MathGraphsDemo;
import eu.svjatoslav.sixth.e3d.examples.MinimalExample;
new DemoEntry("Shaded Shapes",
"Shapes lit by orbiting colored light sources",
new ShowShadedShapes()),
- new DemoEntry("Diamond-Square Landscape",
+ new DemoEntry("Procedural Terrain",
"Procedural mountains with 3 colored light sources",
- new ShowDiamondSquareLandscape()),
+ new ShowTerrainDemo()),
new DemoEntry("Graphics Benchmark",
"Automated performance measuring FPS across modes",
new ShowGraphicsBenchmark()),
}
}
- private static class ShowDiamondSquareLandscape extends AbstractAction {
- ShowDiamondSquareLandscape() {
- putValue(NAME, "Diamond-Square Landscape");
+ private static class ShowTerrainDemo extends AbstractAction {
+ ShowTerrainDemo() {
+ putValue(NAME, "Procedural Terrain");
}
@Override
public void actionPerformed(final ActionEvent e) {
- DiamondSquareLandscape.main(null);
+ TerrainDemo.main(null);
}
}
import eu.svjatoslav.sixth.e3d.geometry.Point3D;
import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
-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;
// create application frame visible to the user
final ViewFrame viewFrame = new ViewFrame();
+ final ViewPanel viewPanel = viewFrame.getViewPanel();
+
+ viewPanel.getCamera().getTransform().set(100, -50, -200, 0.2f, -0.7f, 0);
- final ShapeCollection shapeCollection = viewFrame.getViewPanel()
- .getRootShapeCollection();
+ final ShapeCollection shapeCollection = viewPanel.getRootShapeCollection();
// add matrix
shapeCollection.addShape(MATRIX);
// add wire-frame grid (optional)
shapeCollection.addShape(createGrid());
- final ViewPanel viewPanel = viewFrame.getViewPanel();
-
- setCameraOrientation(viewPanel.getCamera());
-
// enable receiving of keyboard events
viewPanel.getKeyboardFocusStack().pushFocusOwner(this);
// Done! World is built. So ensure screen is updated too.
viewPanel.repaintDuringNextViewUpdate();
-
- // Ensure the render thread is started
- viewPanel.ensureRenderThreadStarted();
}
/**
*/
private Grid2D createGrid() {
return new Grid2D(
- Transform.fromAngles(
- new Point3D( // Grid positioning:
- 0, // center
- 100, // below the main scene
- 0), // center
+ Transform.fromAngles(0, 100, 0, 0, Math.PI / 2, 0),
- // Grid orientation:
- 0, // no rotation along XZ axis
- Math.PI / 2), // face down
+ new Rectangle(800),
- new Rectangle(800), // large enough, square grid
+ 5, 5,
- 5, 5, // grid will be divided to 5x5 segments
-
- new LineAppearance(3, // line thickness
- new Color("FF000050") // red and quite transparent
+ new LineAppearance(3,
+ new Color("FF000050")
)
);
}
- /**
- * Sets the camera to an initial viewing position for the matrix.
- * @param camera the camera to configure
- */
- private void setCameraOrientation(final Camera camera) {
- camera.getTransform().setTranslation(new Point3D(100, -50, -200));
- camera.getTransform().getRotation().set(Quaternion.fromAngles(0.2f, -0.7f));
- }
-
}