Posted September 19, 20186 yr I'm trying to get what the entity the player is riding sees and render it on screen. The official YouTuber Spaceboy Ross
September 19, 20186 yr You would need to create a framebuffer, set it up correctly, bind a render texture to it, bind it as the active framebuffer and pretty much mimic the entire rendering of the game but with the Minecraft.renderViewEntity being the entity of your choice. Then you would retrieve your texture, bind it and render a quad with it. This is theoretical, I have never done anything like that and don't even know if this is possible. Look at minecraft's shaders, they might offer an insight at the issue. Edit: If you simply want to change what the player sees on the screen(read: not add another texture on to of player's view) then you simply need to change Minecraft.renderViewEntity to the entity you wish to view the world from. However this was raised in an another topic and I believe the author of that topic had some frustrum culling issues with this approach. Edited September 19, 20186 yr by V0idWa1k3r
September 19, 20186 yr Yeah, pretty sure you'd have to do everything that the RenderGlobal class does but you'd set the camera and related frustum to be at the other entity position and in the direction it is looking. You could pretty much copy the code but that might not actually be easy because there is probably a lot of private stuff and concurrent modification issues you'd have to work through. I know some people have implemented mirrors that use a similar idea in mods so maybe there is some tutorial or open source code that can give you ideas. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
September 19, 20186 yr 6 minutes ago, jabelar said: You could pretty much copy the code but that might not actually be easy because there is probably a lot of private stuff and concurrent modification issues you'd have to work through. I actually don't think it's too challenging. As long as you change the renderViewEntity you can just do the same the game does when it renders everything. And it doesn't do much - it just calls a couple of public methods here and there. I also don't think CMEs are going to be a thing. CME happens when a collection is modified while it is iterated. That shouldn't happen when the game simply renders the scene twice.
September 20, 20186 yr Author Can I please have a snippet of the code I need? I can't figure out how to get it to work. The official YouTuber Spaceboy Ross
September 20, 20186 yr A snippet of what? Setting the renderViewEntity? Creating a framebuffer? Rendering everything all over again? Setting the renderViewEntity: Minecraft.getMinecraft().setRenderViewEntity(yourEntity) Creating a framebuffer(somewhat of a pseudo-code as I don't know if Minecraft allows using framebuffers directly like that(it might bind it's own framebuffer somewhere else) but I think for your purpose something like this should suffice - so don't use this code directly, it is meant to be an example) int rbo = GL30.glGenRenderbuffers(); // Should be a field GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, rbo); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_DEPTH24_STENCIL8, texWidth, texHeight); int fbo = GL30.glGenFramebuffers(); // Should be a field GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, tex, 0); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT, GL30.GL_DEPTH24_STENCIL8, rbo); But I think the minecraft-way of doing framebuffers is in the net.minecraft.client.shader.Framebuffer class. However I have never used it and as such you need to figure it out yourself but I would imagine it's not too hard. Seems like it largely does the same my example code does but instead uses OpenGlHelper which is the correct way of doing it I suppose since it accounts for extensions. Rendering everything: Minecraft mc = Minecraft.getMinecraft(); FMLCommonHandler.instance().onRenderTickStart(mc.getRenderPartialTicks()); mc.entityRenderer.updateCameraAndRender(mc.getRenderPartialTicks(), System.nanoTime()); FMLCommonHandler.instance().onRenderTickEnd(mc.getRenderPartialTicks()); Note that you will have to handle the case of the game being paused and supplying renderPartialTicksPaused from the game's timer to the updateCameraAndRender method and for that you will need refiection. But you still haven't told us whether you even need all this framebuffer stuff. Do you just want to render the game from a different perspective or do you actually want to render a quad on the screen that shows what another entity is seeing? Edited September 20, 20186 yr by V0idWa1k3r
September 20, 20186 yr Author I only need to be able to control the entity and see what the entity sees on the screen. The official YouTuber Spaceboy Ross
September 20, 20186 yr 17 minutes ago, Spaceboy Ross said: see what the entity sees on the screen. This statement is ambiguous. Do you mean see as in see through the eyes of the entity(read: see the game from a different perspective) or see as in see a picture of the entity's vision on your HUD? If it's the former then you do not need the framebuffers, you simply need to change the renderViewEntity although I've heard that it is not quite that simple and causes frustrum culling issues.
September 20, 20186 yr Author I've got it working now, I just need to figure out how to get the movement working. The official YouTuber Spaceboy Ross
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.