How to get blender’s material name

Hi, is it possible get a material name from a blender object?

I did this:


DesktopAssetManager dsk = (DesktopAssetManager) assetManager;

BlenderKey bk = new BlenderKey("Scenes/level_01/level_01.blend");

Node nd = (Node) dsk.loadModel(bk);

for (Spatial x : nd.getChildren()) {

Node node = (Node) x;

for (Spatial y : node.getChildren()) {

Geometry geo = (Geometry) y;






The problem is that a name of a material is not like I assigned it in the blender file.

THANKS! is a good example :


protected void loadMtlLib(String name) throws IOException{

if (!name.toLowerCase().endsWith(".mtl"))

throw new IOException("Expected .mtl file! Got: " + name);

// NOTE: Cut off any relative/absolute paths

name = new File(name).getName();

AssetKey mtlKey = new AssetKey(key.getFolder() + name);

try {

matList = (MaterialList) assetManager.loadAsset(mtlKey);

} catch (AssetNotFoundException ex){

logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{name, key});


if (matList != null){

// create face lists for every material

for (String matName : matList.keySet()){

matFaces.put(matName, new ArrayList<Face>());





but .blend file has objects + materials. Will it be possible to get a material from a certain object?

asset.AssetKey cannot be cast to ModelKey as far as I understand.

can be useful?

About the cast, it’s just possible if the asset key instance of model key, because model key inherits of asset key. Btw, whats the difference between the material names like you said at first post?

@mifth: Why you forget everything you know about jME3 when doing something slightly different? You can get material info from every object like you always can in jME3 oO Theres no need for any special “blender material” things.

@normen , is there a name of a JME material?

There is no “getMaterial.getName” in JME…

So, I cannot get these names of materials from blender.

Not really, no… Maybe blender sets a key for it… Later we want to be able to load single items from blend files using different keys and a locator to the blend file… Maybe something has been integrated already.

@normen , actually it would be my request for materials naming. Like any spatial has a constructor with a name.

Something like: new Material (String matName, MaterialDef def). I think this is very useful for searching materials by name. For example, I want to find materials “wall_bricks_”.

@Kaelthas , is it possible to get names of materials from blender? With MeshHelper or BlenderHelper, or MaterialHelper or with something you did?

Curious, what does Material.getAssetName() return in this case?

as far as i remember - null.


returns null - from a blender file.

returns Materials/Glass/Glass2_low.j3m - from j3m material.

Hm, as said they will have unique keys per blender material in the future, lets see if names are really necessary then.

Thanks I get you.

As far as I remember, Ogre Material has a name. Am I right?

I think naming of materials is very useful. it would be easier to find materials (wood, walls, floor, grass, ground…), imho.

I get what you mean but adding multiple ways to do that before its really clear 100% how this will be handled isn’t good either. Normally AssetKeys define the “unique name” of anything in jme3, the other name is just a user information in most cases, especially as its not necessarily unique per type. We hear your issue :slight_smile:

Nopes , not possible…

@shivime said:
Nopes , not possible....


There’s material name and then there’s material asset name, they are not the same. The blender loader just needs to set this name for it to work

is there easy way how to make it? I really need these names for my scene composer.

@mifth said:
is there easy way how to make it? I really need these names for my scene composer.

Customise the blender loader :roll:.

As I see it, the material has no ‘name’ property.

It can return the asset name from its key but materials loaded from blender have no asset keys so far.

As @normen said they will have in the future.

But even then the asset name will not be exactly what you want. Its name will be longer and will probably contain the blender file the material

comes from - so that it can be globally unique.

@normen maybe we could add a name for the material (different from the asset name) and the I’ll put the proper blender name in it?

1 Like

Well apparently @Momoko_Fan already expected them to be there already, so I guess its ok ^^