2 * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
7 package eu.svjatoslav.sixth.e3d.examples;
9 import eu.svjatoslav.sixth.e3d.geometry.Point2D;
10 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
11 import eu.svjatoslav.sixth.e3d.geometry.Rectangle;
12 import eu.svjatoslav.sixth.e3d.gui.Avatar;
13 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
14 import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
15 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
16 import eu.svjatoslav.sixth.e3d.math.Transform;
17 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
18 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
19 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
20 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D;
22 public class TextEditorDemo {
24 public static void main(final String[] args) {
26 final ViewFrame viewFrame = new ViewFrame();
27 final ViewPanel viewPanel = viewFrame.getViewPanel();
29 final ShapeCollection shapeCollection = viewFrame.getViewPanel()
30 .getRootShapeCollection();
32 setAvatarLocation(viewPanel);
34 addGrid(shapeCollection);
36 addTextEditors(viewPanel, shapeCollection);
39 private static void addGrid(ShapeCollection shapeCollection) {
40 final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
43 final Rectangle rectangle = new Rectangle(2000);
44 final LineAppearance appearance = new LineAppearance(10, new Color(
47 shapeCollection.addShape(new Grid2D(transform, rectangle, 10, 10, appearance));
50 private static void addTextEditors(ViewPanel viewPanel, ShapeCollection shapeCollection) {
52 for (double z = -500 * m; z <= (500 * m); z += 250 * m)
53 for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
55 final TextEditComponent textEditor = new TextEditComponent(
56 new Transform(new Point3D(x, 0, z)), viewPanel,
57 new Point2D(200, 120));
59 shapeCollection.addShape(textEditor);
63 private static void setAvatarLocation(ViewPanel viewPanel) {
64 Avatar avatar = viewPanel.getAvatar();
65 avatar.setLocation(new Point3D(500, -300, -800));
66 avatar.setAngleXZ(0.6);
67 avatar.setAngleYZ(-0.5);