Jump to content

[1.12.2] setRenderViewEntity issue


qazqazqaz
 Share

Recommended Posts

Hi, I've been trying to make a third person camera mod similar to the camera in the Dark Souls games, that is the camera can rotate around the player and movement is relative to the current view. At first I used the EntityViewRenderEvent.CameraSetup event to set the pitch and yaw of the camera but chunks behind the player's view were not rendered until the player moved. I fixed this by changing the location of the player by a very small amount each tick. However I wanted more control over the camera (e.g. zoom) so I adapted the MineShot camera coremod to suit my needs and transformed the camera using GlStateManager in the EntityViewRenderEvent.RenderFog event. This works ok but has reintroduced the missing chunks issue and moving the player no longer forces these missing chunks to render.

 

I believe that using setRenderViewEntity with a dummy entity set to my third person camera's position should fix this problem in theory as the renderWorldPass method in EntityRenderer uses the current render view entity for its calculations. Below is the code I have used to attempt this.

GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "FakePlayer");
camEntity = new FakePlayer(DimensionManager.getWorld(0), gameProfile);
camEntity.noClip = true;
camEntity.setPositionAndRotation(adjustedSpherePos.x, adjustedSpherePos.y, adjustedSpherePos.z, MathHelper.wrapDegrees(yRot), MathHelper.wrapDegrees(xRot));
MC.setRenderViewEntity(camEntity);

System.out.println(MC.getRenderViewEntity().toString()); //outputs name: FakePlayer, level: world, coords same as adjustedSpherePos (camera)
System.out.println(MC.getRenderViewEntity().getPositionVector().toString()); //outputs (0, 0, 0) for some reason

 

The result of adding this code was that the majority of the world disappeared, with a few parts flashing occasionally, and the position of the new game view appeared to shake between 2 points in an area of around 10 blocks despite the fact its position is not modified by my code after being declared. I also think the getPositionVector() output of (0, 0, 0) is a bit strange.

Now I know you guys don't support coremods, but seeing as the rendering goes back to normal as soon as I set the render view entity back to the player I don't think that it being a coremod is necessarily to blame.

 

It would be greatly appreciated if anybody could help by either:

1. identifying any flaws with my implementation using a FakePlayer (e.g. wrong entity, need to set some extra properties) or

2. suggesting how I might implement the hackier solution of forcing all chunks to be rendered all the time (maybe ChunkRenderContainer.addRenderChunk?)

 

Thanks!

 

  • Like 1
Link to comment
Share on other sites

http://www.minecraftforge.net/forum/topic/17770-solved-changing-eye-height-camera-render-viewpoint/

 

I tried also setting the camEntity.prevPosX etc. as suggested in this post by coolAlias but unfortunately this didn't appear to solve the problem. I guess I'll have to look into how to manually feed the world renderer a different view frustum seeing as the easy route isn't going well.

Link to comment
Share on other sites

A bit unrelated note, you don't need a coremod for zoom. There's  FOVUpdateEvent for that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

1 hour ago, Abastro said:

A bit unrelated note, you don't need a coremod for zoom. There's  FOVUpdateEvent for that.

Thanks for the suggestion. However, my interpretation of zoom here is translating the camera further away from the player rather than adjusting the FOV. Granted, these two approaches would have similar results when close to the player, but I'm more interested in zooming out a bit so I expect there will be warping with a higher FOV. 

 

I could use your suggestion along with the CameraSetup event and get a working solution with correct chunk rendering which is honestly looking very tempting now. It's just frustrating that I would have to accept that I could never centre the camera on anything except the player. It might be possible to do this using setRenderViewEntity, but therein lies my main issue.

 

Another hacky fix I have thought of is to make the player look the same way the camera is facing during the world rendering and then restore the original direction if possible before the player model is rendered. This would probably render most chunks in view since I have been using the default third person behind camera before applying my own transformations, but still not a perfect solution as some chunks at the edges might be missing due to the different zoom level.

Link to comment
Share on other sites

3 hours ago, qazqazqaz said:

Thanks for the suggestion. However, my interpretation of zoom here is translating the camera further away from the player rather than adjusting the FOV.

Oh, you meant zooming in/out from the player.

IDK about this issue, setting the render view entity should work well.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Setting the EntityViewRenderEvent.CameraSetup event yaw and pitch to that of my camera rotation and putting the FOV up to quake pro actually works well enough for my needs and I expect it will still render enough chunks even when the camera is offset from the player centre by some small amounts. Looks like the setRenderViewEntity problem will have to remain a mystery.

 

Edit: Entities e.g. signs still disappear sometimes presumably because their visibility is calculated using the hardcoded third person zoom amount 4.0 rather than my camera's zoom level. I might look into how the shoulder surfing mod changes this value but I suspect it will go over my head. Ideally I just want a way to make all clipping frustum checks for chunks and entities return true always.

Edited by qazqazqaz
  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm researching the how to create biomes in json. There is a great tool for creating the jsons online. Using the vanilla `river` biome, I want to essentially create a custom disk feature that mixes 3 blocks instead of a single-block provider. Any ideas on where to start with that?
    • I figured out what was wrong ... you can spot it pretty quick most likely: { "type": "minecraft:smelting", "ingredient": { "item": "minecraft:gold_nugget_ore" }, "result": "minecraft:gold_nugget", "experience": 0.25, "cookingtime": 150 }   ... so, after changing `minecraft` to `foundations` for all the custom items and all the recipes work. Well that's what copy/paste will get you. One last question about recipes, though. What does the following json key/value do in the game? "group": "copper_ingot"  
    • # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #      102.54.94.97     rhino.acme.com          # source server #       38.25.63.10     x.acme.com              # x client host # localhost name resolution is handled within DNS itself. #    127.0.0.1       localhost #    ::1             localhost ###0.0.0.0 apps.corel.com ###0.0.0.0 mc.corel.com 0.0.0.0 origin-mc.corel.com ###0.0.0.0 iws.corel.com
    • Is there a way to create a custom map marker for a custom structure/biome (same as a vanilla mansion)?
    • I’ve scrounged the Internet for solutions and found absolutely nothing that has worked for me I have posted my code in a GitHub Repository. I bet the culprit is somewhere in the Container or TileEntity classes (Furnace packages are in blocks/coke_furnace or blocks/foundry) PS I know I’m on 1.12.2 and that it’s not supported I don’t want to update my game or my code. Lol It’s my favorite version and the most widely modded. I don’t plan to release the mod, I’m just customizing my game to my will. I’ll send it to friends but that’s it.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.