Skip to content

Commit

Permalink
add panorama view as menu option, and make it the default fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Nov 10, 2023
1 parent fabbc1f commit d2f6698
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class GuiMenuWorldSettings extends GuiVROptionsBase {
}

return true;
})
}),
new VROptionEntry(VRSettings.VrOptions.MENU_WORLD_FALLBACK),
};

public GuiMenuWorldSettings(Screen guiScreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,163 @@ public static void disableStencilTest() {
}
}

private static final ResourceLocation cubeFront = new ResourceLocation("textures/gui/title/background/panorama_0.png");
private static final ResourceLocation cubeRight = new ResourceLocation("textures/gui/title/background/panorama_1.png");
private static final ResourceLocation cubeBack = new ResourceLocation("textures/gui/title/background/panorama_2.png");
private static final ResourceLocation cubeLeft = new ResourceLocation("textures/gui/title/background/panorama_3.png");
private static final ResourceLocation cubeUp = new ResourceLocation("textures/gui/title/background/panorama_4.png");
private static final ResourceLocation cubeDown = new ResourceLocation("textures/gui/title/background/panorama_5.png");
private static final ResourceLocation dirt = new ResourceLocation("minecraft:textures/block/dirt.png");
private static final ResourceLocation grass = new ResourceLocation("minecraft:textures/block/grass_block_top.png");

public static void renderMenuPanorama(PoseStack poseStack) {
BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder();
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.clear(GL11C.GL_COLOR_BUFFER_BIT | GL11C.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
RenderSystem.depthMask(true);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(1, 1, 1, 1);
poseStack.pushPose();

poseStack.translate(-50F, -50F, -50.0F);

Matrix4f matrix = poseStack.last().pose();

// down
RenderSystem.setShaderTexture(0, cubeDown);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 0, 0, 0)
.uv(0, 0).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
bufferbuilder.vertex(matrix, 0, 0, 100)
.uv(0, 1).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 0, 100)
.uv(1, 1).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 0, 0)
.uv(1, 0).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

// up
RenderSystem.setShaderTexture(0, cubeUp);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 0, 100, 100)
.uv(0, 0).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
bufferbuilder.vertex(matrix, 0, 100, 0)
.uv(0, 1).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 0)
.uv(1, 1).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 100)
.uv(1, 0).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

// left
RenderSystem.setShaderTexture(0, cubeLeft);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 0, 0, 0)
.uv(1, 1).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 0, 100, 0)
.uv(1, 0).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 0, 100, 100)
.uv(0, 0).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 0, 0, 100)
.uv(0, 1).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

// right
RenderSystem.setShaderTexture(0, cubeRight);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 100, 0, 0)
.uv(0, 1).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 0, 100)
.uv(1, 1).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 100)
.uv(1, 0).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 0)
.uv(0, 0).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

// front
RenderSystem.setShaderTexture(0, cubeFront);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 0, 0, 0)
.uv(0, 1).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
bufferbuilder.vertex(matrix, 100, 0, 0)
.uv(1, 1).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 0)
.uv(1, 0).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
bufferbuilder.vertex(matrix, 0, 100, 0)
.uv(0, 0).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

//back
RenderSystem.setShaderTexture(0, cubeBack);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
bufferbuilder.vertex(matrix, 0, 0, 100).
uv(1, 1).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
bufferbuilder.vertex(matrix, 0, 100, 100)
.uv(1, 0).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
bufferbuilder.vertex(matrix, 100, 100, 100)
.uv(0, 0).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
bufferbuilder.vertex(matrix, 100, 0, 100)
.uv(0, 1).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
BufferUploader.drawWithShader(bufferbuilder.end());

poseStack.popPose();

Vector2f area = dataHolder.vr.getPlayAreaSize();
if (area == null) {
area = new Vector2f(2, 2);
}
for (int i = 0; i < 2; i++) {
float width = area.x + i * 2;
float length = area.y + i * 2;

poseStack.pushPose();
RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);

int r, g, b;
if (i == 0) {
RenderSystem.setShaderTexture(0, grass);
// plains grass color, but a bit darker
r = 114;
g = 148;
b = 70;
} else {
RenderSystem.setShaderTexture(0, dirt);
r = g = b = 128;
}
Matrix4f matrix4f = poseStack.last().pose();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
poseStack.translate(-width / 2.0F, 0.0F, -length / 2.0F);

final int repeat = 4; // texture wraps per meter

bufferbuilder
.vertex(matrix4f, 0, 0.005f * -i, 0)
.uv(0, 0)
.color(r, g, b, 255)
.normal(0, 1, 0).endVertex();
bufferbuilder
.vertex(matrix4f, 0, 0.005f * -i, length)
.uv(0, repeat * length)
.color(r, g, b, 255)
.normal(0, 1, 0).endVertex();
bufferbuilder
.vertex(matrix4f, width, 0.005f * -i, length)
.uv(repeat * width, repeat * length)
.color(r, g, b, 255)
.normal(0, 1, 0).endVertex();
bufferbuilder
.vertex(matrix4f, width, 0.005f * -i, 0)
.uv(repeat * width, 0)
.color(r, g, b, 255)
.normal(0, 1, 0).endVertex();

BufferUploader.drawWithShader(bufferbuilder.end());
poseStack.popPose();
}
}

public static void renderJrbuddasAwesomeMainMenuRoomNew(PoseStack pMatrixStack) {
int repeat = 4; // texture wraps per meter
float height = 2.5F;
Expand Down Expand Up @@ -704,7 +861,11 @@ public static void renderGuiLayer(float partialTicks, boolean depthAlways, PoseS
dataHolder.menuWorldRenderer.destroy();
}
} else {
renderJrbuddasAwesomeMainMenuRoomNew(poseStack);
if (dataHolder.vrSettings.menuWorldFallbackPanorama) {
renderMenuPanorama(poseStack);
} else {
renderJrbuddasAwesomeMainMenuRoomNew(poseStack);
}
}
poseStack.popPose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ public enum UpdateType implements OptionEnum<UpdateType> {
public boolean shouldRenderSelf = false;
@SettingField(VrOptions.MENU_WORLD_SELECTION)
public MenuWorld menuWorldSelection = MenuWorld.BOTH;
@SettingField(VrOptions.MENU_WORLD_FALLBACK)
public boolean menuWorldFallbackPanorama = true;
//

//Mixed Reality
Expand Down Expand Up @@ -1690,6 +1692,7 @@ Object convertOption(String value) {
}
}
},
MENU_WORLD_FALLBACK(false, true, "vivecraft.options.menuworldfallback.panorama", "vivecraft.options.menuworldfallback.dirtbox"), // fallback for when menurwold is not shown
HRTF_SELECTION(false, false) { // HRTF

// this is now handled by vanilla
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ protected TitleScreenMixin(Component component) {

@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/PanoramaRenderer;render(FF)V"), method = "render", index = 1)
public float vivecraft$maybeNoPanorama(float alpha) {
return VRState.vrRunning && ClientDataHolderVR.getInstance().menuWorldRenderer.isReady() ? 0.0F : alpha;
return VRState.vrRunning && (ClientDataHolderVR.getInstance().menuWorldRenderer.isReady() || ClientDataHolderVR.getInstance().vrSettings.menuWorldFallbackPanorama) ? 0.0F : alpha;
}
}
4 changes: 4 additions & 0 deletions common/src/main/resources/assets/vivecraft/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@
"vivecraft.options.disabled": "Deaktiviert",
"vivecraft.options.editlist": "Liste bearbeiten",
"vivecraft.options.addnew": "Neuen hinzufügen",
"vivecraft.options.menuworldfallback.dirtbox": "Erdbox",
"vivecraft.options.menuworldfallback.panorama": "Panorama",
"_comment_m5": "Option names",
"vivecraft.options.LOW_HEALTH_INDICATOR": "Gesundheit Indikator",
"vivecraft.options.SHADER_GUI_RENDER": "Shader GUI",
Expand All @@ -418,6 +420,7 @@
"vivecraft.options.VR_SETTINGS_BUTTON_VISIBLE": "VR Einstellungsknopf Sichtbar",
"vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Einstellungsknopf Position",
"vivecraft.options.INGAME_BINDINGS_IN_GUI": "Im-Spiel Tasten im GUI",
"vivecraft.options.MENU_WORLD_FALLBACK": "Ersatz Methode",
"_comment_m6": "Option tooltips",
"vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulsiert den Bildschirm Rot bei niedriger Gesundheit, um den derzeitigen Gesundheitszustand anzuzeigen.",
"vivecraft.options.SHADER_GUI_RENDER.tooltip": "Bestimmt wie die Benutzeroberfläche mit Shadern dargestellt wird.\n Nach Shader: zeigt die Benutzeroberfläche ohne Shader, beste Kompatibilität. (Probleme mit PTGI HRR)\n Transparent: zeigt die Benutzeroberfläche mit Shadern und transparent. (Probleme mit Sildurs Vibrant)\n Undurchsichtig: zeigt die Benutzeroberfläche mit Shadern, aber Undurchsichtig",
Expand All @@ -433,6 +436,7 @@
"vivecraft.options.CHAT_MESSAGE_STENCIL.tooltip": "Schreibt eine Nachricht in den Chat, wenn ein anderer Mod erkannt wird, der ebenfalls die Schablone verwendet.",
"vivecraft.options.VR_HOTSWITCH.tooltip": "Schnellwechsel wechselt automatisch zu NONVR wenn das Headset abgenommen wird.\nWenn diese Einstellung ausgeschalten ist, befindet sich das Spiel dauerhaft im VR Modus, sobald VR eingeschalten wurde",
"vivecraft.options.INGAME_BINDINGS_IN_GUI.tooltip": "Erlaubt es alle Im-Spiel Tasten in Menüs zu verwenden. Dies kann zu nicht gewollten doppel Tastendrücken führen.",
"vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "Wenn Menü Welten deaktiviert sind oder noch nicht geladen sind, wird dieser Ersatz stattdessen verwendet",
"_comment_m10": "Messages",
"vivecraft.messages.mode": "Modus:",
"vivecraft.messages.novrhotswitchinglegacy": "Veralteten Vivecraft server mod erkannt. Dieser Server unterstützt kein VR Schnellwechsel. Sie können den Modus nur im Hauptmenü wechseln.",
Expand Down
4 changes: 4 additions & 0 deletions common/src/main/resources/assets/vivecraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@
"vivecraft.options.updatetype.alpha": "Alpha",
"vivecraft.options.updatetype.beta": "Beta",
"vivecraft.options.updatetype.release": "Release",
"vivecraft.options.menuworldfallback.dirtbox": "Dirtbox",
"vivecraft.options.menuworldfallback.panorama": "Panorama",
"_comment_m5": "Option names",
"vivecraft.options.LOW_HEALTH_INDICATOR": "Health Indicator",
"vivecraft.options.SHADER_GUI_RENDER": "Shaders GUI",
Expand All @@ -421,6 +423,7 @@
"vivecraft.options.VR_SETTINGS_BUTTON_VISIBLE": "VR Settings Button Visible",
"vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Settings Button Position",
"vivecraft.options.INGAME_BINDINGS_IN_GUI": "In-Game Bindings In GUI",
"vivecraft.options.MENU_WORLD_FALLBACK": "Fallback Method",
"_comment_m6": "Option tooltips",
"vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulses the screen red, when at low health, to indicate your current health status",
"vivecraft.options.SHADER_GUI_RENDER.tooltip": "Determines how the GUI is rendered with shaders.\n After Shader: renders the GUI without using the shader, best compatibility. (issues with PTGI HRR)\n Translucent: renders the GUI with shader and transparency. (issues with Sildurs Vibrant)\n Opaque: renders the GUI with shader and opaque",
Expand All @@ -436,6 +439,7 @@
"vivecraft.options.CHAT_MESSAGE_STENCIL.tooltip": "Prints a message in chat, when another mod is detected, that also uses the stencil buffer.",
"vivecraft.options.VR_HOTSWITCH.tooltip": "Hotswitching switches to NONVR when the headset is taken off.\nIf this setting is off, the game will always be in VR mode, when VR is enabled",
"vivecraft.options.INGAME_BINDINGS_IN_GUI.tooltip": "Allows for all In-Game bindings to be used in menus, this can cause unwanted double presses.",
"vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "If Menuworlds are disabled or not loaded yet, this fallback will be shown instead.",
"_comment_m10": "Messages",
"vivecraft.messages.mode": "Mode:",
"vivecraft.messages.novrhotswitchinglegacy": "Legacy Vivecraft server mod detected. This Server does not support VR hot switching, you can only change it in the main menu.",
Expand Down

0 comments on commit d2f6698

Please sign in to comment.