Finding material name of primitive

Is there any really simple way to find the material name associated with a particular primitive found with the process on this page panda3d.org/manual/index.php … metry_data ?

I’m trying to make a flexible grid system that I can manipulate as a single object in Blender, so I’m using a mesh and having each tile be a face on it. I’d like to pass some information about the tile’s properties with material names.

I don’t know what you mean by “material name”, since Panda doesn’t have that concept in the same way that modeling tools like Blender do. Panda does have an object called a Material, which might or might not be applied to a particular object and defines the way certain lighting effects apply to geometry, and Panda’s Material object does indeed have a name; so it would be possible to find the Material object that’s applied to a particular Geom, if any, and get its name.

You would do this by getting the RenderState from GeomNode.getGeomState(), composing it with NodePath.getNetState() for good measure (in case the Material is applied at the scene graph level), and then check state.getAttrib(MaterialAttrib) to see if you actually have a MaterialAttrib defined in the state. If you do, you can call MaterialAttrib.getMatrial().getName() to get the name of the Material object.

But I don’t know how useful that will be in general.

David

Thanks drwr, this worked with a bit of jiggering to get the correct references.