This works when my assets are all unpacked. But if I have some assets packed into assets.jar, and others on a separate folder that might or might not be present (read: dlc) then I get this:
java.lang.IllegalArgumentException: Given root path "C:\path\assets"
is not a directory
at com.jme3.asset.plugins.FileLocator.setRootPath(FileLocator.java:54)
at com.jme3.asset.ImplHandler$ImplThreadLocal.initialValue(ImplHandler.j
ava:120)
at java.lang.ThreadLocal.setInitialValue(Unknown Source)
at java.lang.ThreadLocal.get(Unknown Source)
at com.jme3.asset.ImplHandler.tryLocate(ImplHandler.java:178)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java
:360)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.ja
va:391)
at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.ja
va:401)
I’ve shortened for simplicity; it was c:\mygame\lib\assets\
basically: the path where the game is currently installed and running + “lib\assets”. So this is where usually all the assets reside, which is right. However, it is a .JAR file (and is missing the extension as well) and not a folder, hence the error.
Which brings the question: If I register an AssetLocator with FileLocator, why does the assetloader use the FileLocator for the assets.jar?
There’s a bug, either on my code or JME
Different Locators aren’t supposed to be mixed within the same assetLoader
If you are just loading your own random format, there is no strong reason to use the AssetManager at all unless you really want to implement all of the SmartCache stuff.
I load files all the time that having nothing to do with JME. I generally just use a URL/URI in my actual loader routines so that I can load from the classpath or file or whatever I want.
so main advantage of assetLoader is just “SmartCache” , quick access to assets and optimize to send to OpenGL, right?
so some “assets” like saves/etc even should not be loaded via assetLoader to save memory and not hold data in cache all the time.
If use assetManager to load Mod, it will cache custom format/etc files so memory usage will be bigger until user clear it, while GC could just clean it some time after loading if just use “File” and read what is needed.
While im not sure how much important is “optimizes the handling of OpenGL objects”, i belive Textures and Models should always be loaded via assetManager? here i dont for saves, where i also save alphamaps of terrains, should i use assetManager here somehow? (please note this textures are in JAR along with other files)
If i could i would like ask one more question:
when i know that some asset cached in assetManager will be no longer used(once it already were send to OpenGL buffer), should i clean cache from assetManager to optimize memory?
DLC is different. It will be there at compile time but may not be at runtime.
Loading jars that may or may not exist in a DLC directory is essentially a plugin. If the jar exists then it should be injected into the class path at runtime.
This type of architecture is beyond JME scope. It’s a plugin system.
Edit: don’t know why this turned up at the top of the new replies list. Sorry for the graveyard dig.