2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
7 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
8 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
9 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
11 import java.util.ArrayList;
13 public class WireframeSphere extends AbstractCompositeShape {
15 ArrayList<Point3D> previousRing = new ArrayList<>();
17 public WireframeSphere(final Point3D location, final float radius,
18 final LineAppearance lineFactory) {
21 final double step = Math.PI / 10;
23 final Point3D center = new Point3D();
27 for (double j = 0d; j <= (Math.PI * 2); j += step) {
29 Point3D oldPoint = null;
32 for (double i = 0; i <= (Math.PI * 2); i += step) {
33 final Point3D newPoint = new Point3D(0, 0, radius);
34 newPoint.rotate(center, i, j);
37 addShape(lineFactory.getLine(newPoint, oldPoint));
40 final Point3D previousRingPoint = previousRing
42 addShape(lineFactory.getLine(newPoint, previousRingPoint));
44 previousRing.set(pointIndex, newPoint);
46 previousRing.add(newPoint);