Forum

inherit_material

24 November 2015 19:58
Is there any way to export my node materials to a .json and in runtime assign this material to any part of my object?

I'm using inherit_material and right now when I'm loading this .json with the material I have the error "Wrong objects for inheriting material!", it seems that I can't use this function with node materials.

I read in other post that people with the same problem and they're using a beta in order to access to material library, can I access to this beta?

Thanks!!!!
25 November 2015 12:32
Hi.

I'm using inherit_material and right now when I'm loading this .json with the material I have the error "Wrong objects for inheriting material!", it seems that I can't use this function with node materials.

Take a look at this, please.

The "Wrong objects for inheriting material!" console message appears, when the one of two objects hasn't the assigned material. Check the material names, please.

Also you can create node material, which will contain two or more nodes subtrees. And then you can use the "Value" node to change using nodes subtree.

I read in other post that people with the same problem and they're using a beta in order to access to material library, can I access to this beta?

Sorry, could you tell me, please, what "beta" is?
25 November 2015 19:18
The problem was that we are using numbers for the material names, in batch.js in the find_batch_material function it seems that array.indexOf fails with numbers.

We changed this numbers to letters and works fine, thanks for the advise.

Kind regards
26 November 2015 10:25
The "inherit_material" function uses string material names variables, if you give integer or float type of variable - the array.indexOf cannot find it. For example:
var data = ["1", "2", "3"];
var num = 1;
console.log(data.indexOf(num) == 0) // return false
console.log(data.indexOf(num.toString()) == 0) // return true


Try to use the following code, please:
var mat_name_to = 1;
var mat_name_from = 2;
if (typeof(mat_name_to) === "number")
   mat_name_to = mat_name_to.toString();
if (typeof(mat_name_from) === "number")
   mat_name_from = mat_name_from.toString();
m_materials.inherit_material(obj_from, mat_name_from, obj_to,mat_name_to);
 
Please register or log in to leave a reply.