From ba4b4bdf4475f601fb04972890d4fbccc4505141 Mon Sep 17 00:00:00 2001 From: jrbudda Date: Fri, 17 Feb 2017 10:10:39 -0500 Subject: [PATCH] 7r1 --- minecriftversion.py | 2 +- .../net/minecraft/client/Minecraft.java.patch | 401 +++++++++--------- .../client/renderer/EntityRenderer.java.patch | 134 +++--- .../client/settings/GameSettings.java.patch | 30 +- .../src/GuiPerformanceSettingsOF.java.patch | 12 + .../mtbs3d/minecrift/main/VivecraftMain.java | 1 - .../mtbs3d/minecrift/provider/MCOpenVR.java | 55 ++- .../minecrift/provider/OpenVRPlayer.java | 28 +- .../mtbs3d/minecrift/settings/VRHotkeys.java | 83 ++-- .../mtbs3d/minecrift/settings/VRSettings.java | 4 +- src/com/mtbs3d/minecrift/utils/Utils.java | 16 + 11 files changed, 434 insertions(+), 332 deletions(-) create mode 100644 patches/net/minecraft/src/GuiPerformanceSettingsOF.java.patch diff --git a/minecriftversion.py b/minecriftversion.py index 76124659..11a98145 100644 --- a/minecriftversion.py +++ b/minecriftversion.py @@ -4,7 +4,7 @@ of_json_name = "1.7.10_HD_U_D1" of_file_md5 = "57c724fe8335c82aef8d54c101043e60" minecrift_version_num = "1.7.10" -minecrift_build = "jrbudda-37" +minecrift_build = "jrbudda-37r1" of_file_extension = ".jar" mcp_version = "mcp908" mcp_uses_generics = False diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index f566a955..370632f7 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -155,7 +155,7 @@ import net.minecraft.world.EnumDifficulty; import net.minecraft.world.WorldProviderEnd; import net.minecraft.world.WorldProviderHell; -@@ -150,2988 +226,4947 @@ +@@ -150,2988 +226,4966 @@ import net.minecraft.world.storage.ISaveFormat; import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.WorldInfo; @@ -1246,7 +1246,7 @@ + * The minecriftVerString will be automatically updated by the build scripts, do not modify here. + * Modify minecriftversion.py in root minecrift dir. + */ -+ public final String minecriftVerString = "Vivecraft 1.7.10 jrbudda-37"; ++ public final String minecriftVerString = "Vivecraft 1.7.10 jrbudda-37r1"; + private boolean trigger; + /* end version */ + /** END MINECRIFT */ @@ -2232,10 +2232,12 @@ + } + } + -+ + var6 = System.nanoTime() - var5; + + RenderBlocks.fancyGrass = this.gameSettings.fancyGraphics; ++ this.mcProfiler.startSection("sound"); ++ // this.mcSoundHandler.setListener(this.thePlayer, this.timer.renderPartialTicks); ++ this.mcProfiler.endSection(); + + this.mcProfiler.startSection("Gui"); + // Render GUI to FBO if necessary @@ -2250,6 +2252,7 @@ + + checkGLError("post 2d "); + this.mcProfiler.endSection(); ++ + //if (!this.stereoProvider.isGuiOrtho()) { // Useless here + // if (fmlCommonHandler != null) { + // Reflector.callVoid(fmlCommonHandler, Reflector.FMLCommonHandler_onRenderTickEnd, new Object[]{this.timer.renderPartialTicks}); @@ -2261,11 +2264,8 @@ + MCOpenVR.poll(frameIndex); + this.mcProfiler.endSection(); + -+ this.mcProfiler.startSection("sound"); -+ //this.mcSoundHandler.setListener(this.thePlayer, this.timer.renderPartialTicks); -+ updateSoundListener(); // we update the sound listener from the HMD info -+ this.mcProfiler.endSection(); -+ ++ updateSoundListener(); // we update the sound listener from the HMD info. ++ + this.mcProfiler.startSection("hmdSampling"); + + if (hmdPosSamples.size() == hmdAvgLength) @@ -2359,7 +2359,165 @@ + this.framebufferMc.bindFramebuffer(true); //draw to main texture for every pass + this.mcProfiler.endSection(); + -+ shouldupdate = renderSingleView(i,nano); ++ {//renderSingleView ++ int eye = i; ++ if (this.entityRenderer != null) ++ { ++ this.entityRenderer.theShaderGroup = shaderGroup; ++ } ++ ++ GL11.glClearColor(0f, 0, 0, 1f); ++ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); ++ GL11.glEnable(GL11.GL_TEXTURE_2D); ++ ++ ++ Object fmlCommonHandler = null; ++ if (Reflector.FMLCommonHandler_instance.exists()) { ++ fmlCommonHandler = Reflector.call(Reflector.FMLCommonHandler_instance, new Object[0]); ++ } ++ ++ this.mcProfiler.startSection("updateCameraAndRender"); ++ ++ if (!this.skipRenderWorld) ++ { ++ /** MINECRIFT FORGE **/ ++ if (!this.stereoProvider.isStereo()) { ++ if (fmlCommonHandler != null) { ++ Reflector.callVoid(fmlCommonHandler, Reflector.FMLCommonHandler_onRenderTickStart, new Object[]{nano}); ++ } ++ } ++ ///THIS IS WHERE EVERYTHING IS RENDERED ++ this.entityRenderer.updateCameraAndRender(nano); ++ ++ checkGLError("postucr " + eye); ++ ++ ++ if (!this.stereoProvider.isStereo()) { ++ if (fmlCommonHandler != null) { ++ Reflector.callVoid(fmlCommonHandler, Reflector.FMLCommonHandler_onRenderTickEnd, new Object[]{this.timer.renderPartialTicks}); ++ } ++ } ++ /** END MINECRIFT FORGE **/ ++ } ++ this.mcProfiler.endSection(); ++ ++ if(currentPass != renderPass.Third && currentPass != renderPass.Center) { ++ //copies the rendered scene to eye tex with fsaa and other postprocessing effects. ++ this.mcProfiler.startSection("postprocesseye"); ++ ++ Framebuffer source = this.framebuffer; ++ ++ if (this.vrSettings.useFsaa) ++ { ++ this.mcProfiler.startSection("fsaa"); ++ doFSAA(); ++ source = fsaaLastPassResultFBO; ++ checkGLError("fsaa " + eye); ++ this.mcProfiler.endSection(); ++ } ++ ++ if(currentPass == renderPass.Left) ++ framebufferEye0.bindFramebuffer(true); //draw to L eye tex ++ else ++ framebufferEye1.bindFramebuffer(true); //draw to R eye tex ++ ++ if(vrSettings.useFOVReduction && vrSettings.vrFreeMove){ ++ if( thePlayer !=null && (Math.abs(thePlayer.moveForward) > 0 || Math.abs(thePlayer.moveStrafing) > 0)) { ++ fov -=0.05; ++ if(fov < 0.22) fov = 0.22f; ++ } else { ++ fov +=0.01; ++ if(fov > 0.8) fov = 0.8f; ++ } ++ } else { ++ fov = 1f; ++ } ++ ++ ARBShaderObjects.glUseProgramObjectARB(VRShaders._FOVReduction_shaderProgramId); ++ ARBShaderObjects.glUniform1iARB(VRShaders._FOVReduction_TextureUniform, 0); ++ ++ if(pumpkineffect > 0){ ++ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_RadiusUniform, 0.25f); ++ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_BorderUniform, 0.0f); ++ } else{ ++ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_RadiusUniform, fov); ++ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_BorderUniform, 0.06f); ++ } ++ ++ // VIVE start - screen flash when hurt instead of view tilt ++ float r = 0, k = 0; ++ // VIVE start - screen flash when hurt instead of view tilt ++ float time = (float) (System.currentTimeMillis() - usageSnooper.getMinecraftStartTimeMillis()) / 1000; ++ if (thePlayer!=null) { ++ ++ if(entityRenderer.itemRenderer.inwater){ ++ watereffect = 1.3f; ++ } else { ++ if(watereffect == 1.3f) watereffect = 2.3f; ++ watereffect -= (1f/60f); ++ if(watereffect < 0) watereffect = 0; ++ } ++ ++ if(Reflector.shadersModExists()) watereffect = 0; //dont stack. ++ ++ if(entityRenderer.itemRenderer.inportal){ ++ portaleffect = 1f; ++ } else { ++ portaleffect -= (1f/60f); ++ if(portaleffect < 0) portaleffect = 0; ++ } ++ ++ float var3 = (float)thePlayer.hurtTime - nano; ++ ++ float percent = 1 - thePlayer.getHealth() / thePlayer.getMaxHealth(); ++ percent = (percent-0.5f) * 0.75f; ++ ++ if (var3>0.0f) ++ { ++ var3 /= (float) thePlayer.maxHurtTime; ++ var3 = percent + MathHelper.sin(var3 * var3 * var3 * var3 * (float) Math.PI) * 0.5f; ++ r = var3; ++ } else { ++ r = (float) (percent * Math.abs(Math.sin(2.5f*time/(1-percent+.1) ))); ++ if (thePlayer.capabilities.isCreativeMode) r = 0; ++ } ++ ++ if(entityRenderer.itemRenderer.inblock && thePlayer.isDead == false){ ++ k = (float) entityRenderer.itemRenderer.inBlock; ++ } ++ ++ if (thePlayer.isPlayerSleeping()){ ++ if(k<0.8)k=.8f; ++ } ++ ++ if (MCOpenVR.isWalkingAbout){ ++ if(k<0.8)k=.8f; ++ } ++ } ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_HealthAlpha, r); ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_BlackAlpha, k); ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_time,time); ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_waterAmplitude, watereffect); ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_portalAmplitutde, portaleffect); ++ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_pumpkinAmplitutde, pumpkineffect); ++ ARBShaderObjects.glUniform1iARB(VRShaders._Overlay_eye, currentPass == currentPass.Left ? 1 : -1); ++ ++ source.framebufferRender(framebufferEye0.framebufferWidth, framebufferEye0.framebufferHeight); ++ ++ ARBShaderObjects.glUseProgramObjectARB(0); ++ ++ checkGLError("post-draw " + eye); ++ ++ this.mcProfiler.endSection(); ++ ++ } ++ ++ this.mcProfiler.startSection("mirror"); ++ shouldupdate =copyToMirror(this.currentPass); ++ checkGLError("post-mirror " + eye); ++ this.mcProfiler.endSection(); ++ ++ } + + this.mcProfiler.endSection(); //eye + } //end per eye rendering. @@ -2446,168 +2604,6 @@ + mcProfiler.startSection("Idle"); + } + -+ private boolean renderSingleView(int eye, float nano) { -+ boolean shouldupdate = false; -+ -+ if (this.entityRenderer != null) -+ { -+ this.entityRenderer.theShaderGroup = shaderGroup; -+ } -+ -+ GL11.glClearColor(0f, 0, 0, 1f); -+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); -+ GL11.glEnable(GL11.GL_TEXTURE_2D); -+ -+ -+ Object fmlCommonHandler = null; -+ if (Reflector.FMLCommonHandler_instance.exists()) { -+ fmlCommonHandler = Reflector.call(Reflector.FMLCommonHandler_instance, new Object[0]); -+ } -+ -+ this.mcProfiler.startSection("updateCameraAndRender"); -+ -+ if (!this.skipRenderWorld) -+ { -+ /** MINECRIFT FORGE **/ -+ if (!this.stereoProvider.isStereo()) { -+ if (fmlCommonHandler != null) { -+ Reflector.callVoid(fmlCommonHandler, Reflector.FMLCommonHandler_onRenderTickStart, new Object[]{nano}); -+ } -+ } -+ ///THIS IS WHERE EVERYTHING IS RENDERED -+ this.entityRenderer.updateCameraAndRender(nano); -+ -+ checkGLError("postucr " + eye); -+ -+ -+ if (!this.stereoProvider.isStereo()) { -+ if (fmlCommonHandler != null) { -+ Reflector.callVoid(fmlCommonHandler, Reflector.FMLCommonHandler_onRenderTickEnd, new Object[]{this.timer.renderPartialTicks}); -+ } -+ } -+ /** END MINECRIFT FORGE **/ -+ } -+ this.mcProfiler.endSection(); -+ -+ if(currentPass != renderPass.Third && currentPass != renderPass.Center) { -+ //copies the rendered scene to eye tex with fsaa and other postprocessing effects. -+ this.mcProfiler.startSection("postprocesseye"); -+ -+ Framebuffer source = this.framebuffer; -+ -+ if (this.vrSettings.useFsaa) -+ { -+ this.mcProfiler.startSection("fsaa"); -+ doFSAA(); -+ source = fsaaLastPassResultFBO; -+ checkGLError("fsaa " + eye); -+ this.mcProfiler.endSection(); -+ } -+ -+ if(currentPass == renderPass.Left) -+ framebufferEye0.bindFramebuffer(true); //draw to L eye tex -+ else -+ framebufferEye1.bindFramebuffer(true); //draw to R eye tex -+ -+ if(vrSettings.useFOVReduction && vrSettings.vrFreeMove){ -+ if( thePlayer !=null && (Math.abs(thePlayer.moveForward) > 0 || Math.abs(thePlayer.moveStrafing) > 0)) { -+ fov -=0.05; -+ if(fov < 0.22) fov = 0.22f; -+ } else { -+ fov +=0.01; -+ if(fov > 0.8) fov = 0.8f; -+ } -+ } else { -+ fov = 1f; -+ } -+ -+ ARBShaderObjects.glUseProgramObjectARB(VRShaders._FOVReduction_shaderProgramId); -+ ARBShaderObjects.glUniform1iARB(VRShaders._FOVReduction_TextureUniform, 0); -+ -+ if(pumpkineffect > 0){ -+ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_RadiusUniform, 0.25f); -+ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_BorderUniform, 0.0f); -+ } else{ -+ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_RadiusUniform, fov); -+ ARBShaderObjects.glUniform1fARB(VRShaders._FOVReduction_BorderUniform, 0.06f); -+ } -+ -+ // VIVE start - screen flash when hurt instead of view tilt -+ float r = 0, k = 0; -+ // VIVE start - screen flash when hurt instead of view tilt -+ float time = (float) (System.currentTimeMillis() - usageSnooper.getMinecraftStartTimeMillis()) / 1000; -+ if (thePlayer!=null) { -+ -+ if(entityRenderer.itemRenderer.inwater){ -+ watereffect = 1.3f; -+ } else { -+ if(watereffect == 1.3f) watereffect = 2.3f; -+ watereffect -= (1f/60f); -+ if(watereffect < 0) watereffect = 0; -+ } -+ -+ if(Reflector.shadersModExists()) watereffect = 0; //dont stack. -+ -+ if(entityRenderer.itemRenderer.inportal){ -+ portaleffect = 1f; -+ } else { -+ portaleffect -= (1f/60f); -+ if(portaleffect < 0) portaleffect = 0; -+ } -+ -+ float var3 = (float)thePlayer.hurtTime - nano; -+ -+ float percent = 1 - thePlayer.getHealth() / thePlayer.getMaxHealth(); -+ percent = (percent-0.5f) * 0.75f; -+ -+ if (var3>0.0f) -+ { -+ var3 /= (float) thePlayer.maxHurtTime; -+ var3 = percent + MathHelper.sin(var3 * var3 * var3 * var3 * (float) Math.PI) * 0.5f; -+ r = var3; -+ } else { -+ r = (float) (percent * Math.abs(Math.sin(2.5f*time/(1-percent+.1) ))); -+ if (thePlayer.capabilities.isCreativeMode) r = 0; -+ } -+ -+ if(entityRenderer.itemRenderer.inblock && thePlayer.isDead == false){ -+ k = (float) entityRenderer.itemRenderer.inBlock; -+ } -+ -+ if (thePlayer.isPlayerSleeping()){ -+ if(k<0.8)k=.8f; -+ } -+ -+ if (MCOpenVR.isWalkingAbout){ -+ if(k<0.8)k=.8f; -+ } -+ } -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_HealthAlpha, r); -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_BlackAlpha, k); -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_time,time); -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_waterAmplitude, watereffect); -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_portalAmplitutde, portaleffect); -+ ARBShaderObjects.glUniform1fARB(VRShaders._Overlay_pumpkinAmplitutde, pumpkineffect); -+ ARBShaderObjects.glUniform1iARB(VRShaders._Overlay_eye, currentPass == currentPass.Left ? 1 : -1); -+ -+ source.framebufferRender(framebufferEye0.framebufferWidth, framebufferEye0.framebufferHeight); -+ -+ ARBShaderObjects.glUseProgramObjectARB(0); -+ -+ checkGLError("post-draw " + eye); -+ -+ this.mcProfiler.endSection(); -+ -+ } -+ -+ this.mcProfiler.startSection("mirror"); -+ shouldupdate =copyToMirror(this.currentPass); -+ checkGLError("post-mirror " + eye); -+ this.mcProfiler.endSection(); -+ -+ return shouldupdate; -+ } -+ + private float fov; + + /** @@ -4973,6 +4969,8 @@ + /** MINECRIFT ADDITIONS BELOW */ + + float mixedRealityPlayerDepth; ++ public org.lwjgl.util.vector.Matrix4f thirdPassInverseViewMatrix = new org.lwjgl.util.vector.Matrix4f(); ++ public org.lwjgl.util.vector.Matrix4f thirdPassViewMatrix = new org.lwjgl.util.vector.Matrix4f(); + + private boolean copyToMirror(renderPass currentPass2) + { @@ -4990,19 +4988,45 @@ + boolean hasShaders = Reflector.shadersModExists(); + + this.framebufferMc.unbindFramebuffer(); //draw directly to window ++ ++ // create view matrix ++ //temp ++ vrSettings.mrMovingCamOffsetPitch = 0; ++ vrSettings.mrMovingCamOffsetYaw = 0; ++ vrSettings.mrMovingCamOffsetRoll = 0; ++ vrSettings.mrMovingCamOffsetX = 0; ++ vrSettings.mrMovingCamOffsetY = 0f; ++ vrSettings.mrMovingCamOffsetZ = 0f; ++ // ++ Vec3 cam = entityRenderer.getEyeRenderPos(renderPass.Third); ++ GL11.glMatrixMode(GL11.GL_MODELVIEW); ++ GL11.glPushMatrix(); ++ GL11.glLoadIdentity(); ++ GL11.glTranslated(cam.xCoord, cam.yCoord, cam.zCoord); ++ entityRenderer.test(false); ++ GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matrixBuffer); ++ matrixBuffer.rewind(); ++ this.thirdPassViewMatrix.load(matrixBuffer); ++ matrixBuffer.rewind(); ++ GL11.glPopMatrix(); + -+ float yaw = (float)(vrSettings.vrFixedCamrotYaw - vrSettings.vrWorldRotation); -+ float pitch = (float)(vrSettings.vrFixedCamrotPitch); -+ -+ float f = MathHelper.cos(-yaw * 0.017453292F - (float)Math.PI); -+ float f1 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI); -+ float f2 = -MathHelper.cos(-pitch * 0.017453292F); -+ float f3 = MathHelper.sin(-pitch * 0.017453292F); -+ -+ Vector3f CameraLook = new Vector3f(-(f1 * f2), f3, -f * f2); + -+ Vec3 camplayer = entityRenderer.getEyeRenderPos(renderPass.Center).subtract(entityRenderer.getEyeRenderPos(renderPass.Third)); ++ Vec3 camplayer = new Vec3(thirdPassViewMatrix.m30, thirdPassViewMatrix.m31, thirdPassViewMatrix.m32).subtractProperly(entityRenderer.getEyeRenderPos(renderPass.Center)); ++ camplayer = camplayer.rotateYaw((float) Math.PI); ++ // org.lwjgl.util.vector.Vector3f CameraLookx = new org.lwjgl.util.vector.Vector3f(0,0,-1); ++ // org.lwjgl.util.vector.Vector3f CameraLooky = Utils.directionFromMatrix(thirdPassViewMatrix, 0, 0, -1); ++ float yaw = (float) Math.toRadians(180+vrSettings.vrFixedCamrotYaw + vrSettings.vrWorldRotation); ++ // float yawx = (float) Math.atan2((-thirdPassViewMatrix.m20),(Math.sqrt(Math.pow(thirdPassViewMatrix.m21, 2) + Math.pow(thirdPassViewMatrix.m22, 2)))); ++ org.lwjgl.util.vector.Vector3f CameraLook = new org.lwjgl.util.vector.Vector3f((float) Math.sin(yaw), 0f, (float)Math.cos(yaw)); ++ ++ org.lwjgl.util.vector.Matrix4f viewMatrix = new org.lwjgl.util.vector.Matrix4f(thirdPassViewMatrix); ++ viewMatrix.m33 =1; ++ viewMatrix.m30 =0; ++ viewMatrix.m31 =0; ++ viewMatrix.m32 =0; + ++ // Vec3d camplayerx = entityRenderer.getMRCamLocation().subtract(entityRenderer.getEyeRenderPos(renderPass.Center)); ++ + boolean alphaMask = this.vrSettings.mixedRealityUnityLike && this.vrSettings.mixedRealityAlphaMask; + + GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0); @@ -5021,12 +5045,7 @@ + matrixBuffer.rewind(); + ARBShaderObjects.glUniformMatrix4ARB(VRShaders._DepthMask_projectionMatrix, false, matrixBuffer); + -+ // create view matrix -+ org.lwjgl.util.vector.Matrix4f viewMatrix = new org.lwjgl.util.vector.Matrix4f(); -+ viewMatrix.rotate((float)Math.toRadians(vrSettings.vrFixedCamrotRoll), new org.lwjgl.util.vector.Vector3f(0.0F, 0.0F, 1.0F)); -+ viewMatrix.rotate((float)Math.toRadians(vrSettings.vrFixedCamrotPitch), new org.lwjgl.util.vector.Vector3f(1.0F, 0.0F, 0.0F)); -+ viewMatrix.rotate((float)Math.toRadians(vrSettings.vrFixedCamrotYaw - vrSettings.vrWorldRotation), new org.lwjgl.util.vector.Vector3f(0.0F, 1.0F, 0.0F)); -+ ++ + // set view matrix + viewMatrix.store(matrixBuffer); + matrixBuffer.rewind(); @@ -5056,21 +5075,21 @@ + ARBShaderObjects.glUniform1iARB(VRShaders._DepthMask_colorTexUniform, 1); + ARBShaderObjects.glUniform1iARB(VRShaders._DepthMask_depthTexUniform, 2); + ARBShaderObjects.glUniform3fARB(VRShaders._DepthMask_hmdViewPosition, (float)camplayer.xCoord, (float)camplayer.yCoord, (float)camplayer.zCoord); -+ ARBShaderObjects.glUniform3fARB(VRShaders._DepthMask_hmdPlaneNormal, -CameraLook.x, 0, -CameraLook.z); ++ ARBShaderObjects.glUniform3fARB(VRShaders._DepthMask_hmdPlaneNormal, CameraLook.x, 0, -CameraLook.z); + ARBShaderObjects.glUniform1iARB(VRShaders._DepthMask_passUniform, i); + ARBShaderObjects.glUniform3fARB(VRShaders._DepthMask_keyColorUniform, vrSettings.mixedRealityKeyColor.getRed() / 255F, vrSettings.mixedRealityKeyColor.getGreen() / 255F, vrSettings.mixedRealityKeyColor.getBlue() / 255F); + ARBShaderObjects.glUniform1iARB(VRShaders._DepthMask_alphaModeUniform, alphaMask ? 1 : 0); + + // bind color and depth textures + GL13.glActiveTexture(GL13.GL_TEXTURE1); -+ framebuffer.bindFramebufferTexture(); ++ framebufferMR.bindFramebufferTexture(); + GL13.glActiveTexture(GL13.GL_TEXTURE2); + if (hasShaders) GL11.glBindTexture(GL11.GL_TEXTURE_2D, entityRenderer.smcDepthBuffer); // shaders mod has it's own depth buffer -+ else GL11.glBindTexture(GL11.GL_TEXTURE_2D, framebuffer.depthBuffer); ++ else GL11.glBindTexture(GL11.GL_TEXTURE_2D, framebufferMR.depthBuffer); + GL13.glActiveTexture(GL13.GL_TEXTURE0); + + // draw framebuffer -+ framebufferMc.framebufferRender(posW, resW, resH, posH); ++ framebufferMR.framebufferRender(posW, resW, resH, posH); + + OpenGlHelper.glUseProgram(0); + diff --git a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch index 429dd6cc..3c303f82 100644 --- a/patches/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -98,7 +98,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MouseFilter; import net.minecraft.util.MovingObjectPosition; -@@ -61,2593 +104,5076 @@ +@@ -61,2593 +104,5112 @@ import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; @@ -1429,10 +1429,8 @@ + } + else if(mc.currentPass == renderPass.Third){ + -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+ GL11.glRotatef(180+mc.vrSettings.vrFixedCamrotYaw - mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+ ++ applyMRCameraRotation(false); ++ + } else { + /** MINECRIFT */ + @@ -1460,6 +1458,59 @@ + /** END MINECRIFT */ + } + ++ ++ public void applyMRCameraRotation(boolean invert){ ++ ++ if(invert){ ++ ++ GL11.glRotatef(-180-mc.vrSettings.vrFixedCamrotYaw + mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); ++ ++ GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetRoll, 0.0F, 0.0F, 1.0F); ++ GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetYaw, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetPitch, 1.0F, 0.0F, 0.0F); ++ ++ }else{ ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotYaw + mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); ++ ++ GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetYaw, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetPitch, 1.0F, 0.0F, 0.0F); ++ GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetRoll, 0.0F, 0.0F, 1.0F); ++ } ++ ++ } ++ // VIVE END - render functions ++ ++ public void test(boolean invert){ ++ ++ if(invert){ ++// GL11.glRotatef(-180-mc.vrSettings.vrFixedCamrotYaw + mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++// GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); ++// GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); ++// ++// GL11.glTranslatef(mc.vrSettings.mrMovingCamOffsetX,mc.vrSettings.mrMovingCamOffsetY,mc.vrSettings.mrMovingCamOffsetZ); ++// ++// GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetRoll, 0.0F, 0.0F, 1.0F); ++// GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetYaw, 0.0F, 1.0F, 0.0F); ++// GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetPitch, 1.0F, 0.0F, 0.0F); ++ ++ }else{ ++ ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotYaw + mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); ++ ++ GL11.glTranslatef(mc.vrSettings.mrMovingCamOffsetX,mc.vrSettings.mrMovingCamOffsetY,mc.vrSettings.mrMovingCamOffsetZ); ++ ++ GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetYaw, 0.0F, 1.0F, 0.0F); ++ GL11.glRotatef(mc.vrSettings.mrMovingCamOffsetPitch, 1.0F, 0.0F, 0.0F); ++ GL11.glRotatef(-mc.vrSettings.mrMovingCamOffsetRoll, 0.0F, 0.0F, 1.0F); ++ } ++ } ++ + /** + * sets up projection, view effects, camera position/rotation + */ @@ -1642,19 +1693,20 @@ + (float) interpolatedPlayerPos.zCoord); + + Vec3 o = getEyeRenderPos(renderPass.Center ); -+ if (mc.currentPass == renderPass.Third) o =getEyeRenderPos(renderPass.Third); ++ if (mc.currentPass == renderPass.Third) ++ o =getEyeRenderPos(renderPass.Third); + + Vec3 pos = o.subtract(feets).addVector(0, 0.01, 0); -+ Vec3 pos2 = o.subtract(mc.roomScale.getHMDPos_World()); + setupPolyRendering(true); + //renderCircle(pos2, 0.1f * mc.vrSettings.vrWorldScale, 32, 255, 255, 0, 255, 1); ++ eyeCollision = true; + if(eyeCollision ){ + int was = GL11.glGetInteger(GL11.GL_DEPTH_FUNC); + GL11.glDepthFunc(GL11.GL_ALWAYS); -+ renderCircle(pos, 0.05f * mc.vrPlayer.worldScale, 32, 0, 255, 255, 32, 1); ++ renderCircle(pos, 0.05f * mc.vrPlayer.worldScale, 32, 0, 255, 255, 255, 1); + GL11.glDepthFunc(was); + } else { -+ renderCircle(pos, .05f * mc.vrPlayer.worldScale, 32, 0, 255, 255, 32, 1); ++ renderCircle(pos, .05f * mc.vrPlayer.worldScale, 32, 0, 255, 255, 255, 1); + } + + setupPolyRendering(false); @@ -1676,33 +1728,15 @@ + + setupCameraTransform(par1, 0); + -+ //TODO: Techjar fix plz. -+// if (MCOpenVR.mrMovingCamActive) { -+// Vec3d cam = new Vec3d(MCOpenVR.mrControllerPos.xCoord * mc.vrPlayer.interpolatedWorldScale, MCOpenVR.mrControllerPos.yCoord * mc.vrPlayer.interpolatedWorldScale, MCOpenVR.mrControllerPos.zCoord * mc.vrPlayer.interpolatedWorldScale); -+// cam = cam.rotateYaw(mc.vrPlayer.worldRotationRadians); -+// cam = interPolatedRoomOrigin.addVector(cam.xCoord, cam.yCoord, cam.zCoord); -+// Vec3d o = getEyeRenderPos(renderPass.Center); -+// Vec3d pos = cam.subtract(o).addVector(0, 0.02, 0); -+// -+// GL11.glTranslated(pos.xCoord, pos.yCoord, pos.zCoord); -+// GL11.glRotatef(-mc.vrSettings.vrFixedCamrotYaw, 0.0F, 1.0F, 0.0F); -+// GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+// GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+// GL11.glTranslatef(mc.vrSettings.mrMovingCamOffsetX * mc.vrPlayer.interpolatedWorldScale, mc.vrSettings.mrMovingCamOffsetY * mc.vrPlayer.interpolatedWorldScale, mc.vrSettings.mrMovingCamOffsetZ * mc.vrPlayer.interpolatedWorldScale); -+// } else { -+// Vec3d cam = getEyeRenderPos(renderPass.Third); -+// Vec3d o = getEyeRenderPos(renderPass.Center); -+// Vec3d pos = cam.subtract(o).addVector(0, 0.02, 0); -+// -+// GL11.glTranslated(pos.xCoord, pos.yCoord, pos.zCoord); -+// GL11.glRotatef(-mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+// GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+// GL11.glRotatef(-mc.vrSettings.vrFixedCamrotYaw + mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); -+// } -+ -+ setupPolyRendering(true); -+ renderDebugAxes(0, 0, 0, 0.08f * mc.vrPlayer.worldScale); //TODO: camera model? -+ setupPolyRendering(false); ++ Vec3 cam = getMRCamLocation(); ++ Vec3 o = getEyeRenderPos(renderPass.Center); ++ Vec3 pos = cam.subtractProperly(o).addVector(0, 0.02, 0); ++ ++ GL11.glTranslated(pos.xCoord, pos.yCoord, pos.zCoord); ++ ++ applyMRCameraRotation(true); ++ ++ renderDebugAxes(0, 0, 0, 0.08f * mc.vrPlayer.worldScale); //TODO: camera model? + + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glPopMatrix(); @@ -1718,7 +1752,11 @@ + + } + -+ ++ public Vec3 getMRCamLocation(){ ++ ++ return Vec3.createVectorHelper(mc.thirdPassViewMatrix.m30, mc.thirdPassViewMatrix.m31, mc.thirdPassViewMatrix.m32); ++ ++ } + + + @@ -2255,7 +2293,7 @@ + + Vec3 f; + if(mc.currentPass == renderPass.Third) -+ f = getEyeRenderPos(renderPass.Third); ++ f = getMRCamLocation(); + else + f = getEyeRenderPos(renderPass.Center); + @@ -2358,10 +2396,10 @@ + + if (shadersMod) { + //does not actually use the values you pass it. Sets viewport on either shadow or color FB internally -+ Reflector.callVoid(Reflector.ShadersMod_Shaders_setViewport, new Object[] {0, 0, this.mc.displayFBWidth, this.mc.displayFBHeight}); ++ Reflector.callVoid(Reflector.ShadersMod_Shaders_setViewport, new Object[] {0, 0, this.mc.getFramebuffer().framebufferWidth, this.mc.getFramebuffer().framebufferHeight}); + } + else { -+ GL11.glViewport(0, 0, this.mc.displayFBWidth, this.mc.displayFBHeight); ++ GL11.glViewport(0, 0, this.mc.getFramebuffer().framebufferWidth, this.mc.getFramebuffer().framebufferHeight); + } + + this.updateFogColor(par1); @@ -4531,9 +4569,7 @@ + if (currentPass != renderPass.Third) { + GL11.glMultMatrix(mc.roomScale.getHMDMatrix_World()); + } else { -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+ GL11.glRotatef(180+mc.vrSettings.vrFixedCamrotYaw - mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ applyMRCameraRotation(false); + } + + GL11.glTranslatef((float) (guipos.x - eye.xCoord), (float)(guipos.y - eye.yCoord), (float)(guipos.z - eye.zCoord)); @@ -4570,9 +4606,10 @@ + if (currentPass != renderPass.Third) { + GL11.glMultMatrix(mc.roomScale.getHMDMatrix_World()); + } else { -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+ GL11.glRotatef(180+mc.vrSettings.vrFixedCamrotYaw - mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ applyMRCameraRotation(false); ++// GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); ++// GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); ++// GL11.glRotatef(180+mc.vrSettings.vrFixedCamrotYaw - mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); + } + + GL11.glTranslatef((float)(interPolatedRoomOrigin.xCoord - eye.xCoord), (float)(interPolatedRoomOrigin.yCoord - eye.yCoord), (float)(interPolatedRoomOrigin.zCoord - eye.zCoord)); @@ -5180,9 +5217,7 @@ + if (mc.currentPass != renderPass.Third) { + GL11.glMultMatrix(mc.roomScale.getHMDMatrix_World()); + } else { -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotRoll, 0.0F, 0.0F, 1.0F); -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotPitch, 1.0F, 0.0F, 0.0F); -+ GL11.glRotatef(mc.vrSettings.vrFixedCamrotYaw - mc.vrSettings.vrWorldRotation, 0.0F, 1.0F, 0.0F); ++ applyMRCameraRotation(false); + } + + @@ -7750,4 +7785,5 @@ - } - } + // VIVE END - render functions ++ } diff --git a/patches/net/minecraft/client/settings/GameSettings.java.patch b/patches/net/minecraft/client/settings/GameSettings.java.patch index ac343334..75b7042e 100644 --- a/patches/net/minecraft/client/settings/GameSettings.java.patch +++ b/patches/net/minecraft/client/settings/GameSettings.java.patch @@ -53,7 +53,7 @@ public boolean ofSunMoon = true; public int ofVignette = 0; - public int ofChunkUpdates = 1; -+ public int ofChunkUpdates = 5; ++ public int ofChunkUpdates = 2; public int ofChunkLoading = 0; public boolean ofChunkUpdatesDynamic = false; public int ofTime = 0; @@ -188,15 +188,6 @@ this.updateVSync(); } -@@ -905,7 +858,7 @@ - { - ++this.ofChunkUpdates; - -- if (this.ofChunkUpdates > 5) -+ if (this.ofChunkUpdates > 15) - { - this.ofChunkUpdates = 1; - } @@ -1026,15 +979,9 @@ if (par1EnumOptions == GameSettings.Options.FAST_RENDER) @@ -378,16 +369,15 @@ String s = ""; while ((s = bufferedreader.readLine()) != null) -@@ -2670,7 +2647,7 @@ - if (exception1[0].equals("ofChunkUpdates") && exception1.length >= 2) +@@ -2671,6 +2648,7 @@ { this.ofChunkUpdates = Integer.valueOf(exception1[1]).intValue(); -- this.ofChunkUpdates = Config.limit(this.ofChunkUpdates, 1, 5); -+ this.ofChunkUpdates = Config.limit(this.ofChunkUpdates, 1, 15); + this.ofChunkUpdates = Config.limit(this.ofChunkUpdates, 1, 5); ++ if(ofChunkUpdates > 2) ofChunkUpdates = 2; //remove this line some day. } if (exception1[0].equals("ofChunkLoading") && exception1.length >= 2) -@@ -2802,11 +2779,20 @@ +@@ -2802,11 +2780,20 @@ } } @@ -409,7 +399,7 @@ exception.println("ofRenderDistanceChunks:" + this.renderDistanceChunks); exception.println("ofFogType:" + this.ofFogType); exception.println("ofFogStart:" + this.ofFogStart); -@@ -2882,8 +2868,15 @@ +@@ -2882,8 +2869,15 @@ } } @@ -425,7 +415,7 @@ this.renderDistanceChunks = 8; this.viewBobbing = true; this.anaglyph = false; -@@ -2932,7 +2925,7 @@ +@@ -2932,7 +2926,7 @@ this.ofStars = true; this.ofSunMoon = true; this.ofVignette = 0; @@ -434,7 +424,7 @@ this.ofChunkLoading = 0; this.ofChunkUpdatesDynamic = false; this.ofTime = 0; -@@ -2966,17 +2959,39 @@ +@@ -2966,17 +2960,39 @@ this.ofAnimatedTerrain = true; this.ofAnimatedItems = true; this.ofAnimatedTextures = true; @@ -481,7 +471,7 @@ private void updateWaterOpacity() { -@@ -3181,12 +3196,12 @@ +@@ -3181,12 +3197,12 @@ return null; } @@ -497,7 +487,7 @@ { this.enumString = p_i45004_3_; this.enumFloat = p_i45004_4_; -@@ -3252,9 +3267,9 @@ +@@ -3252,9 +3268,9 @@ return p_148264_1_; } diff --git a/patches/net/minecraft/src/GuiPerformanceSettingsOF.java.patch b/patches/net/minecraft/src/GuiPerformanceSettingsOF.java.patch new file mode 100644 index 00000000..42ca38f0 --- /dev/null +++ b/patches/net/minecraft/src/GuiPerformanceSettingsOF.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/src/GuiPerformanceSettingsOF.java ++++ b/net/minecraft/src/GuiPerformanceSettingsOF.java +@@ -48,6 +48,9 @@ + { + this.buttonList.add(new GuiOptionSlider(enumoptions.returnEnumOrdinal(), x, y, enumoptions)); + } ++ if (enumoptions == GameSettings.Options.SMOOTH_FPS) { ++ ((GuiButton)this.buttonList.get(i)).enabled = false; ++ } + + ++i; + } diff --git a/src/com/mtbs3d/minecrift/main/VivecraftMain.java b/src/com/mtbs3d/minecrift/main/VivecraftMain.java index 9ea31fe4..9b09b537 100644 --- a/src/com/mtbs3d/minecrift/main/VivecraftMain.java +++ b/src/com/mtbs3d/minecrift/main/VivecraftMain.java @@ -31,7 +31,6 @@ public class VivecraftMain public static void main(String[] p_main_0_) { - LaunchClassLoader load = (LaunchClassLoader) Thread.currentThread().getContextClassLoader(); try { diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index 1407d809..ee31d4fe 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -242,7 +242,7 @@ public MCOpenVR() { super(); - for (int c=0;c<2;c++) + for (int c=0;c<3;c++) { aimSource[c] = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); for (int sample = 0; sample < 5; sample++) @@ -334,7 +334,7 @@ else if( osname.contains("mac")){ initializeJOpenVR(); initOpenVRCompositor(true) ; initOpenVROverlay() ; - initOpenVROSettings(); + initOpenVRSettings(); initOpenVRRenderModels(); initOpenVRChaperone(); } catch (Exception e) { @@ -374,7 +374,7 @@ else if( osname.contains("mac")){ final int rotationIncrement = 0; public static boolean isError(){ - return hmdErrorStore.getValue() != 0 && hmdErrorStoreBuf.get(0) != 0; + return hmdErrorStore.getValue() != 0 || hmdErrorStoreBuf.get(0) != 0; } public static int getError(){ @@ -474,12 +474,17 @@ public static void initOpenVROverlay() throws Exception vrOverlay.read(); System.out.println("OpenVR Overlay initialized OK"); } else { - throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + if (getError() == 7) { + System.out.println("VROverlay init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + vrOverlay = null; + } else { + throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + } } } - public static void initOpenVROSettings() throws Exception + public static void initOpenVRSettings() throws Exception { vrSettings = new VR_IVRSettings_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSettings_Version, hmdErrorStoreBuf)); if (vrSettings != null && !isError()) { @@ -487,7 +492,12 @@ public static void initOpenVROSettings() throws Exception vrSettings.read(); System.out.println("OpenVR Settings initialized OK"); } else { - throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + if (getError() == 7) { + System.out.println("VRSettings init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + vrSettings = null; + } else { + throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + } } } @@ -579,7 +589,12 @@ public static void initOpenVRRenderModels() throws Exception vrRenderModels.read(); System.out.println("OpenVR RenderModels initialized OK"); } else { - throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + if (getError() == 7) { + System.out.println("VRRenderModels init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + vrRenderModels = null; + } else { + throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + } } } @@ -590,9 +605,12 @@ private static void initOpenVRChaperone() throws Exception { vrChaperone.read(); System.out.println("OpenVR chaperone initialized."); } else { - System.out.println("Chaperone init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0)); - vrChaperone = null; - //throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0)); + if (getError() == 7) { + System.out.println("VRChaperone init failed: " + jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + vrChaperone = null; + } else { + throw new Exception(jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(getError()).getString(0)); + } } } @@ -649,7 +667,7 @@ public static void poll(long frameIndex) processVRFunctions(sleeping, mc.currentScreen != null); Minecraft.getMinecraft().mcProfiler.endStartSection("updatePose"); - updatePose(); + updatePose(); Minecraft.getMinecraft().mcProfiler.endSection(); } @@ -717,6 +735,7 @@ private static void processHotbar() { private static int quickTorchPreviousSlot; public static boolean setKeyboardOverlayShowing(boolean showingState, GuiTextField gui) { + if (vrOverlay == null) return false; try { if(mc.vrSettings.seated) showingState = false; keyboardGui = gui; @@ -1981,7 +2000,8 @@ private static void updatePose() triggerHapticPulse(1, 500); } - controllerDeviceIndex[THIRD_CONTROLLER] = -1; + if(controllerDeviceIndex[0] != -1 && controllerDeviceIndex[1] !=-1) + controllerDeviceIndex[THIRD_CONTROLLER] = -1; for (int nDevice = 0; nDevice < JOpenVRLibrary.k_unMaxTrackedDeviceCount; ++nDevice ) { @@ -1994,10 +2014,12 @@ private static void updatePose() if(mc.vrSettings.displayMirrorMode == VRSettings.MIRROR_MIXED_REALITY){ int c = vrsystem.GetTrackedDeviceClass.apply(nDevice); int r = vrsystem.GetControllerRoleForTrackedDeviceIndex.apply(nDevice); - if((c == 2 && r == 0) || c == 3) controllerDeviceIndex[THIRD_CONTROLLER] = nDevice; - } + if((c == 2 && r == 0) || c == 3) + controllerDeviceIndex[THIRD_CONTROLLER] = nDevice; + } } + if (hmdTrackedDevicePoses[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd].bPoseIsValid != 0 ) { OpenVRUtil.Matrix4fCopy(poseMatrices[JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd], hmdPose); @@ -2029,7 +2051,6 @@ private static void updatePose() getTipTransforms(); //TODO dont do this @90hz. updateAim(); - } /** @@ -2541,14 +2562,14 @@ private static void updateAim() { mrMovingCamActive = false; } } - } public static Matrix4f getHandRotation( int controller ) { return controller == 0 ? handRotation[0]: handRotation[1]; } - private static void getTipTransforms(){ + private static void getTipTransforms() { + if (vrRenderModels == null) return; int count = vrRenderModels.GetRenderModelCount.apply(); Pointer pointer = new Memory(JOpenVRLibrary.k_unMaxPropertyStringSize); for (int i = 0; i < 2; i++) { diff --git a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java index b7cf663f..5e8e54f5 100644 --- a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java +++ b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java @@ -21,6 +21,7 @@ import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityMinecart; @@ -729,7 +730,11 @@ public void updateTeleportArc(Minecraft mc, Entity player) newPos.yCoord = pos.yCoord + velocity.yCoord; newPos.zCoord = pos.zCoord + velocity.zCoord; - boolean water = mc.entityRenderer.getEyeCollisionBlock(mc.currentPass, true).getMaterial() == Material.water; + + boolean water =false; + Block b = mc.entityRenderer.getEyeCollisionBlock(mc.currentPass, true); + water = b!=null &&b.getMaterial() == Material.water; + MovingObjectPosition collision = tpRaytrace(player.worldObj, pos, newPos, !water, true, false); @@ -1055,11 +1060,14 @@ private boolean checkAndSetTeleportDestination(Minecraft mc, Entity player, Vec3 bb = player.boundingBox.copy().offset(offset.xCoord, offset.yCoord, offset.zCoord); emptySpotReq = mc.theWorld.getCollidingBoundingBoxes(player,bb).isEmpty(); } - + + float ex = 0; + if(mc.vrSettings.seated)ex = 0.5f; + if(emptySpotReq){ - movementTeleportDestination = Vec3.createVectorHelper((bb.maxX - bb.minX) /2 ,bb.minY, (bb.maxZ - bb.minZ)/2); + movementTeleportDestination = Vec3.createVectorHelper((bb.maxX + bb.minX) /2 ,bb.minY + ex, (bb.maxZ + bb.minZ)/2); movementTeleportDestinationSideHit = collision.sideHit; - return true; + bFoundValidSpot = true; } } else if (collision.sideHit != 1) @@ -1075,7 +1083,7 @@ private boolean checkAndSetTeleportDestination(Minecraft mc, Entity player, Vec3 movementTeleportDestination.yCoord = dest.yCoord; movementTeleportDestination.zCoord = dest.zCoord; movementTeleportDestinationSideHit = collision.sideHit; - return true; //really should check if the block above is passable. Maybe later. + bFoundValidSpot = true; //really should check if the block above is passable. Maybe later. } else { if (!mc.thePlayer.capabilities.allowFlying && mc.vrSettings.vrLimitedSurvivalTeleport) {return false;} //if creative, check if can hop on top. } @@ -1628,7 +1636,9 @@ public float getControllerPitch_World(int controller) { @Override public float getControllerRoll_World(int controller) { - org.lwjgl.util.vector.Matrix4f mat = (org.lwjgl.util.vector.Matrix4f)new org.lwjgl.util.vector.Matrix4f().load(getControllerMatrix_World(controller)); + org.lwjgl.util.vector.Matrix4f mat = + (org.lwjgl.util.vector.Matrix4f)new org.lwjgl.util.vector.Matrix4f(). + load(getControllerMatrix_World_Normal(controller)); return (float)-Math.toDegrees(Math.atan2(mat.m10, mat.m11)); } @@ -1639,6 +1649,12 @@ public FloatBuffer getControllerMatrix_World(int controller) { return Matrix4f.multiply(rot,out).transposed().toFloatBuffer(); } + public FloatBuffer getControllerMatrix_World_Normal(int controller) { + Matrix4f out = MCOpenVR.getAimRotation(controller); + Matrix4f rot = Matrix4f.rotationY(worldRotationRadians); + return Matrix4f.multiply(rot,out).toFloatBuffer(); + } + @Override public Vec3 getCustomHMDVector(Vec3 axis) { Vector3f v3 = MCOpenVR.hmdRotation.transform(new Vector3f((float)axis.xCoord, (float)axis.yCoord, (float)axis.zCoord)); diff --git a/src/com/mtbs3d/minecrift/settings/VRHotkeys.java b/src/com/mtbs3d/minecrift/settings/VRHotkeys.java index 3e1d694c..83b689ce 100644 --- a/src/com/mtbs3d/minecrift/settings/VRHotkeys.java +++ b/src/com/mtbs3d/minecrift/settings/VRHotkeys.java @@ -141,68 +141,69 @@ public static boolean handleKeyboardInputs(Minecraft mc) } - if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_UP && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposX -= 0.01; + mc.vrSettings.vrFixedCamrotPitch -= 0.5; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT&& Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposX += 0.01; + mc.vrSettings.vrFixedCamrotPitch += 0.5; gotKey = true; + } - if (Keyboard.getEventKey() == Keyboard.KEY_UP&& Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposZ -= 0.01; + mc.vrSettings.vrFixedCamrotYaw -= 0.5; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposZ += 0.01; + mc.vrSettings.vrFixedCamrotYaw += 0.5; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_PRIOR && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_PRIOR && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposY += 0.01; + mc.vrSettings.vrFixedCamrotRoll -= 0.05; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_NEXT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) + if (Keyboard.getEventKey() == Keyboard.KEY_NEXT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamposY -= 0.01; + mc.vrSettings.vrFixedCamrotRoll += 0.05; gotKey = true; } - - if (Keyboard.getEventKey() == Keyboard.KEY_UP && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if(!gotKey){ + if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamrotPitch -= 0.5; + mc.vrSettings.vrFixedCamposX -= 0.01; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT&& Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamrotPitch += 0.5; + mc.vrSettings.vrFixedCamposX += 0.01; gotKey = true; - } - if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if (Keyboard.getEventKey() == Keyboard.KEY_UP&& Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamrotYaw -= 0.5; + mc.vrSettings.vrFixedCamposZ -= 0.01; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamrotYaw += 0.5; + mc.vrSettings.vrFixedCamposZ += 0.01; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_PRIOR && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if (Keyboard.getEventKey() == Keyboard.KEY_PRIOR && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { - mc.vrSettings.vrFixedCamrotRoll -= 0.05; + mc.vrSettings.vrFixedCamposY += 0.01; gotKey = true; } - if (Keyboard.getEventKey() == Keyboard.KEY_NEXT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + if (Keyboard.getEventKey() == Keyboard.KEY_NEXT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) { - mc.vrSettings.vrFixedCamrotRoll += 0.05; + mc.vrSettings.vrFixedCamposY -= 0.01; gotKey = true; } + if (Keyboard.getEventKey() == Keyboard.KEY_INSERT && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) { mc.gameSettings.fovSetting +=1 ; @@ -214,6 +215,7 @@ public static boolean handleKeyboardInputs(Minecraft mc) mc.gameSettings.fovSetting -=1 ; gotKey = true; } + } if (Keyboard.getEventKey() == Keyboard.KEY_HOME && Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) { snapMRCam(mc,0); @@ -229,26 +231,17 @@ public static boolean handleKeyboardInputs(Minecraft mc) return gotKey; } + public static void snapMRCam(Minecraft mc, int controller) { - mc.vrSettings.vrFixedCamrotPitch = -Minecraft.getMinecraft().roomScale.getControllerPitch_World(controller) + mc.vrSettings.mrMovingCamOffsetPitch; - mc.vrSettings.vrFixedCamrotYaw = Minecraft.getMinecraft().roomScale.getControllerYaw_World(controller) + mc.vrSettings.vrWorldRotation + mc.vrSettings.mrMovingCamOffsetYaw; - mc.vrSettings.vrFixedCamrotRoll = Minecraft.getMinecraft().roomScale.getControllerRoll_World(controller) + mc.vrSettings.mrMovingCamOffsetRoll; - - org.lwjgl.util.vector.Vector4f vec = new org.lwjgl.util.vector.Vector4f(mc.vrSettings.mrMovingCamOffsetX, mc.vrSettings.mrMovingCamOffsetY, mc.vrSettings.mrMovingCamOffsetZ, 1); - org.lwjgl.util.vector.Matrix4f matrix = new org.lwjgl.util.vector.Matrix4f(); - matrix.rotate((float)Math.toRadians(mc.vrSettings.vrFixedCamrotRoll), new org.lwjgl.util.vector.Vector3f(0, 0, 1)); - matrix.rotate((float)Math.toRadians(mc.vrSettings.vrFixedCamrotPitch), new org.lwjgl.util.vector.Vector3f(-1, 0, 0)); - matrix.rotate((float)Math.toRadians(mc.vrSettings.vrFixedCamrotYaw), new org.lwjgl.util.vector.Vector3f(0, -1, 0)); - org.lwjgl.util.vector.Matrix4f.transform(matrix, vec, vec); - - Vec3 pos = Minecraft.getMinecraft().roomScale.getControllerPos_Room(controller); - mc.vrSettings.vrFixedCamposX = ((float)pos.xCoord + vec.x) / mc.vrPlayer.worldScale; - mc.vrSettings.vrFixedCamposY = ((float)pos.yCoord + vec.y) / mc.vrPlayer.worldScale; - mc.vrSettings.vrFixedCamposZ = ((float)pos.zCoord + vec.z) / mc.vrPlayer.worldScale; - MCOpenVR.mrControllerPos = Minecraft.getMinecraft().roomScale.getControllerPos_Room(controller); - MCOpenVR.mrControllerPitch = -Minecraft.getMinecraft().roomScale.getControllerPitch_World(controller); - MCOpenVR.mrControllerYaw = Minecraft.getMinecraft().roomScale.getControllerYaw_World(controller) + mc.vrSettings.vrWorldRotation; - MCOpenVR.mrControllerRoll = Minecraft.getMinecraft().roomScale.getControllerRoll_World(controller); + mc.vrSettings.vrFixedCamrotPitch = -mc.roomScale.getControllerPitch_World(controller); + mc.vrSettings.vrFixedCamrotYaw = 180+ mc.roomScale.getControllerYaw_World(controller) - mc.vrSettings.vrWorldRotation; + mc.vrSettings.vrFixedCamrotRoll = mc.roomScale.getControllerRoll_World(controller); + + Vec3 pos = mc.roomScale.getControllerPos_Room(controller); + mc.vrSettings.vrFixedCamposX = ((float)pos.xCoord) / mc.vrPlayer.worldScale; + mc.vrSettings.vrFixedCamposY = ((float)pos.yCoord) / mc.vrPlayer.worldScale; + mc.vrSettings.vrFixedCamposZ = ((float)pos.zCoord) / mc.vrPlayer.worldScale; + } } diff --git a/src/com/mtbs3d/minecrift/settings/VRSettings.java b/src/com/mtbs3d/minecrift/settings/VRSettings.java index 38cf3223..f5faf809 100644 --- a/src/com/mtbs3d/minecrift/settings/VRSettings.java +++ b/src/com/mtbs3d/minecrift/settings/VRSettings.java @@ -1853,8 +1853,8 @@ private VRControllerButtonMapping[] getBindingsDefaults(){ out[ViveButtons.BUTTON_LEFT_TOUCHPAD_UR.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_UR, "key.inventory"); out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_UP.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_UP, "none"); out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_DOWN.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_DOWN, "none"); - out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_LEFT.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_LEFT, "none"); - out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_RIGHT.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_RIGHT, "none"); + out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_LEFT.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_LEFT, "Hotbar Prev"); + out[ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_RIGHT.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_LEFT_TOUCHPAD_SWIPE_RIGHT, "Hotbar Next"); out[ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_UP.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_UP, "none"); out[ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_DOWN.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_DOWN, "none"); out[ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_LEFT.ordinal()] = new VRControllerButtonMapping(ViveButtons.BUTTON_RIGHT_TOUCHPAD_SWIPE_LEFT, "Hotbar Prev"); diff --git a/src/com/mtbs3d/minecrift/utils/Utils.java b/src/com/mtbs3d/minecrift/utils/Utils.java index cf7d4be9..51ad4955 100644 --- a/src/com/mtbs3d/minecrift/utils/Utils.java +++ b/src/com/mtbs3d/minecrift/utils/Utils.java @@ -7,6 +7,7 @@ import org.lwjgl.util.vector.Matrix4f; import org.lwjgl.util.vector.Vector2f; import org.lwjgl.util.vector.Vector3f; +import org.lwjgl.util.vector.Vector4f; import net.minecraft.util.Vec3; @@ -100,6 +101,14 @@ public static Vector3f convertVector(Vector3 vector) { return new Vector3f(vector.getX(), vector.getY(), vector.getZ()); } + public static Vector3f convertVector(de.fruitfly.ovr.structs.Vector3f vector) { + return new Vector3f(vector.x, vector.y, vector.z); + } + + public static de.fruitfly.ovr.structs.Vector3f convertToOVRVector(Vector3f vector) { + return new de.fruitfly.ovr.structs.Vector3f(vector.x, vector.y, vector.z); + } + public static Vector3 convertVector(Vector3f vector) { return new Vector3(vector.getX(), vector.getY(), vector.getZ()); } @@ -134,5 +143,12 @@ public static Matrix4f matrix3to4(Matrix3f matrix) { mat.m22 = matrix.m22; return mat; } + + public static Vector3f directionFromMatrix(Matrix4f matrix, float x, float y, float z) { + Vector4f vec = new Vector4f(x, y, z, 0); + Matrix4f.transform(matrix, vec, vec); + vec.normalise(vec); + return new Vector3f(vec.x, vec.y, vec.z); + } }