NeoTextureLoader error

I’m trying to use NeoTextureLoader in my jme3 eclipse project



[java] assetManager.registerLocator("/", “com.jme3.texture.plugins.NeoTextureLocator”);

assetManager.registerLoader(“com.jme3.texture.plugins.NeoTextureLoader”,“tgr”);

NeoTextureKey nkey = new NeoTextureKey(“textures/wood.tgr”);

Texture tex=(Texture) assetManager.loadAsset(nkey);

[/java]



I get following error:



[java]7-nov-2010 20.46.31 com.jme3.asset.DesktopAssetManager loadAsset

AVVERTENZA: Error occured while loading resource materials/wood.tgr (Mipmaped) using NeoTextureLoader

7-nov-2010 20.46.31 com.jme3.app.Application handleError

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.jme3.asset.TextureKey.createClonedInstance(TextureKey.java:73)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:250)

at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:263)

at com.jme3.scene.plugins.ogre.MaterialLoader.readTextureImage(MaterialLoader.java:122)

at com.jme3.scene.plugins.ogre.MaterialLoader.readTextureUnitStatement(MaterialLoader.java:147)

at com.jme3.scene.plugins.ogre.MaterialLoader.readTextureUnit(MaterialLoader.java:183)

at com.jme3.scene.plugins.ogre.MaterialLoader.readPassStatement(MaterialLoader.java:221)

at com.jme3.scene.plugins.ogre.MaterialLoader.readPass(MaterialLoader.java:253)

at com.jme3.scene.plugins.ogre.MaterialLoader.readTechnique(MaterialLoader.java:270)

at com.jme3.scene.plugins.ogre.MaterialLoader.readMaterialStatement(MaterialLoader.java:277)

at com.jme3.scene.plugins.ogre.MaterialLoader.readMaterial(MaterialLoader.java:299)

at com.jme3.scene.plugins.ogre.MaterialLoader.load(MaterialLoader.java:365)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:224)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:254)

at it.F1Viewer3D.test.TestOgreLoading.simpleInitApp(TestOgreLoading.java:115)

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(Unknown Source)[/java]

If you want to load the NeoTexture as material you have to register the material loader, not the texture loader and locator:

[java]assetManager.registerLoader(“com.jme3.material.plugins.NeoTextureMaterialLoader”,“tgr”);[/java]

I’ve already followed the procedure you said loading NeoTexture as material without errors

I’ve read “Using tgr files like normal textures in j3m files” and I thought I could instantiate a Texture loading it by NeoTextureLoader and assigning it to a material

Well rtfm: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:jmonkeyplatform:neotexture

You can use the .tgr files like normal textures in j3m files, with a syntax like this: Materials/neoMaterial?m_DiffuseMap.tgr The part between the ? and the suffix is the name of the node you want to load as a texture. If you dont supply a name, texture is used.

To be able to load these textures, you have to register a Locator and a Loader in the AssetManager, note that you can only register one loader per extension so you cannot load .tgr files as materials and as textures with the same assetManager.

assetManager.registerLocator("/", "com.jme3.texture.plugins.NeoTextureLocator");
assetManager.registerLoader("com.jme3.texture.plugins.NeoTextureLoader","tgr");


Just set some texture in a j3m file to "Stuff/MyNeoTexture?m_NormalMap.tgr" or load the texture like assetManager.loadTexture("Stuff/MyNeoTexture?m_NormalMap.tgr").