Skip to content

Commit d2f6698

Browse files
committed
add panorama view as menu option, and make it the default fallback
1 parent fabbc1f commit d2f6698

File tree

6 files changed

+176
-3
lines changed

6 files changed

+176
-3
lines changed

common/src/main/java/org/vivecraft/client/gui/settings/GuiMenuWorldSettings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public class GuiMenuWorldSettings extends GuiVROptionsBase {
3131
}
3232

3333
return true;
34-
})
34+
}),
35+
new VROptionEntry(VRSettings.VrOptions.MENU_WORLD_FALLBACK),
3536
};
3637

3738
public GuiMenuWorldSettings(Screen guiScreen) {

common/src/main/java/org/vivecraft/client_vr/render/helpers/VREffectsHelper.java

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,163 @@ public static void disableStencilTest() {
174174
}
175175
}
176176

177+
private static final ResourceLocation cubeFront = new ResourceLocation("textures/gui/title/background/panorama_0.png");
178+
private static final ResourceLocation cubeRight = new ResourceLocation("textures/gui/title/background/panorama_1.png");
179+
private static final ResourceLocation cubeBack = new ResourceLocation("textures/gui/title/background/panorama_2.png");
180+
private static final ResourceLocation cubeLeft = new ResourceLocation("textures/gui/title/background/panorama_3.png");
181+
private static final ResourceLocation cubeUp = new ResourceLocation("textures/gui/title/background/panorama_4.png");
182+
private static final ResourceLocation cubeDown = new ResourceLocation("textures/gui/title/background/panorama_5.png");
183+
private static final ResourceLocation dirt = new ResourceLocation("minecraft:textures/block/dirt.png");
184+
private static final ResourceLocation grass = new ResourceLocation("minecraft:textures/block/grass_block_top.png");
185+
186+
public static void renderMenuPanorama(PoseStack poseStack) {
187+
BufferBuilder bufferbuilder = Tesselator.getInstance().getBuilder();
188+
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
189+
RenderSystem.clear(GL11C.GL_COLOR_BUFFER_BIT | GL11C.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
190+
RenderSystem.depthMask(true);
191+
RenderSystem.enableBlend();
192+
RenderSystem.defaultBlendFunc();
193+
RenderSystem.setShaderColor(1, 1, 1, 1);
194+
poseStack.pushPose();
195+
196+
poseStack.translate(-50F, -50F, -50.0F);
197+
198+
Matrix4f matrix = poseStack.last().pose();
199+
200+
// down
201+
RenderSystem.setShaderTexture(0, cubeDown);
202+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
203+
bufferbuilder.vertex(matrix, 0, 0, 0)
204+
.uv(0, 0).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
205+
bufferbuilder.vertex(matrix, 0, 0, 100)
206+
.uv(0, 1).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
207+
bufferbuilder.vertex(matrix, 100, 0, 100)
208+
.uv(1, 1).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
209+
bufferbuilder.vertex(matrix, 100, 0, 0)
210+
.uv(1, 0).color(255, 255, 255, 255).normal(0, 1, 0).endVertex();
211+
BufferUploader.drawWithShader(bufferbuilder.end());
212+
213+
// up
214+
RenderSystem.setShaderTexture(0, cubeUp);
215+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
216+
bufferbuilder.vertex(matrix, 0, 100, 100)
217+
.uv(0, 0).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
218+
bufferbuilder.vertex(matrix, 0, 100, 0)
219+
.uv(0, 1).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
220+
bufferbuilder.vertex(matrix, 100, 100, 0)
221+
.uv(1, 1).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
222+
bufferbuilder.vertex(matrix, 100, 100, 100)
223+
.uv(1, 0).color(255, 255, 255, 255).normal(0, -1, 0).endVertex();
224+
BufferUploader.drawWithShader(bufferbuilder.end());
225+
226+
// left
227+
RenderSystem.setShaderTexture(0, cubeLeft);
228+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
229+
bufferbuilder.vertex(matrix, 0, 0, 0)
230+
.uv(1, 1).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
231+
bufferbuilder.vertex(matrix, 0, 100, 0)
232+
.uv(1, 0).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
233+
bufferbuilder.vertex(matrix, 0, 100, 100)
234+
.uv(0, 0).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
235+
bufferbuilder.vertex(matrix, 0, 0, 100)
236+
.uv(0, 1).color(255, 255, 255, 255).normal(1, 0, 0).endVertex();
237+
BufferUploader.drawWithShader(bufferbuilder.end());
238+
239+
// right
240+
RenderSystem.setShaderTexture(0, cubeRight);
241+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
242+
bufferbuilder.vertex(matrix, 100, 0, 0)
243+
.uv(0, 1).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
244+
bufferbuilder.vertex(matrix, 100, 0, 100)
245+
.uv(1, 1).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
246+
bufferbuilder.vertex(matrix, 100, 100, 100)
247+
.uv(1, 0).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
248+
bufferbuilder.vertex(matrix, 100, 100, 0)
249+
.uv(0, 0).color(255, 255, 255, 255).normal(-1, 0, 0).endVertex();
250+
BufferUploader.drawWithShader(bufferbuilder.end());
251+
252+
// front
253+
RenderSystem.setShaderTexture(0, cubeFront);
254+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
255+
bufferbuilder.vertex(matrix, 0, 0, 0)
256+
.uv(0, 1).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
257+
bufferbuilder.vertex(matrix, 100, 0, 0)
258+
.uv(1, 1).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
259+
bufferbuilder.vertex(matrix, 100, 100, 0)
260+
.uv(1, 0).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
261+
bufferbuilder.vertex(matrix, 0, 100, 0)
262+
.uv(0, 0).color(255, 255, 255, 255).normal(0, 0, 1).endVertex();
263+
BufferUploader.drawWithShader(bufferbuilder.end());
264+
265+
//back
266+
RenderSystem.setShaderTexture(0, cubeBack);
267+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
268+
bufferbuilder.vertex(matrix, 0, 0, 100).
269+
uv(1, 1).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
270+
bufferbuilder.vertex(matrix, 0, 100, 100)
271+
.uv(1, 0).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
272+
bufferbuilder.vertex(matrix, 100, 100, 100)
273+
.uv(0, 0).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
274+
bufferbuilder.vertex(matrix, 100, 0, 100)
275+
.uv(0, 1).color(255, 255, 255, 255).normal(0, 0, -1).endVertex();
276+
BufferUploader.drawWithShader(bufferbuilder.end());
277+
278+
poseStack.popPose();
279+
280+
Vector2f area = dataHolder.vr.getPlayAreaSize();
281+
if (area == null) {
282+
area = new Vector2f(2, 2);
283+
}
284+
for (int i = 0; i < 2; i++) {
285+
float width = area.x + i * 2;
286+
float length = area.y + i * 2;
287+
288+
poseStack.pushPose();
289+
RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
290+
291+
int r, g, b;
292+
if (i == 0) {
293+
RenderSystem.setShaderTexture(0, grass);
294+
// plains grass color, but a bit darker
295+
r = 114;
296+
g = 148;
297+
b = 70;
298+
} else {
299+
RenderSystem.setShaderTexture(0, dirt);
300+
r = g = b = 128;
301+
}
302+
Matrix4f matrix4f = poseStack.last().pose();
303+
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
304+
poseStack.translate(-width / 2.0F, 0.0F, -length / 2.0F);
305+
306+
final int repeat = 4; // texture wraps per meter
307+
308+
bufferbuilder
309+
.vertex(matrix4f, 0, 0.005f * -i, 0)
310+
.uv(0, 0)
311+
.color(r, g, b, 255)
312+
.normal(0, 1, 0).endVertex();
313+
bufferbuilder
314+
.vertex(matrix4f, 0, 0.005f * -i, length)
315+
.uv(0, repeat * length)
316+
.color(r, g, b, 255)
317+
.normal(0, 1, 0).endVertex();
318+
bufferbuilder
319+
.vertex(matrix4f, width, 0.005f * -i, length)
320+
.uv(repeat * width, repeat * length)
321+
.color(r, g, b, 255)
322+
.normal(0, 1, 0).endVertex();
323+
bufferbuilder
324+
.vertex(matrix4f, width, 0.005f * -i, 0)
325+
.uv(repeat * width, 0)
326+
.color(r, g, b, 255)
327+
.normal(0, 1, 0).endVertex();
328+
329+
BufferUploader.drawWithShader(bufferbuilder.end());
330+
poseStack.popPose();
331+
}
332+
}
333+
177334
public static void renderJrbuddasAwesomeMainMenuRoomNew(PoseStack pMatrixStack) {
178335
int repeat = 4; // texture wraps per meter
179336
float height = 2.5F;
@@ -704,7 +861,11 @@ public static void renderGuiLayer(float partialTicks, boolean depthAlways, PoseS
704861
dataHolder.menuWorldRenderer.destroy();
705862
}
706863
} else {
707-
renderJrbuddasAwesomeMainMenuRoomNew(poseStack);
864+
if (dataHolder.vrSettings.menuWorldFallbackPanorama) {
865+
renderMenuPanorama(poseStack);
866+
} else {
867+
renderJrbuddasAwesomeMainMenuRoomNew(poseStack);
868+
}
708869
}
709870
poseStack.popPose();
710871
}

common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ public enum UpdateType implements OptionEnum<UpdateType> {
314314
public boolean shouldRenderSelf = false;
315315
@SettingField(VrOptions.MENU_WORLD_SELECTION)
316316
public MenuWorld menuWorldSelection = MenuWorld.BOTH;
317+
@SettingField(VrOptions.MENU_WORLD_FALLBACK)
318+
public boolean menuWorldFallbackPanorama = true;
317319
//
318320

319321
//Mixed Reality
@@ -1690,6 +1692,7 @@ Object convertOption(String value) {
16901692
}
16911693
}
16921694
},
1695+
MENU_WORLD_FALLBACK(false, true, "vivecraft.options.menuworldfallback.panorama", "vivecraft.options.menuworldfallback.dirtbox"), // fallback for when menurwold is not shown
16931696
HRTF_SELECTION(false, false) { // HRTF
16941697

16951698
// this is now handled by vanilla

common/src/main/java/org/vivecraft/mixin/client/gui/screens/TitleScreenMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ protected TitleScreenMixin(Component component) {
8181

8282
@ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/PanoramaRenderer;render(FF)V"), method = "render", index = 1)
8383
public float vivecraft$maybeNoPanorama(float alpha) {
84-
return VRState.vrRunning && ClientDataHolderVR.getInstance().menuWorldRenderer.isReady() ? 0.0F : alpha;
84+
return VRState.vrRunning && (ClientDataHolderVR.getInstance().menuWorldRenderer.isReady() || ClientDataHolderVR.getInstance().vrSettings.menuWorldFallbackPanorama) ? 0.0F : alpha;
8585
}
8686
}

common/src/main/resources/assets/vivecraft/lang/de_de.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@
401401
"vivecraft.options.disabled": "Deaktiviert",
402402
"vivecraft.options.editlist": "Liste bearbeiten",
403403
"vivecraft.options.addnew": "Neuen hinzufügen",
404+
"vivecraft.options.menuworldfallback.dirtbox": "Erdbox",
405+
"vivecraft.options.menuworldfallback.panorama": "Panorama",
404406
"_comment_m5": "Option names",
405407
"vivecraft.options.LOW_HEALTH_INDICATOR": "Gesundheit Indikator",
406408
"vivecraft.options.SHADER_GUI_RENDER": "Shader GUI",
@@ -418,6 +420,7 @@
418420
"vivecraft.options.VR_SETTINGS_BUTTON_VISIBLE": "VR Einstellungsknopf Sichtbar",
419421
"vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Einstellungsknopf Position",
420422
"vivecraft.options.INGAME_BINDINGS_IN_GUI": "Im-Spiel Tasten im GUI",
423+
"vivecraft.options.MENU_WORLD_FALLBACK": "Ersatz Methode",
421424
"_comment_m6": "Option tooltips",
422425
"vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulsiert den Bildschirm Rot bei niedriger Gesundheit, um den derzeitigen Gesundheitszustand anzuzeigen.",
423426
"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",
@@ -433,6 +436,7 @@
433436
"vivecraft.options.CHAT_MESSAGE_STENCIL.tooltip": "Schreibt eine Nachricht in den Chat, wenn ein anderer Mod erkannt wird, der ebenfalls die Schablone verwendet.",
434437
"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",
435438
"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.",
439+
"vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "Wenn Menü Welten deaktiviert sind oder noch nicht geladen sind, wird dieser Ersatz stattdessen verwendet",
436440
"_comment_m10": "Messages",
437441
"vivecraft.messages.mode": "Modus:",
438442
"vivecraft.messages.novrhotswitchinglegacy": "Veralteten Vivecraft server mod erkannt. Dieser Server unterstützt kein VR Schnellwechsel. Sie können den Modus nur im Hauptmenü wechseln.",

common/src/main/resources/assets/vivecraft/lang/en_us.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@
404404
"vivecraft.options.updatetype.alpha": "Alpha",
405405
"vivecraft.options.updatetype.beta": "Beta",
406406
"vivecraft.options.updatetype.release": "Release",
407+
"vivecraft.options.menuworldfallback.dirtbox": "Dirtbox",
408+
"vivecraft.options.menuworldfallback.panorama": "Panorama",
407409
"_comment_m5": "Option names",
408410
"vivecraft.options.LOW_HEALTH_INDICATOR": "Health Indicator",
409411
"vivecraft.options.SHADER_GUI_RENDER": "Shaders GUI",
@@ -421,6 +423,7 @@
421423
"vivecraft.options.VR_SETTINGS_BUTTON_VISIBLE": "VR Settings Button Visible",
422424
"vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Settings Button Position",
423425
"vivecraft.options.INGAME_BINDINGS_IN_GUI": "In-Game Bindings In GUI",
426+
"vivecraft.options.MENU_WORLD_FALLBACK": "Fallback Method",
424427
"_comment_m6": "Option tooltips",
425428
"vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulses the screen red, when at low health, to indicate your current health status",
426429
"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",
@@ -436,6 +439,7 @@
436439
"vivecraft.options.CHAT_MESSAGE_STENCIL.tooltip": "Prints a message in chat, when another mod is detected, that also uses the stencil buffer.",
437440
"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",
438441
"vivecraft.options.INGAME_BINDINGS_IN_GUI.tooltip": "Allows for all In-Game bindings to be used in menus, this can cause unwanted double presses.",
442+
"vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "If Menuworlds are disabled or not loaded yet, this fallback will be shown instead.",
439443
"_comment_m10": "Messages",
440444
"vivecraft.messages.mode": "Mode:",
441445
"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.",

0 commit comments

Comments
 (0)