Applying mateiral to a mesh instance

There are no stupid questions, just stupid answers.
6 posts Page 1 of 1
Code_Man
Posts: 9
Joined: Fri Jan 26, 2018 9:12 pm
by Code_Man » Thu Mar 01, 2018 12:49 am
I would like to apply a material to specific instances of meshes in the game trough torquescript, but i dont know how to do this.
Its fine if it applies to the whole model instead of just a specific material in a collada node.

I also noticed that i seem to have to prepend the model name to a material when using collada models, this is a problem for me too since i reuse many materials for different models.
I only use collada for now, though if have to i could convert them to dts.

How could i go about this?
Online Duion
Posts: 958
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Thu Mar 01, 2018 1:22 am
Are you trying to apply lightmaps to the models? This is something I'm also interested in.

From what I know it is possible to swap materials per instance of a mesh through chosing a different skin. A skin is a material using the same namespace as the original material, maybe this feature could be extended for what you need, but this would need to happen on the fly.
Code_Man
Posts: 9
Joined: Fri Jan 26, 2018 9:12 pm
by Code_Man » Thu Mar 01, 2018 11:17 am
Duion wrote:Are you trying to apply lightmaps to the models? This is something I'm also interested in.

Not really, at this stage atleast.

Duion wrote:From what I know it is possible to swap materials per instance of a mesh through chosing a different skin. A skin is a material using the same namespace as the original material, maybe this feature could be extended for what you need, but this would need to happen on the fly.

Hmm, are the player models in uebergame using skins too for team colors?
If so i might perhaps be a able to figure it out on my own
Online Duion
Posts: 958
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Thu Mar 01, 2018 11:47 am
I setup my rock models to use skins, so any instance of a rock model can have any other rock material I have in the game, simply by changing the skin, you can try them out.
https://github.com/Duion/Uebergame/blob ... terials.cs

The base material is "base_rock_main" and each skin replaces the "base" part of the name, so in the skin field of the shape you enter "plain_01" if you want to use the material "plain_01_rock_main" then the instance of the rock will change to that, this can also be changed on the fly through scripts like I do with some objects using team colors.
DoyleWes
Posts: 1
Joined: Wed Feb 28, 2018 10:34 am
by DoyleWes » Tue Mar 13, 2018 9:50 am
That's an awesome idea, Duion. Do you think that'd be worth doing for stuff other than rocks maybe?
Online Duion
Posts: 958
Joined: Sun Feb 08, 2015 1:51 am
 
by Duion » Tue Mar 13, 2018 11:34 pm
@
User avatar
DoyleWes

Anything that you can imagine, I use it on rocks, because they all use a seamless texture, so every other seamless texture will fit as well, limitations are objects with unique UV layout, since then other textures will no longer fit well and the other limitation is objects with multiple materials and of course some ways that do not allow changing skins like forest objects, but they have two materials also.

You could theoretically make anything into a skin so you can exchange anything with anything, but there are probably better ways through coding to do that.
6 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests