Refresh Imported Assets

I am attempting to create a display for a bunch of meteorological data. The data is read from a web server and I want to use graphs to display it. I have JFreeChart working to create graphs, and it is dumping renders of the data to .png files. I am currently loading the .png into a material and displaying it on a quad; which is working quite well. The issue I have is that my separate java application will read and update the image files every time new data appears, and I cannot figure out how to make Jmonkey reload an asset. the “assetManager” is designed to prevent you from loading to same asset twice, but how can I get around this?

This was my attempt as loading an image directly:

File f = new File(“assets\Scenes\GraphTest\saved3.png”);
Texture t = assetManager.loadTexture(“Scenes/GraphTest/saved3.png”);
Image I = new Image();
try{; //This Line Doesnot work.
System.out.println(“Worked”); // quick debug
}catch(Exception e){
System.out.println(“Read Error”); // quick debut
Material m = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
m.setTexture(“DiffuseMap”, t);

The file is addressed correctly I am just not sure how to load it into a JME style Image? Should I be using Image.setData() ? or is there a completely different way to go about this?

This just a guess, but you can try releasing the texture cache with DesktopAssetManager.deleteCache(AssestKey key)

I really don’t know how to go about that, can you give me some clarification as to what the DesktopAssetManager is and how it relates to that assetManager from the SimpleApplication?

It is one, you can cast it like this:
DesktopAssetManager mgr = (DesktopAssetManager) assetManager;

I tried this:

((DesktopAssetManager)assetManager).deleteFromCache(new AssetKey("Scenes/GraphTest/Graph2.j3m")); rootNode.getChild("Graph").setMaterial(assetManager.loadMaterial("Scenes/GraphTest/Graph2.j3m"));

But it had no effect. Any ideas? Thanks so much for the help!

Well this way you only delete the buffered material and not the texture. You have to delete that.

When you create a texture in OpenGL, it stores it in memory, and returns an id, which you can then use to reference that same texture. When you create your texture in the first place, save that to a texture key and apply to the model, and then later remove that same texture key when u want to add another, and see if that works.

You might have to do other stuff idk