* <li>{@link SolidCubesTest} - Solid-color polygon rendering</li>
* <li>{@link TexturedCubesTest} - Textured polygon rendering</li>
* <li>{@link WireframeCubesTest} - Line rendering</li>
+ * <li>{@link StarGridTest} - Billboard (glowing point) rendering</li>
* </ul>
*/
public class GraphicsBenchmark implements FrameListener, KeyboardInputHandler {
tests.add(new SolidCubesTest());
tests.add(new TexturedCubesTest());
tests.add(new WireframeCubesTest());
+ tests.add(new StarGridTest());
}
private void startNextTest() {
--- /dev/null
+/*
+ * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+
+package eu.svjatoslav.sixth.e3d.examples.benchmark;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
+import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
+import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.GlowingPoint;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * Benchmark test for glowing point (star) billboards.
+ * Renders a grid of glowing points arranged in a cube formation to test
+ * billboard rendering and texture blending performance.
+ */
+public class StarGridTest implements BenchmarkTest {
+
+ private static final int GRID_SIZE = 16;
+ private static final double SPACING = 80;
+ private static final double STAR_SIZE = 20;
+ private static final int UNIQUE_COLORS_COUNT = 30;
+ private static final long RANDOM_SEED = 42;
+
+ private final Random random = new Random(RANDOM_SEED);
+ private final List<Object> stars = new ArrayList<>();
+ private List<Color> colors;
+
+ @Override
+ public String getName() {
+ return "Star Grid";
+ }
+
+ @Override
+ public void setup(ShapeCollection shapes) {
+ initializeColors();
+ random.setSeed(RANDOM_SEED);
+ double offset = -(GRID_SIZE - 1) * SPACING / 2;
+
+ for (int x = 0; x < GRID_SIZE; x++) {
+ for (int y = 0; y < GRID_SIZE; y++) {
+ for (int z = 0; z < GRID_SIZE; z++) {
+ double px = offset + x * SPACING;
+ double py = offset + y * SPACING;
+ double pz = offset + z * SPACING;
+
+ Color color = colors.get(random.nextInt(colors.size()));
+ GlowingPoint star = new GlowingPoint(
+ new Point3D(px, py, pz),
+ STAR_SIZE,
+ color
+ );
+ shapes.addShape(star);
+ stars.add(star);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void teardown(ShapeCollection shapes) {
+ for (Object star : stars) {
+ shapes.getShapes().remove(star);
+ }
+ stars.clear();
+ }
+
+ private void initializeColors() {
+ colors = new ArrayList<>();
+ random.setSeed(RANDOM_SEED);
+ for (int i = 0; i < UNIQUE_COLORS_COUNT; i++) {
+ colors.add(new Color(
+ random.nextDouble() + 0.5,
+ random.nextDouble() + 0.5,
+ random.nextDouble() + 0.5,
+ 255
+ ));
+ }
+ }
+}
\ No newline at end of file