X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Frenderer%2Fraster%2Fshapes%2Fbasic%2FGlowingPoint.java;h=14e213c63174657e77189d2965c48bfdf7c04e1d;hb=24e68b2f99037dec8a3442030dcb15013c930652;hp=e96426a6b48772bedb3e05438fb8cb39bb8bf5a0;hpb=ed4236f4d37f20f56347e47af41f8bcc4fafb8a1;p=sixth-3d.git diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java index e96426a..14e213c 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java @@ -1,12 +1,7 @@ /* - * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - * + * Sixth 3D engine. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. */ - package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic; import eu.svjatoslav.sixth.e3d.geometry.Point3D; @@ -23,6 +18,10 @@ import static java.lang.Math.sqrt; public class GlowingPoint extends ForwardOrientedTexture { private static final int TEXTURE_RESOLUTION_PIXELS = 100; + /** + * A set of all existing glowing points. + * Used to reuse textures of glowing points of the same color. + */ private static final Set glowingPoints = Collections.newSetFromMap(new WeakHashMap<>()); private final Color color; @@ -36,10 +35,15 @@ public class GlowingPoint extends ForwardOrientedTexture { } } + private static double computeScale(double pointSize) { return pointSize / ((double) (TEXTURE_RESOLUTION_PIXELS / 50f)); } + /** + * Returns a texture for a glowing point of the given color. + * The texture is a circle with a gradient from transparent to the given color. + */ private static Texture getTexture(final Color color) { // attempt to reuse texture from existing glowing point of the same color synchronized (glowingPoints) { @@ -52,6 +56,10 @@ public class GlowingPoint extends ForwardOrientedTexture { return createTexture(color); } + /** + * Creates a texture for a glowing point of the given color. + * The texture is a circle with a gradient from transparent to the given color. + */ private static Texture createTexture(final Color color) { final Texture texture = new Texture(TEXTURE_RESOLUTION_PIXELS, TEXTURE_RESOLUTION_PIXELS, 1); int halfResolution = TEXTURE_RESOLUTION_PIXELS / 2;