-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Box and Block renderer with depth test and culling configurable
We couldn't use batching for this. We want to change the color, opacity and depthtest/culling for every object and one render call would not support different settings for each object
- Loading branch information
Showing
22 changed files
with
297 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/de/srendi/advancedperipherals/client/smartglasses/OverlayModuleOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../java/de/srendi/advancedperipherals/client/smartglasses/objects/threedim/BoxRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.srendi.advancedperipherals.client.smartglasses.objects.threedim; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.BufferBuilder; | ||
import com.mojang.blaze3d.vertex.BufferUploader; | ||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import de.srendi.advancedperipherals.client.RenderUtil; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.three_dim.ThreeDimensionalObject; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.client.event.RenderLevelStageEvent; | ||
|
||
import java.util.List; | ||
|
||
public class BoxRenderer implements IThreeDObjectRenderer { | ||
|
||
@Override | ||
public void renderBatch(List<ThreeDimensionalObject> batch, RenderLevelStageEvent event, PoseStack poseStack, Vec3 view, BufferBuilder bufferBuilder) { | ||
poseStack.pushPose(); | ||
|
||
for (ThreeDimensionalObject renderableObject : batch) { | ||
poseStack.pushPose(); | ||
onPreRender(renderableObject); | ||
bufferBuilder.begin(RenderType.translucent().mode(), DefaultVertexFormat.POSITION_COLOR_NORMAL); | ||
|
||
RenderSystem.setShader(GameRenderer::getPositionColorShader); | ||
float alpha = renderableObject.opacity; | ||
float red = (float) (renderableObject.color >> 16 & 255) / 255.0F; | ||
float green = (float) (renderableObject.color >> 8 & 255) / 255.0F; | ||
float blue = (float) (renderableObject.color & 255) / 255.0F; | ||
|
||
poseStack.translate(-view.x + renderableObject.getX(), -view.y + renderableObject.getY(), -view.z + renderableObject.getZ()); | ||
RenderUtil.drawBox(poseStack, bufferBuilder, red, green, blue, alpha, renderableObject.getMaxX(), renderableObject.getMaxY(), renderableObject.getMaxX()); | ||
BufferUploader.drawWithShader(bufferBuilder.end()); | ||
onPostRender(renderableObject); | ||
|
||
poseStack.popPose(); | ||
} | ||
|
||
poseStack.popPose(); | ||
} | ||
} |
19 changes: 16 additions & 3 deletions
19
...rendi/advancedperipherals/client/smartglasses/objects/threedim/IThreeDObjectRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
package de.srendi.advancedperipherals.client.smartglasses.objects.threedim; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.BufferBuilder; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import de.srendi.advancedperipherals.client.smartglasses.objects.IObjectRenderer; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.two_dim.RenderableObject; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.three_dim.ThreeDimensionalObject; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.client.event.RenderLevelStageEvent; | ||
import net.minecraftforge.client.gui.overlay.ForgeGui; | ||
|
||
import java.util.List; | ||
|
||
public interface IThreeDObjectRenderer extends IObjectRenderer { | ||
|
||
void renderBatch(List<RenderableObject> object, RenderLevelStageEvent event, PoseStack poseStack, Vec3 view, BufferBuilder bufferBuilder); | ||
void renderBatch(List<ThreeDimensionalObject> batch, RenderLevelStageEvent event, PoseStack poseStack, Vec3 view, BufferBuilder bufferBuilder); | ||
|
||
default void onPostRender(ThreeDimensionalObject object) { | ||
if (object.disableCulling) | ||
RenderSystem.enableCull(); | ||
if (object.disableDepthTest) | ||
RenderSystem.enableDepthTest(); | ||
} | ||
|
||
default void onPreRender(ThreeDimensionalObject object) { | ||
if (object.disableCulling) | ||
RenderSystem.disableCull(); | ||
if (object.disableDepthTest) | ||
RenderSystem.disableDepthTest(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.