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.LookAndFeel;
16 import eu.svjatoslav.sixth.e3d.gui.textEditorComponent.TextEditComponent;
17 import eu.svjatoslav.sixth.e3d.math.Transform;
18 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
19 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
20 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
21 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid2D;
23 public class TextEditorDemo {
25 public static void main(final String[] args) {
27 final ViewFrame viewFrame = new ViewFrame();
28 final ViewPanel viewPanel = viewFrame.getViewPanel();
30 final ShapeCollection shapeCollection = viewFrame.getViewPanel()
31 .getRootShapeCollection();
33 setAvatarLocation(viewPanel);
35 addGrid(shapeCollection);
37 addTextEditors(viewPanel, shapeCollection);
40 private static void addGrid(ShapeCollection shapeCollection) {
41 final Transform transform = new Transform(new Point3D(0, 100, 0), 0,
44 final Rectangle rectangle = new Rectangle(2000);
45 final LineAppearance appearance = new LineAppearance(10, new Color(
48 shapeCollection.addShape(new Grid2D(transform, rectangle, 10, 10, appearance));
51 private static void addTextEditors(ViewPanel viewPanel, ShapeCollection shapeCollection) {
53 for (double z = -500 * m; z <= (500 * m); z += 250 * m)
54 for (double x = -500 * m; x <= (500 * m); x += 250 * m) {
56 final TextEditComponent textEditor = new TextEditComponent(
57 new Transform(new Point3D(x, 0, z)), viewPanel,
58 new Point2D(200, 120), new LookAndFeel());
60 shapeCollection.addShape(textEditor);
64 private static void setAvatarLocation(ViewPanel viewPanel) {
65 Avatar avatar = viewPanel.getAvatar();
66 avatar.setLocation(new Point3D(500, -300, -800));
67 avatar.setAngleXZ(0.6);
68 avatar.setAngleYZ(-0.5);