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