. Load png files (external)

Hallo. Ich habe eine Frage. Ich benutze NetBeans.Ich habe JMonkeyEngine3.jar benutzt um mit jme zu arbeiten. Ich habe aber leider ein problem ! Ich möchte andere .png Datan von meine Festplatte laden. Beispiel :



mat1.setTexture(“m_ColorMap”, assetManager.loadTexture(“C:\Users\Haupt\terrain1.png”));



It is unfortunately always the following error message:



WARNUNG: Cannot locate resource: C:UsersHauptterrain1.png/F/MIP



I WANT load necessarily on C: . not "Textures/…

Can someone help me please?

Please have a look at the tutorials about asset loading. You have to register a locator.

Cheers,

Normen

Essentially its like this:

[java]

assetManager.registerLocator(“C:/Users/”, FileLocator.class);

mat1.setTexture(“m_ColorMap”, assetManager.loadTexture(“Hauptterrain1.png”));

[/java]

Hi,



I have just tried the same thing,

[java]

assetManager.registerLocator(“Textures/images/”, FileLocator.class);

mat1.setTexture(“m_ColorMap”, assetManager.loadTexture(“pix.png”));

[/java]



& it still isn’t working, I usually get



java.lang.IllegalArgumentException: Material parameter is not defined: m_ColorMap





What seems to be the problem, all images are in their correct directories located in the assets folder (the preferred JME default folders). The images folder is in the Textures folder which in turn can be found in the assets folder, please someone should help in regards to this matter been battling with it for almost 4 days… kind of getting irritated

Its called m_DiffuseMapin Lighting.j3md. Try using jMP to edit j3m files, its way easier and more obvious what to do.

fixed it…



I found out there are 2 ways of loading the texture

  1. you can declare the locator as suggested above but also
  2. you can load the texture without actually registering the locator



    as long as when you initialize the material to which the texture is to be set by using the appropriate path — “Common/MatDefs/Misc/SimpleTextured.j3md



    for example

    [java]

    Material mat = new Material( assetManager , “Common/MatDefs/Misc/SimpleTextured.j3md” );

    mat.setMaterial( "m_ColorMap , assetManager.loadTexture(“Textures/images/55.png”) );

    [/java]



    both ways work perfectly, most important is the path mentioned above in bold & italic… (it works for me perfectly - well unless am wrong)
1 Like

Yes, you should actually not need to register locators for each folder model but use a directory structure. One locator for an assets folder is fine (or just add the assets to the classpath in a jar or smth). Otherwise it might happen that you have two “hull.jpg” from two models that are both “the same” for the assetmanager although they reside in different folders.

Cheers,

Normen