-
-
Save TheTemportalist/835a4c1043e6e45d6c37 to your computer and use it in GitHub Desktop.
RenderWorldViewer
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
package com.temportalist.test.client.render | |
import com.temportalist.origin.wrapper.client.render.TERenderer | |
import net.minecraft.client.Minecraft | |
import net.minecraft.client.entity.EntityOtherPlayerMP | |
import net.minecraft.client.shader.Framebuffer | |
import net.minecraft.entity.EntityLivingBase | |
import net.minecraft.tileentity.TileEntity | |
import org.lwjgl.opengl.GL11 | |
/** | |
* | |
* | |
* @author TheTemportalist | |
*/ | |
class RenderWorldViewer() extends TERenderer { | |
private val mc: Minecraft = Minecraft.getMinecraft() | |
private var frameBuffer: Framebuffer = null | |
override protected def render(tileEntity: TileEntity, renderPartialTicks: Float, | |
f5: Float): Unit = { | |
// Create a new buffer (which stores an image of the world) at the player's sceen size | |
// At the player's screen size so it looks like the rendered part is a window | |
// into another POV (like the Portal game almost) | |
this.frameBuffer = new Framebuffer(this.mc.displayWidth, this.mc.displayHeight, true) | |
// New matrix of rendering | |
GL11.glPushMatrix() | |
// todo What does this do? | |
GL11.glLoadIdentity() | |
// todo Bind the texture stored in the framebuffer? Maybe this binds the framebuffer for it to save the render? | |
this.frameBuffer.bindFramebuffer(true) | |
// Remove these modifiers? | |
GL11.glClear( | |
GL11.GL_STENCIL_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | |
) | |
// What does this stuff do? | |
GL11.glMatrixMode(GL11.GL_PROJECTION) | |
GL11.glLoadIdentity() | |
GL11.glMatrixMode(GL11.GL_MODELVIEW) | |
GL11.glLoadIdentity() | |
// Full color | |
GL11.glColor3f(1.0F, 1.0F, 1.0F) | |
// Store the current view (the player most likely) | |
val viewEntity: EntityLivingBase = this.mc.renderViewEntity | |
// Store these paramentery things | |
val posX: Double = viewEntity.posX | |
val posY: Double = viewEntity.posY | |
val posZ: Double = viewEntity.posZ | |
val rotYaw: Float = viewEntity.rotationYaw | |
val rotPitch: Float = viewEntity.rotationPitch | |
// Create a fake player where the window's image is from | |
val fakePlayer: EntityOtherPlayerMP = new EntityOtherPlayerMP( | |
this.mc.theWorld, this.mc.thePlayer.getGameProfile() | |
) | |
this.mc.renderViewEntity = fakePlayer | |
fakePlayer.posX = tileEntity.xCoord + 0.5F | |
fakePlayer.posY = tileEntity.yCoord + 1.5F | |
fakePlayer.posZ = tileEntity.zCoord + 0.5F | |
fakePlayer.rotationYaw = 0.0F | |
fakePlayer.rotationPitch = 0.0F | |
// Save generic settings so that it looks like a window | |
val hideGui: Boolean = this.mc.gameSettings.hideGUI | |
mc.gameSettings.hideGUI = true | |
val thirdPerson: Int = this.mc.gameSettings.thirdPersonView | |
this.mc.gameSettings.thirdPersonView = 0 | |
// Render the world. todo Does this put it into the framebuffer? | |
this.mc.entityRenderer.renderWorld(1.0F, 0L) | |
// Reset back to what we were before render | |
mc.gameSettings.thirdPersonView = thirdPerson | |
mc.gameSettings.hideGUI = hideGui | |
mc.renderViewEntity = viewEntity | |
viewEntity.posX = posX | |
viewEntity.posY = posY | |
viewEntity.posZ = posZ | |
viewEntity.rotationYaw = rotYaw | |
viewEntity.rotationPitch = rotPitch | |
// Unbind the buffer, stop rendering the world | |
this.frameBuffer.unbindFramebuffer() | |
// todo Bind the framebuffer texture to the rendering system? | |
GL11.glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) | |
// TODO render the texture of the framebuffer to a specific box shape in the world! | |
GL11.glPopMatrix() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment