Hi,
I was following the tutorials on how to load assets. I am using maya with ogremax to export my scene as .mesh.xml and .material. The 3d object loaded:
Spatial sea_turtle = assetManager.loadModel(“Models/polySurface1/polySurface1.j3o”);
but the materials did not. I tried several loading options:
// Material mat_seaTurtle = new Material(assetManager, “Materials/Sea_Turtle.material”);
// mat_seaTurtle.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/test.png”));
sea_turtle.setMaterial( (Material) assetManager.loadAsset(new AssetKey(“MatDefs/Sea_Turtle.j3md”)));
I tried renaming my .material to .j3m and .j3md
but when I ran my program it terminates right away.
May 29, 2011 4:55:37 AM com.jme3.asset.DesktopAssetManager loadAsset
WARNING: Failed to load resource: MatDefs/Sea_Turtle.j3md
java.io.IOException: Specified file is not a Material file
at com.jme3.material.plugins.J3MLoader.loadFromScanner(J3MLoader.java:515)
at com.jme3.material.plugins.J3MLoader.load(J3MLoader.java:590)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:224)
at mygame.HelloAssets.simpleInitApp(HelloAssets.java:29)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:186)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:134)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:183)
at java.lang.Thread.run(Thread.java:662)
May 29, 2011 4:55:37 AM com.jme3.asset.DesktopAssetManager loadAsset
WARNING: Error occured while loading resource MatDefs/Sea_Turtle.j3md using J3MLoader
May 29, 2011 4:55:37 AM com.jme3.scene.Node attachChild
INFO: Child (polySurface1-ogremesh) attached to this node (Root Node)
May 29, 2011 4:55:37 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalStateException: No material is set for Geometry: polySurface1-geom-1
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:476)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:462)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:462)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:655)
at com.jme3.renderer.RenderManager.render(RenderManager.java:684)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:216)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:141)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:198)
at java.lang.Thread.run(Thread.java:662)
How do I change this so that it loads properly?
Thanks
When I set the material to:
// Material mat_seaTurtle = new Material(assetManager, “Materials/Sea_Turtle.material”);
// mat_seaTurtle.setTexture(“ColorMap”, assetManager.loadTexture(“Materials/test.png”));
sea_turtle.setMaterial( (Material) assetManager.loadAsset(new AssetKey(“MatDefs/Sea_Turtle.material”)));
May 29, 2011 11:02:50 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.ClassCastException: com.jme3.material.MaterialList cannot be cast to com.jme3.material.Material
I guess this is the final error that i get.
Can someone help me please?
Name your .material file the same as your mesh.xml file, then convert your mesh xml to j3o.
j3m and j3md are jME3 material and material definitions files, .material files are ogre material structure, we support import from it but it’s not the preferred material format for the engine.
for more information on j3m and j3md see the material section in the documentation https://wiki.jmonkeyengine.org/legacy/doku.php/jme3#tutorials_for_beginners
ok I am doing this the j3m way.
Material mat_seaTurtle = new Material(assetManager, “Materials/LeakThrough.j3m”);
// mat_seaTurtle.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/test.png”));
// sea_turtle.setMaterial(mat_seaTurtle);
sea_turtle.setMaterial( (Material) assetManager.loadAsset(new AssetKey(“Materials/LeakThrough.j3m”)));
LeakThrough.j3m is the one i followed in the Hello_Materials section
Here is my definition basically:
Material My Material : Common/MatDefs/Misc/SolidColor.j3md {
MaterialParameters {
m_GlowMap : Textures/test.png
m_GlowColor : 1.0 0.8 0.2 1.0
}
}
When I run it I get this error:
May 29, 2011 11:50:36 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.ClassCastException: com.jme3.material.Material cannot be cast to com.jme3.material.MaterialDef
Should I upgrade to alpha4? I am using alpha3
Thanks
fixed it:
Material mat_seaTurtle = new Material(assetManager, “Common/MatDefs/Misc/ColoredTextured.j3md”);
mat_seaTurtle.setTexture(“m_Color”, assetManager.loadTexture(“Textures/test.png”));
sea_turtle.setMaterial(mat_seaTurtle);
just wondering why I could not use a material j3m to mat_seaTurtle as my material?
It says an error cannot cast type Material to MaterialDef or something?
Where can I get more material definitions?
my model needs more shading.
It can use j3m i got to use this line though
sea_turtle.setMaterial( (Material) assetManager.loadAsset(“Materials/LeakThrough.j3m”));
Well you got it
you have to load the j3m with the asset manager.