Jump to content

[1.16.3] Is it possible to dynamically toggle pieces of a .obj model?


Recommended Posts

Posted

Hey modders!

 

I'm looking to find out if it's possible for me to toggle individual parts of a .obj block model via the java code. The block in question will be a TileEntity because it needs to function, so I'm assuming a TESR may be in order? 

I've been away from the modding scene for a while, and as a result have forgotten how these are set up. Besides, the code has changed significantly since last time and I don't want to assume it's the same, and the documentation is untrustworthy and out-of-date. Not only that, but I don't know if a TESR is the way to go.

 

TLDR: The .obj model comprises of multiple objects, some of which I want to control the visibility of (just a simple toggle on/off) from Java.

What would be the best approach to doing this?

 

As an added bonus, is there a way I can control cullable faces? When using 

"detectCullableFaces": true

and placing multiple of my block next to one another, touching faces are culled in a way that doesn't look right, and it's not a backface problem in the model because I always check those. The model isn't super high poly-count so I could get away with disabling cullable faces which leaves the model looking correct, but I would like the block to be optimised if I can.

 

Thanks in advance for any help.

Posted (edited)

You may want to take a look at this example here: https://wiki.mcjty.eu/modding/index.php?title=Render_Block_TESR_/_OBJ-1.12

Its for 1.12 but the idea is still valid in the most recent versions...you can see it is rendering different parts of an OBJ model, one that is static and one that is rotating around the Y axis. As for the culling problem, if your block is not a full cube, you have to tell that to the game, otherwise it will still consider it as a full cube and it will not render the faces of adiacent block because it thinks they cannot be seen. So you have to set an appropriate voxel shape for your block. You can look at other vanilla non full-cube blocks to see how they are handled

Edited by Beethoven92

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Posted
18 hours ago, Beethoven92 said:

You may want to take a look at this example here: https://wiki.mcjty.eu/modding/index.php?title=Render_Block_TESR_/_OBJ-1.12

Its for 1.12 but the idea is still valid in the most recent versions...you can see it is rendering different parts of an OBJ model, one that is static and one that is rotating around the Y axis. As for the culling problem, if your block is not a full cube, you have to tell that to the game, otherwise it will still consider it as a full cube and it will not render the faces of adiacent block because it thinks they cannot be seen. So you have to set an appropriate voxel shape for your block. You can look at other vanilla non full-cube blocks to see how they are handled

Aha, perfect find, thank you! I'll look into it

Posted

Alright, I was able to attach a TileEntityRenderer to my block, however if I override render() and leave the function empty, it seems to still be rendering the block as default. I checked with logging and it is being called. Why could this be? I'm not calling the super.

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.

Announcements



×
×
  • Create New...

Important Information

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