-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Torus Object implemented, clean up some inconsistencies, clean up Ren…
…derUtil.java, support for rotation and floating number coordinates
- Loading branch information
Showing
22 changed files
with
569 additions
and
271 deletions.
There are no files selected for viewing
248 changes: 118 additions & 130 deletions
248
src/main/java/de/srendi/advancedperipherals/client/RenderUtil.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
47 changes: 47 additions & 0 deletions
47
...ava/de/srendi/advancedperipherals/client/smartglasses/objects/threedim/TorusRenderer.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,47 @@ | ||
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 com.mojang.blaze3d.vertex.VertexFormat; | ||
import de.srendi.advancedperipherals.client.RenderUtil; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.three_dim.ThreeDimensionalObject; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.three_dim.TorusObject; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.client.event.RenderLevelStageEvent; | ||
|
||
import java.util.List; | ||
|
||
public class TorusRenderer implements IThreeDObjectRenderer { | ||
|
||
@Override | ||
public void renderBatch(List<ThreeDimensionalObject> batch, RenderLevelStageEvent event, PoseStack poseStack, Vec3 view, BufferBuilder bufferBuilder) { | ||
poseStack.pushPose(); | ||
|
||
for (ThreeDimensionalObject obj : batch) { | ||
poseStack.pushPose(); | ||
onPreRender(obj); | ||
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_NORMAL); | ||
|
||
TorusObject torus = (TorusObject) obj; | ||
|
||
RenderSystem.setShader(GameRenderer::getPositionColorShader); | ||
float alpha = torus.opacity; | ||
float red = RenderUtil.getRed(torus.color); | ||
float green = RenderUtil.getGreen(torus.color); | ||
float blue = RenderUtil.getBlue(torus.color); | ||
|
||
poseStack.translate(-view.x + torus.x, -view.y + torus.y, -view.z + torus.z); | ||
RenderUtil.drawTorus(poseStack, bufferBuilder, torus.majorRadius, torus.minorRadius, 0, 0, 0, torus.xRot, torus.yRot, torus.zRot, red, green, blue, alpha, torus.rings, torus.sides); | ||
BufferUploader.drawWithShader(bufferBuilder.end()); | ||
onPostRender(obj); | ||
|
||
poseStack.popPose(); | ||
} | ||
|
||
poseStack.popPose(); | ||
} | ||
} |
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
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.