Register locator?

Maybe I’m doing something wrong but the same code that worked for me in JME3.0 isn’t working JME3.1(beta).

I’m trying to load a model from a custom path.

 app.getAssetManager().registerLocator(window.fileDirectory, FileLocator.class);

 node = (Node)app.getAssetManager().loadModel(filePath);

fileDirectory = C:\Users\april\Documents\jmonkeyprojects3_1\Interface_Editor\assets\Interface

filePath = C:\Users\april\Documents\jmonkeyprojects3_1\Interface_Editor\assets\Interface\test.j3o

I tried manually entering the paths to be sure it was done right and still no success.

I get this error - com.jme3.asset.AssetNotFoundException: C:\Users\april\Documents\jmonkeyprojects3_1\Interface_Editor\assets\Interface\test.j3o

Any clues to what is wrong ?

My guess is then you are loading “Interface/test.j3o”? How many interface subdirectories do you have?

Just the one default interface directory that comes with the project. Loading works fine with the registered directories.

Yes… then so if you try to load “Interface/test.j3o” then what path will you suppose it will construct against that root?

It doesn’t matter what folder the file is in I get the same error. I already tried moving it around registering different folders.

fileDirectory + filePath == REAL file path.

your fileDirectory:
your real file path:

Then your model path should be:

I suggest you register this directory:

And load your model with this path:

Okay that seems to be working. What if the user is loading multiple models from a directory with many sub directories ? How would the asset manager know which one is the default one to search in ? Would it be best to register a directory each load then unregister it immediately after wards ?

FileLocater won’t automatic search models for you, you MUST tell assetManager the model’s path.

for me, I have hero and monster folder under Models folder, such as:
F:\My Asset\Models\hero\sunny.3ds
F:\My Asset\Models\Monster\death_knight\dk.j3o
F:\My Asset\Textures…
F:\My Asset\Sky…

I register the filedirectory “F:\My Asset” to assetManager with FileLocater.class, and load my model with these path:


When I release this game I while pack everything under “F:\My Asset” into a zip or jar file, and I have no need to change any model’s path.