Jump to content

Question About Binding Textures to Techne Models


MadTinkerer

Recommended Posts

Hi there guys, I got a (hopefully) simple question here.

 

I want to make a custom techne model that has both solid components as well as transparent components (basically a fluid tank component on my block). I would like for at run time to change the texture displayed in the transparent shape to represent whatever fluid is currently in block.

 

Is there a way to do this without redrawing the entire model? Can I bind a texture to just one shape at a time?

 

Any suggestions?

 

Thanks!

 

Link to comment
Share on other sites

First of all, I'd suggest using the Tessellator to render, because it provides more customisability, but that is up to you. Second, you can from the get-go bind two textures and then, in your render code, just don't use the texture. You can then make a boolean that will be true if the tank is active and if the boolean is true, draw render code that uses that texture. If you are using Techne, I can't really help you, so I'd suggest using the Tessellator.

I am the self-nominated Lord of the Mastodons and don't you dare deny it. ;) Also, check out my YouTube channel: https://www.youtube.com/user/DerpDerp44/

Link to comment
Share on other sites

It doesn't matter whether you use Techne or not. If you have custom renderer you can decide what you render and how you render it.

This is how I would do it: Render it in two parts, first the solid (empty) tank and if there it's not empty (you check that from your tileentity in your renderer's renderTileEntityAt(...) method) then you render fluid and bind fluid specific texture. You can decide do you want to use tessellator for that or not.

 

LoardMastodonFTW: What do you mean by suggesting using the Tessellator?

Link to comment
Share on other sites

Okay, so I did combine the approaches to achieve the effect I wanted.

 

Essentially my block (a steam boiler) has a techne model that constitutes of frame and transparent glass panels that I render, then within the same render loop I instantiate a tesselator instance and draw a proportional representation of the fluid inside (steam) inside the hollow space of the block.

 

I guess the only question I have remaining is - The tesselator is painful to work with when designing any model other than crude shapes. Is there a better way to do this? A helper library or a modelling tool that will give you the vertices you need to create the model?

 

Obviously, for simple cuboids this isn't much of a problem, but if I have to do more complex rendering this way I think I'd rather chop off my own nuts.

 

Link to comment
Share on other sites

Like I said, you don't have to use tessellator if you don't want to. You just render your model in two parts; you have in your model.java file method named render(...) right? There are names you have given in techne for each parts. Create new method, for example, renderTankContent() and move things you want to render depending on tileentity data to there. Then you just check in your tileentity special renderer you first call yourmodel#render(...) and then check if it should render it with content or not, if so, bind texture for content and render content.

 

Here is the whole idea how to do this:

 

tileentity special renderer#renderTileEntityAt(...)

 

--rotate and scale model as needed--

--bind texture--

model#render(...)

 

--check if tileentity#hasFluid, and if so: --

--bind texture--

model#renderTankContent()

 

Link to comment
Share on other sites

I'm fairly certain for my particular use I would need to use the tesselator because I am drawing a cube and texturing it with my liquid that is of a size on the Y plane that is relative to how much liquid is in the tank.

 

So, if the tank is 12x12x12 cube at full, it will be 12x6x12 when half full.

 

Obviously if it was just a matter of swapping out a texture on a cube that was always the same size, then this wouldn't be an issue :D

 

 

Link to comment
Share on other sites

argh... If you don't want to try what I just said then ok.. But this is something I just did without using tessellator and with method I explained:

svovbq.gif

This thing can be turned off (then there is no rotating blue cubes and light indicator on the front turns from green to red)

 

Link to comment
Share on other sites

Don't get frustrated, you didn't explain yourself very well.

 

It wasn't until I took a look again at the code Techne generates that I realized I could just instantiate a new ModelRenderer class and .addBox a cube representing my tank of the appropriate dimensions at runtime and go from there.

 

Don't get me wrong, I am thankful for your help (and it did help give me the right idea). Frankly, I feel stupid for not realizing this earlier, but oh well :D

 

 

Link to comment
Share on other sites

Sorry for that =D I just woke up and having flu so it is hard to stay calm =D

Ok but you got the idea? Check the YourModel#render(..) and how it renders those boxes so you understand how you can render things in multiple parts and even rotate and scale those parts as needed without having them affecting other already rendered parts.

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.