Add javadocs to generic rendering objects

This commit is contained in:
James Seibel
2024-06-30 15:28:00 -05:00
parent f68edcbfea
commit 5a71e4015c
6 changed files with 90 additions and 20 deletions
@@ -128,6 +128,10 @@ public class DhApi
*/
public static IDhApiWrapperFactory wrapperFactory = null;
/**
* Used to add custom objects to DH's render pass.
* @since API 3.0.0
*/
public static IDhApiCustomRenderRegister renderRegister = null;
}
@@ -5,6 +5,16 @@ import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import java.util.List;
/**
* Handles adding, removing, and creating
* {@link IDhApiRenderableBoxGroup} objects,
* which can be used to render custom objects into
* DH's terrain.
*
* @author James Seibel
* @version 2024-6-30
* @since API 3.0.0
*/
public interface IDhApiCustomRenderRegister
{
void add(IDhApiRenderableBoxGroup cubeGroup) throws IllegalArgumentException;
@@ -7,21 +7,39 @@ import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import java.util.List;
import java.util.function.Consumer;
/**
* A list of {@link DhApiRenderableBox}'s that
* can be rendered to DH's terrain pass.
*
* @see DhApiRenderableBox
*
* @author James Seibel
* @version 2024-6-30
* @since API 3.0.0
*/
public interface IDhApiRenderableBoxGroup extends List<DhApiRenderableBox>
{
/** @return the ID for this specific group */
long getId();
/** Sets whether this group should render or not. */
void setActive(boolean active);
/** @return if active this group will render. */
boolean isActive();
/** Sets where this group will render in the level. */
void setOriginBlockPos(DhApiVec3f pos);
/** @return the block position in the level that all {@see DhApiRenderableBox} will render relative to. */
DhApiVec3f getOriginBlockPos();
/**
* Called right before this group is rendered. <br>
* This is a good place to change the origin or notify of any box changes.
*/
void setPreRenderFunc(Consumer<DhApiRenderParam> renderEventParam);
/**
* If a cube's color, position, or other property are changed this method
* If a cube's color, position, or other property is changed this method
* must be called for those changes to render. <br><br>
*
* Note: changing the group's position via {@link #setOriginBlockPos} doesn't
@@ -1,21 +1,46 @@
package com.seibel.distanthorizons.api.objects.render;
import com.seibel.distanthorizons.coreapi.util.math.Vec3f;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import java.awt.*;
public final class DhApiRenderableBox
/**
* @see IDhApiRenderableBoxGroup
*
* @author James Seibel
* @version 2024-6-30
* @since API 3.0.0
*/
public class DhApiRenderableBox
{
public Vec3f minPos;
public Vec3f maxPos;
/** the position closest to (-inf,-inf) */
public DhApiVec3f minPos;
/** the position closest to (+inf,+inf) */
public DhApiVec3f maxPos;
public Color color;
public boolean fullBright = false;
/* TODO */
//public boolean fullBright = false;
public DhApiRenderableBox(Vec3f minPos, Vec3f maxPos, Color color)
//==============//
// constructors //
//==============//
public DhApiRenderableBox(DhApiVec3f minPos, float width, Color color)
{
this(minPos, new DhApiVec3f(
minPos.x + width,
minPos.y + width,
minPos.z + width
), color);
}
public DhApiRenderableBox(DhApiVec3f minPos, DhApiVec3f maxPos, Color color)
{
this.minPos = minPos;
this.maxPos = maxPos;
@@ -64,16 +64,26 @@ import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
/**
* Handles rendering generic groups of {@link DhApiRenderableBox}.
*
* @see IDhApiCustomRenderRegister
* @see DhApiRenderableBox
*/
public class GenericObjectRenderer implements IDhApiCustomRenderRegister
{
public static GenericObjectRenderer INSTANCE = new GenericObjectRenderer();
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final ConfigBasedSpamLogger SPAM_LOGGER = new ConfigBasedSpamLogger(LogManager.getLogger(TestRenderer.class), () -> EDhApiLoggerMode.LOG_ALL_TO_CHAT, 1);
public static final ConfigBasedSpamLogger SPAM_LOGGER = new ConfigBasedSpamLogger(LogManager.getLogger(GenericObjectRenderer.class), () -> EDhApiLoggerMode.LOG_ALL_TO_CHAT, 1);
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
public static boolean RENDER_DEBUG_OBJECTS = true;
/**
* Can be used to troubleshoot the renderer.
* If enabled several debug objects will render around (0,150,0).
*/
public static final boolean RENDER_DEBUG_OBJECTS = true;
// rendering setup
@@ -217,7 +227,7 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
// single giant box
IDhApiRenderableBoxGroup singleGiantBoxGroup = DhApi.Delayed.renderRegister.createForSingleBox(
new DhApiRenderableBox(
new Vec3f(0f,0f,0f), new Vec3f(16f,190f,16f),
new DhApiVec3f(0f,0f,0f), new DhApiVec3f(16f,190f,16f),
new Color(Color.CYAN.getRed(), Color.CYAN.getGreen(), Color.CYAN.getBlue(), 125))
);
DhApi.Delayed.renderRegister.add(singleGiantBoxGroup);
@@ -226,7 +236,7 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
// single slender box
IDhApiRenderableBoxGroup singleTallBoxGroup = DhApi.Delayed.renderRegister.createForSingleBox(
new DhApiRenderableBox(
new Vec3f(16f,0f,31f), new Vec3f(17f,2000f,32f),
new DhApiVec3f(16f,0f,31f), new DhApiVec3f(17f,2000f,32f),
new Color(Color.GREEN.getRed(), Color.GREEN.getGreen(), Color.GREEN.getBlue(), 125))
);
DhApi.Delayed.renderRegister.add(singleTallBoxGroup);
@@ -237,7 +247,7 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
for (int i = 0; i < 18; i++)
{
absBoxList.add(new DhApiRenderableBox(
new Vec3f(0f+i,150f+i,24f), new Vec3f(1f+i,151f+i,25f),
new DhApiVec3f(0f+i,150f+i,24f), new DhApiVec3f(1f+i,151f+i,25f),
new Color(Color.ORANGE.getRed(), Color.ORANGE.getGreen(), Color.ORANGE.getBlue())));
}
IDhApiRenderableBoxGroup absolutePosBoxGroup = DhApi.Delayed.renderRegister.createAbsolutePositionedGroup(absBoxList);
@@ -249,7 +259,7 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
for (int i = 0; i < 8; i+=2)
{
relBoxList.add(new DhApiRenderableBox(
new Vec3f(0f,0f+i,0f), new Vec3f(1f,1f+i,1f),
new DhApiVec3f(0f,0f+i,0f), new DhApiVec3f(1f,1f+i,1f),
new Color(Color.MAGENTA.getRed(), Color.MAGENTA.getGreen(), Color.MAGENTA.getBlue())));
}
IDhApiRenderableBoxGroup relativePosBoxGroup = DhApi.Delayed.renderRegister.createRelativePositionedGroup(
@@ -272,7 +282,7 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
for (int z = 0; z < 50*2; z+=2)
{
massRelBoxList.add(new DhApiRenderableBox(
new Vec3f(0f-x, 0f, 0f-z), new Vec3f(1f-x, 1f, 1f-z),
new DhApiVec3f(0f-x, 0f, 0f-z), new DhApiVec3f(1f-x, 1f, 1f-z),
new Color(Color.RED.getRed(), Color.RED.getGreen(), Color.RED.getBlue())));
}
}
@@ -371,12 +371,18 @@ public class LodRenderer
// Disable blending for opaque rendering
GL32.glDisable(GL32.GL_BLEND);
// terrain
profiler.popPush("LOD Opaque");
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
// TODO: Directional culling
this.bufferHandler.renderOpaque(this, renderEventParam);
// custom objects
profiler.popPush("Custom Objects");
GenericObjectRenderer.INSTANCE.render(renderEventParam, profiler);
// SSAO
if (Config.Client.Advanced.Graphics.Ssao.enabled.get())
{
profiler.popPush("LOD SSAO");
@@ -421,9 +427,6 @@ public class LodRenderer
DebugRenderer.INSTANCE.render(combinedMatrix);
}
profiler.popPush("Custom Objects");
GenericObjectRenderer.INSTANCE.render(renderEventParam, profiler);
profiler.popPush("LOD cleanup");