How to get blender’s material name

COOL! When this feature will be expected?

You will save me from many xml tables with names of nodes and materials.



Thanks.

Hi @mifth

I took the liberty to add material name.

I hope nobody will kill me for that :wink:



And I read the name from blender so test it please and tell me if it is OK :slight_smile:

2 Likes

MAN!! I very appreciate it! Thank you a lot. you saved me. I’ll try it asap.



Thank you very much.

@Kaelthas , I tested the material’s name. Everything works fine.



I tested:

[java]Geometry.getMaterial().getName();

Geometry.getMaterial().setName(“xxx”);[/java]



I found another issue. I have about 10 textures 512x512 and one texture 1024x1024 in a blend file. And when I try to load a blend model i've got such Exception:
...
INFO: Child (BitmapFont) attached to this node (null)
Dec 22, 2011 3:03:50 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Dec 22, 2011 3:03:50 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Dec 22, 2011 3:03:50 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Dec 22, 2011 3:03:50 PM com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
Dec 22, 2011 3:03:50 PM com.jme3.scene.plugins.blender.objects.ObjectHelper toObject
INFO: Loading obejct: base
Dec 22, 2011 3:03:50 PM com.jme3.scene.plugins.blender.objects.ObjectHelper toObject
INFO: Importing mesh.
Dec 22, 2011 3:03:51 PM com.jme3.scene.plugins.blender.materials.MaterialHelper toMaterial
INFO: Loading material.
Dec 22, 2011 3:03:51 PM com.jme3.scene.plugins.blender.textures.TextureHelper getTextureFromImage
INFO: Reading texture from file: //../../../Textures/base_textures/base_roofs/base_roof_07.jpg
Dec 22, 2011 3:03:51 PM com.jme3.scene.plugins.blender.textures.TextureHelper getTextureFromImage
INFO: Reading texture from file: //textures/level_01_oa.png
Dec 22, 2011 3:03:51 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: The texture null has invalid width! It should be: 512!
at com.jme3.scene.plugins.blender.textures.TextureHelper.mergeTextures(TextureHelper.java:297)
at com.jme3.scene.plugins.blender.materials.MaterialContext.(MaterialContext.java:158)
at com.jme3.scene.plugins.blender.materials.MaterialHelper.toMaterial(MaterialHelper.java:198)
at com.jme3.scene.plugins.blender.materials.MaterialHelper.getMaterials(MaterialHelper.java:454)
at com.jme3.scene.plugins.blender.meshes.MeshHelper.toMesh(MeshHelper.java:267)
at com.jme3.scene.plugins.blender.objects.ObjectHelper.toObject(ObjectHelper.java:163)
at com.jme3.scene.plugins.blender.AbstractBlenderLoader.toObject(AbstractBlenderLoader.java:134)
at com.jme3.scene.plugins.blender.BlenderLoader.toObject(BlenderLoader.java:70)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:63)
at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:49)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:273)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:408)
at com.bigboots.testscene.TestSceneComposer.simpleInitApp(TestSceneComposer.java:53)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:662)
Dec 22, 2011 3:03:51 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
Dec 22, 2011 3:03:51 PM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
Dec 22, 2011 3:03:51 PM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
Dec 22, 2011 3:03:51 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
BUILD SUCCESSFUL (total time: 8 seconds)
Dec 22, 2011 3:01:38 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
BUILD SUCCESSFUL (total time: 29 seconds)

You probably have them applied to a single mesh.



When I load the textures I merge them and (at least do far) I check if they are of the same size.

Please resize the larger texture to 512x512.



I’ll try to make it automatically. But so far this is the only workaround.

ACTUALLY, THIS IS NOT GOOD, BECAUSE i bake a lightmap of entire scene. Lightmap is 1024x1024, but all other textures 512 or even 256. Is it possible not to merge textures?