Jump to content

Recommended Posts

Posted

Hello everyone!

 

I wanted to create a pipe block, which can connect to adjacent pipes on every side. The connection element should be rendered with an .obj file, that is rotated to the correct direction for each connected side. The problem is, that I cannot get the obj models to work.

 

I've created a simple model file that does the same with vanilla model files (and actually works), but this is not customizable enough for me, I'd like to use .obj instead.

 

This is the model code I used with the vanilla model files:

 

  Reveal hidden contents

 

And this is the base class ModelBase I created for working with code-driven renderers:

 

  Reveal hidden contents

 

 

This code does work.

However, my second attempt with the .obj models did not work at all: The models are loaded, but they are not rendered in the game. Nothing there at all.

Here's the code of the loadSubmodels and putQuads method (everything else is the same).

 

 

  Reveal hidden contents

 

 

The obj file is a simple cube at the moment to keep it simple.

 

  Reveal hidden contents

 

 

If anyone has an idea why this does not work or how to fix it, please tell me!

If you need some more code, I can provide it as well.

Posted

There is a lot simpler way of rendering OBJ models. If you register your mod with OBJLoader.instance.addDomain, you can simply use your .obj files instead of defining vanilla json model files. With the forge blockstate json syntax and submodels, I think you can get the versatility you need.

Posted

Yes, this would work, however I have one problem with this:

The pipes I try to create would have way too many different blockstates!

There is one boolean state for each direction (2^6 states), the pipe can have different colors (*16 more states), the pipe can have different materials (even more) and maybe I want to allow different pipe types to connect to each other, which needs to be rendered differently.

 

Every single possible combination of those states would require a single blockstate which

a) slows down minecraft loading, because every single blockstate is evaluated and cached (Tried it, I got about 2048 states per pipe)

b) consumes tons of ram, especially if the models become more complicated

c) makes the blockstates json file a mess and difficult to read and write.

Therefore I decided not to use blockstates at all and to make a code-driven renderer which works fine generally. Only the obj models are not rendered, everything else is fine already. Therefore, I wont change to forge's blockstates file now.

Posted

Well, I did some further investigation and found out what caused the problem, although I neither know why this is a problem, nor how to solve it. (Did I mention that I hate the Minecraft model system because it makes everything pretty user-unfriendly to debug?)

 

I created an even simpler .obj file consisting out of a single face and generated the same face by code (the latter works, the former doesn't) and compared the raw data I got.

This is the data stored in the UnpackedBakedQuad classes:

 

  Reveal hidden contents

 

 

The difference is, that the UV coordinates are repeated for the obj model. I changed the repeated values to 0 in eclipse debug mode, and it works.

I assume, the values are doubled because the BLOCK vertex format uses

[POS, COLOR, UV (double), UV (short)].

 

Now the questions:

1st and most important: Dear Minecraft, why the heck do you need UVs twice, why in different formats and WHY do I HAVE TO make the second ones all zero?

2nd: Why does the Forge model loader put the uvs in two times if one is enough? Or is this a problem only I have so no one else noticed?

3rd: How can I fix this from inside my code, not from debug mode? I don't want to recreate the whole ObjModel class to change a tiny bit in the final putVertexData method and I also don't really want to create a coremod for this.

  • 1 month later...

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.