Jump to content

[1.12.2] setRenderViewEntity issue


qazqazqaz

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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