View Full Version : c++ API applying material to instance
gregpat90
June 1st, 2009, 20:04
I am having trouble applying the blueSG material from the cpp example using the c++ API instead of the javascript API.
Hi,
What do you mean with 'apply' in detail?
Is it possible to upload the application you tried with?
Regards.
gregpat90
June 2nd, 2009, 19:34
I am trying to assign to existing material to geometry so that the geometry is rendering using that material. This is code I currently have.
db->create_attribute(cstate, (std::string(meshname)).c_str(), "String","Material[]");
if(inst.is_valid())
{
cstate.loginfo( "inst after create material valid ");
}
mi::Access<mi::Ref> ref = inst.get_field("material[0]");
if(ref.is_valid())
{
cstate.loginfo( "ref is valid ");
}
mi::Edit<mi::Material> mat = ref->get_edit(cstate);
if(mat.is_valid())
{
cstate.loginfo( "mat is valid ");
}
The ref is not valid
cleh
June 4th, 2009, 17:33
Hi,
using RealityServer 2.3, accessing the material of an instance should look like this
mi::Access<mi::Array<mi::Material> > mat = inst.get_field("material");
if (!mat.is_valid())
return false;
mi::Access<mi::Material> mat0 = mat->get_element(cstate, 0);
if (!mat0.is_valid())
return false;
If you are not on 2.3, please let me know what version you are working with and
I'll look into this in detail.
Regards,
Chris
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.