X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d-demos.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Flife%2FStar.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Flife%2FStar.java;h=0000000000000000000000000000000000000000;hp=ad242d0d689abd6e84f443b89f70fc32f4fe630b;hb=08719db537fae3645ca86f9ee6f8deba4dadf4f4;hpb=f0ebc20d0438fc46be1d98fb3643bd4196cb64c9 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java deleted file mode 100644 index ad242d0..0000000 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/life/Star.java +++ /dev/null @@ -1,41 +0,0 @@ -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 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 - ); - } - -}