public static Setting<Integer> spawnableBlocksRenderWidth;
public static Setting<Integer> spawnableBlocksRenderHeight;
public static Setting<Boolean> invertBoxColorPlayerInside;
+ public static Setting<Boolean> renderSphereAsDots;
public static void loadConfig() {
configDir = new File(".", "config");
alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
+ renderSphereAsDots = setup(config, "general", "renderSphereAsDots", false, "If set to true spheres will be rendered as dots.");
drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.Point;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.util.HashSet;
-import java.util.Set;
public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
private static final double TAU = 6.283185307179586D;
GL11.glPopMatrix();
}
- void renderSphere(OffsetPoint center, double radius, Color color, int density, int dotSize) {
- GL11.glEnable(GL11.GL_POINT_SMOOTH);
- GL11.glPointSize(dotSize);
- Renderer renderer = Renderer.startPoints()
+ void renderSphere(Point center, double radius, Color color, int density, int dotSize) {
+ if (ConfigManager.renderSphereAsDots.get()) {
+ renderDotSphere(center, radius, color, density, dotSize);
+ } else {
+ renderLineSphere(center, radius, color, density);
+ }
+ }
+
+ private void renderLineSphere(Point center, double radius, Color color, int density) {
+ GL11.glLineWidth(2f);
+ int segments = 24 + (density * 8);
+
+ double offset = ((radius - (int) radius) == 0) ? center.getY() - (int) center.getY() : 0;
+ for (double dy = offset - radius; dy <= radius + 1; dy++) {
+ double circleRadius = Math.sqrt((radius * radius) - (dy * dy));
+ if (circleRadius == 0) circleRadius = Math.sqrt(2) / 2;
+ renderCircle(center, circleRadius, color, segments, dy + 0.001F);
+ }
+ }
+
+ private void renderCircle(Point center, double radius, Color color, int segments, double dy) {
+ Renderer renderer = Renderer.startCircle()
.setColor(color);
- buildPoints(center, radius, density)
- .forEach(renderer::addPoint);
+
+ for (int a = 0; a < 360; a += 360 / segments) {
+ double heading = a * PI / 180;
+ renderer.addPoint(new OffsetPoint(center.offset(Math.cos(heading) * radius, dy, Math.sin(heading) * radius)));
+ }
+
renderer.render();
}
- private Set<OffsetPoint> buildPoints(OffsetPoint center, double radius, int density) {
+ private void renderDotSphere(Point center, double radius, Color color, int density, int dotSize) {
+ GL11.glEnable(GL11.GL_POINT_SMOOTH);
+ GL11.glPointSize(dotSize);
+ Renderer renderer = Renderer.startPoints()
+ .setColor(color);
int segments = 24 + (density * 8);
- Set<OffsetPoint> points = new HashSet<>(segments * segments);
-
double thetaSegment = PI / (double) segments;
double phiSegment = TAU / (double) segments;
double dz = radius * Math.sin(phi) * Math.sin(theta);
double dy = radius * Math.cos(phi);
- points.add(center.offset(dx, dy, dz));
+ renderer.addPoint(new OffsetPoint(center.offset(dx, dy, dz)));
}
}
- return points;
+ renderer.render();
}
}
renderCuboid(centerBox.grow(8, 8, 8), Colors.DARK_ORANGE);
}
if (level != 0) {
- renderSphere(center, boundingBox.getRadius() + 0.5, color, 5, 5);
+ renderSphere(point, boundingBox.getRadius() + 0.5, color, 5, 5);
}
}
}
return new Renderer(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
}
+ static Renderer startCircle() {
+ return new Renderer(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
+ }
+
static Renderer startQuads() {
return new Renderer(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
}
import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
+import com.irtimaled.bbor.common.models.Point;
import net.minecraft.client.resources.I18n;
import java.awt.*;
public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawningSphere> {
@Override
public void render(BoundingBoxSpawningSphere boundingBox) {
- OffsetPoint sphereCenter = new OffsetPoint(boundingBox.getPoint());
+ Point point = boundingBox.getPoint();
+ OffsetPoint sphereCenter = new OffsetPoint(point);
OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
renderCuboid(offsetBox, Color.GREEN);
String.format("%,d", spawnableSpacesCount));
}
- renderSphere(sphereCenter, BoundingBoxSpawningSphere.SAFE_RADIUS, Color.GREEN, 5, 5);
- renderSphere(sphereCenter, BoundingBoxSpawningSphere.SPAWN_RADIUS, Color.RED, 5, 5);
+ renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, Color.GREEN, 5, 5);
+ renderSphere(point, BoundingBoxSpawningSphere.SPAWN_RADIUS, Color.RED, 5, 5);
if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
renderSpawnableSpaces(boundingBox);
import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import com.irtimaled.bbor.common.models.Coords;
+import com.irtimaled.bbor.common.models.Point;
import org.lwjgl.opengl.GL11;
import java.awt.*;
}
private void renderBoundingBoxVillageAsSphere(BoundingBoxVillage boundingBox) {
- OffsetPoint center = new OffsetPoint(boundingBox.getPoint());
+ Point point = boundingBox.getPoint();
double radius = boundingBox.getRadius();
Color color = boundingBox.getColor();
int density = ConfigManager.villageSphereDensity.get();
int dotSize = ConfigManager.villageSphereDotSize.get();
- renderSphere(center, radius, color, density, dotSize);
+ renderSphere(point, radius, color, density, dotSize);
}
}