Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get material string of unit

1 REPLY 1
Reply
Message 1 of 2
Anonymous
276 Views, 1 Reply

Get material string of unit

Hello

 

I am trying to set the material of one unit, to the same material as another unit. How do I achieve this?

 

The way I set the material of the unit is the following, in my c code: 

void *materials[] = { _resource_api->get("material", lua_material_string) };
mesh_api->set_materials(o.mesh, 1, materials);

where lua_material_string is 'content/materials/yellow'

 

 

What I want is therefore to get a string similar to this, from another unit. I've tried the following, in c and lua:

 

c:

uint32_t mesh_name = _unit->mesh_name(lua_unit_base, 0);
uint32_t mesh_handle = _mesh_api->lookup(lua_unit_base, mesh_name);

void *mat = _mesh_api->material(mesh_handle, 0);
void *materials[] = { mat };
_mesh_api->set_materials(o.mesh, 1, materials);

lua:

stingray.IdString32.to_string(stingray.Mesh.material_slot_name(stingray.Unit.mesh(unit, 1), 1))
stingray.Unit.get_property(unit, "materials")

None of which seems to give me what I want.

 

 

Is there a way to retrieve the material of a unit/mesh in the form 'content/materials/yellow'? Alternatively, is there another way of setting the material of one unit to the same material as another unit?

 

Thanks for the help!

 

1 REPLY 1
Message 2 of 2
__ben__
in reply to: Anonymous

This thread deals with material strings in LUA:

 

https://forums.autodesk.com/t5/stingray-forum/changing-a-material-s-color-at-run-time-ru-he-zhi-jie-...

 

What is the function you are calling returning? Is it a hex string? Stingray manages material paths internally not as strings but as hashes for efficiency. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report