2 * Sixth - System for data storage, computation, exploration and interaction.
3 * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.sixth.e3d.examples;
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
14 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
15 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
16 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
17 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon.SolidPolygon;
18 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.Grid3D;
22 private static void addRandomPolygon(final ShapeCollection geometryCollection) {
23 final Point3D polygonLocation = getRandomPoint(1000);
25 final double polygonAverageSize = 30;
27 final Point3D point1 = new Point3D(polygonLocation);
28 point1.add(getRandomPoint(polygonAverageSize));
30 final Point3D point2 = new Point3D(polygonLocation);
31 point2.add(getRandomPoint(polygonAverageSize));
33 final Point3D point3 = new Point3D(polygonLocation);
34 point3.add(getRandomPoint(polygonAverageSize));
36 final Color color = new Color(Math.random(), Math.random(),
39 final SolidPolygon polygon = new SolidPolygon(point1, point2, point3,
41 geometryCollection.addShape(polygon);
44 private static Point3D getRandomPoint(final double amplitude) {
45 return new Point3D((Math.random() * amplitude * 2d) - amplitude,
46 (Math.random() * amplitude * 2d) - amplitude, (Math.random()
51 public static void main(final String[] args) {
53 final ViewFrame viewFrame = new ViewFrame();
55 final ShapeCollection shapeCollection = viewFrame.getView()
56 .getContext().getRootShapeCollection();
59 final LineAppearance appearance = new LineAppearance(5, new Color(100,
62 shapeCollection.addShape(new Grid3D(new Point3D(1000, -1000, -1000),
63 new Point3D(-1000, 1000, 1000), 300, appearance));
65 // add random polygons
66 for (int i = 0; i < 3000; i++)
67 addRandomPolygon(shapeCollection);