Jump to content

[1.12.2] Dynamic Textures on Item JSON Model


Spyeedy

Recommended Posts

So a portion of my item model has 3 cards, they can be stacked starting from the bottom. I want to be able to interchangeably apply any card texture on any of the 3 cards (provided there is a card below to place on top).

So I guess it's like a box of cards, the cards can be shuffled however they want. I guess that's what I want, my cards to be moved to any position in the stack in the model.

 

I'm not too sure where I should start, or if this is even possible.

 

Additional Note: I'm using MeshDefinitions for this model for a boolean state of closing/opening, well, i suppose that won't make any difference here, but, just an extra note.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

10 hours ago, Draco18s said:

From my understanding of ItemMeshDefinition, it replaces the model entirely, but that's not what I want to do here, I want to apply any texture I want to a portion of my item model.

 

And I think I didn't specify as to what kind of model it is, it's a JSON model, modelled in 3D.

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

hmm, what if I were to use a custom Baked Model or something that allows me to change the texture location, of any of the values applied to the card part, defined in textures of the JSON model?

Is that possible? If so, I would have to add all the card textures to the texture atlas right?

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Take a look at this thread: 

 

I made a Gun Mod with attachments. Instead of creating all combinations each, I created the single layers and then just dynamically combined them for rendering. I am basically sharing all code here. It might help you, feel free to copy parts it.

 

EDIT: What you could do is have 1 model for each card, and 3 models for the transforms where they can be, then combine them

1. Make a card model of the middle card

2. Copy the model, move it up/down and export again for the top/bottom card

- Now you have 3 json models, all have the same data, except that their transforms are different

3. Copy the first model again for each card and apply texture

- Now you also have a model for each card

4. In the rendering code, always load the model with the card texture (of step 3), but load the transform of one of the initial 3 models to get it into the right position. Do that for all 3 cards.

 

Now only does that solve your problem, but it also lets you change everything via resource pack only.

Edited by CAS_ual_TY
Link to comment
Share on other sites

1 hour ago, CAS_ual_TY said:

I made a Gun Mod with attachments. Instead of creating all combinations each, I created the single layers and then just dynamically combined them for rendering.

From the looks of it, your gun mod uses items' whose models are 3D-ed from 2D textures, like most vanilla items doesn't it?

But for my item, I created a 3D model, with a part of my model having a slot to put in 3 cards. Given that I could render extra quads onto the model, I'm not too sure where I could tell these quads to move to the exact position within the slot?

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

2 hours ago, Afroman said:

Why not make various models with diferent textures, i mean it is how vanilla does it.

Forget it. Now I get what you want. Not much fun in doing 54^3 models Hahaha

I plan to add more cards, hence why I created this thread for the purpose of changing the card's textures dynamically to prevent writing so maaaany variants for all the combinations of cards.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Here is how I would do it:

 

- I would open the model (eg https://blockbench.net/) and add the middle card onto it. Just as a blanc quad or thin cube. Now I would move it to the other 2 slots and write down how I had to move it for that.

- Next, I would remove everything except for the card itself, and export it. Now move the card to another slot (as written down), export. Now move it to the final slot, export.

- Now I would take the initial card-only model again, and create copies of it with the actual textures on it. To clarify: You now have your main item model, 3 blanc card models, which all fit into a slot of your main item model, and then X models of the first card but textured.

- Now whenever you render your item model, you also render one of the textured cards, with the transform of the correct blanc card applied for the slot.

 

This would still require you to create 1 model per card, but no combinations needed.

 

Or you quickly write a Programm which does all the combinations for you from a small premade template.

Link to comment
Share on other sites

6 minutes ago, CAS_ual_TY said:

- Now I would take the initial card-only model again, and create copies of it with the actual textures on it. To clarify: You now have your main item model, 3 blanc card models, which all fit into a slot of your main item model, and then X models of the first card but textured.

- Now whenever you render your item model, you also render one of the textured cards, with the transform of the correct blanc card applied for the slot.

 

This would still require you to create 1 model per card, but no combinations needed.

 

Or you quickly write a Programm which does all the combinations for you from a small premade template.

I see, so with the cards textures, create a card model that fits into the 1st slot, then whenever a card is slotted, take the model of that card and apply the transformations where needed?

 

But before we get into all of that, how will I combine the models?

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

3 minutes ago, CAS_ual_TY said:

Ah, you get your attachment models from here

And then you add this attachment model's quads to the main list in this method

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Alright, I've had the time to implement the Baked Models suggestion. The card appears on the model! Yay!

But I've run into a snag, my item's camera transformation is screwed when my new Baked Model replaces the item model.

 

On a side note, I'm not too sure how I can perform transformations on the card to move it.

 

Here's my code. PackageDiendDriver is where I do the ModelBakeEvent, while the others are the Baked Model classes.

 

Edit: Oh nevermind, I looked into IBakedModel and saw that it uses Forge's default perspectives, so that's why my camera transformations were botched. Fixed that. Still unsure on performing transformations on the card model.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

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.

Announcements



×
×
  • Create New...

Important Information

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