Can't figure out how to use .material

Hi guys,

I’m slowly learning Java, and i got a problem here. google didn’t helped… and the forum neither.

juin 19, 2013 10:55:13 AM com.jme3.system.JmeDesktopSystem initialize INFO: Running on jMonkeyEngine 3.0.0 Beta juin 19, 2013 10:55:13 AM com.jme3.system.Natives extractNativeLibs INFO: Extraction Directory: C:\Users\weblab\Documents\florian_test\florian_test5 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run INFO: Using LWJGL 2.8.4 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglDisplay createContext INFO: Selected display mode: 640 x 480 x 0 @0Hz juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Adapter: aticfx64 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Driver Version: 8.17.10.1036 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Vendor: ATI Technologies Inc. juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: OpenGL Version: 4.0.10061 Compatibility Profile Context juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: Renderer: ATI Radeon HD 5670 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo INFO: GLSL Ver: 4.00 juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglTimer <init> INFO: Timer resolution: 1 000 ticks per second juin 19, 2013 10:55:13 AM com.jme3.renderer.lwjgl.LwjglRenderer initialize INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, TextureMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, OpenGL32, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray, Multisample, PackedDepthStencilBuffer] juin 19, 2013 10:55:13 AM com.jme3.asset.AssetConfig loadText WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader juin 19, 2013 10:55:13 AM com.jme3.asset.DesktopAssetManager <init> INFO: DesktopAssetManager created. juin 19, 2013 10:55:13 AM com.jme3.renderer.Camera <init> INFO: Camera created (W: 640, H: 480) juin 19, 2013 10:55:13 AM com.jme3.renderer.Camera <init> INFO: Camera created (W: 640, H: 480) juin 19, 2013 10:55:13 AM com.jme3.input.lwjgl.LwjglMouseInput initialize INFO: Mouse created. juin 19, 2013 10:55:13 AM com.jme3.input.lwjgl.LwjglKeyInput initialize INFO: Keyboard created. juin 19, 2013 10:55:13 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: AudioRenderer supports 64 channels juin 19, 2013 10:55:13 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: Audio effect extension version: 1.0 juin 19, 2013 10:55:13 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread INFO: Audio max auxilary sends: 4 juin 19, 2013 10:55:13 AM com.jme3.material.MaterialDef <init> INFO: Loaded material definition: Unshaded juin 19, 2013 10:55:13 AM com.jme3.scene.Node attachChild INFO: Child (BitmapFont) attached to this node (null) juin 19, 2013 10:55:13 AM com.jme3.material.MaterialDef <init> INFO: Loaded material definition: Phong Lighting juin 19, 2013 10:55:13 AM com.jme3.app.Application handleError SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] com.jme3.asset.AssetNotFoundException: Materials/material_corps.material (Flipped) (Mipmapped) at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:278) at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:341) at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:351) at mygame2.HelloAssets2.simpleInitApp(HelloAssets2.java:26) at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225) at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207) at java.lang.Thread.run(Thread.java:722)

juin 19, 2013 10:55:13 AM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
juin 19, 2013 10:55:13 AM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
juin 19, 2013 10:55:13 AM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
juin 19, 2013 10:55:13 AM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
BUILD SUCCESSFUL (total time: 13 seconds) </quoteblock>

Here’s my code. Made with the Hello Assets, i only changed to use my meshs/textures/materials :slight_smile:

[java]package mygame2 ;

import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.texture.Texture;

/** Sample 3 - how to load an OBJ model, and OgreXML model,

  • a material/texture, or text. */
    public class HelloAssets2 extends SimpleApplication {

    public static void main(String args) {
    HelloAssets2 app = new HelloAssets2();
    app.start();
    }

    @Override
    public void simpleInitApp() {
    Spatial corps = assetManager.loadModel(“Models/CORPS.j3o”);
    corps.scale(0.5f, 0.5f, 0.5f);
    corps.rotate(0.0f, 90.0f, 0.0f) ;
    Material mat_corps = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
    Texture tex_ml = assetManager.loadTexture(“Materials/material_corps.material”);
    mat_corps.setTexture(“ColorMap”, tex_ml);
    corps.setMaterial(mat_corps) ;
    rootNode.attachChild(corps);

     // Create a wall with a simple texture from test_data
    

    Spatial teapot23 = assetManager.loadModel(“Models/Teapot.obj”);
    teapot23.scale(0.05f, 0.05f, 0.05f);
    Material mat_brick = new Material(
    assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
    mat_brick.setTexture(“ColorMap”,
    assetManager.loadTexture(“Textures/BrickWall.jpg”));
    teapot23.setMaterial(mat_brick);
    teapot23.setLocalTranslation(2.0f,-2.5f,0.0f);
    rootNode.attachChild(teapot23);

    // rootNode.attachChild("pivot");
     // You must add a light to make the model visible
     DirectionalLight sun = new DirectionalLight();
     sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
     rootNode.addLight(sun);
    

    }
    }[/java]

Sorry for double posting : i think the problem comes from,

"SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] com.jme3.asset.AssetNotFoundException: Materials/material_corps.material (Flipped) (Mipmapped)"

That’s why i said google can’t help.

Read what it says AssetNotFoundException

So that probably means it can’t find an asset?

And it even tells you what material it was trying to find…

Are you sure it’s .material…normally I’d expect it to be .j3m… ?

Well it’s .material, and, i can’t right-click/convert it.

Try adding
[java]assetManager.registerLocator(“assets”, FileLocator.class);[/java]
Before you load any assets, presuming that your assets is located in that folder.

Also I dont know if .material can be loaded as a texture.

Did you convert your object to j3o? In that case it usually converts it along with the material attached to it.

Perfecticus, where should i add this line ? I tryed severals places, and it tells me it’s not good…

The problem comes from this i think, cause it works when i put it in comments.

[java] @Override
public void simpleInitApp() {
Spatial corps = assetManager.loadModel(“Models/CORPS.j3o”);
corps.scale(0.5f, 0.5f, 0.5f);
corps.rotate(0.0f, 90.0f, 0.0f) ;
Material mat_corps = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
Texture tex_ml = assetManager.loadTexture(“Materials/material_corps.material”);
mat_corps.setTexture(“ColorMap”, tex_ml);
corps.setMaterial(mat_corps) ;
rootNode.attachChild(corps);[/java]