1 package eu.svjatoslav.sixth.e3d.examples.life;
3 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
4 import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
5 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.GlowingPoint;
7 import java.util.ArrayList;
10 public class Star extends GlowingPoint{
11 public static final int STAR_SIZE = 10;
13 public static final int UNIQUE_STARS_COUNT = 30;
15 private static final List<Color> uniqueStarColors = new ArrayList<>();
18 * A little hack to save RAM. We are going to have potentially lot of stars.
19 * Instead of creating new individual texture for each star, Sixth 3D engine
20 * uses internal optimization and reuses existing star textures, if star with
21 * identical color already exists. To take advantage ot such optimization
22 * we create here limited set of precomputed star colors and later reuse them.
25 for (int i = 0; i < UNIQUE_STARS_COUNT; i++)
34 public Star(Point3D location) {
37 uniqueStarColors.get((int) (Math.random() * uniqueStarColors.size())) // pick random pre-generated color