ezpstmb
February 13, 2019, 6:57am
1
I can clear cache for Model and Texture , When I clear Material Cache Always return null?
//clear Model cache code:
Spatial model = assetManager.loadModel(“XXXXX.j3o”);
assetManager.deleteFromCache((ModelKey) model.getKey());
//clear Texture cache code:
Geometry geometry = (Geometry) spatial;
AssetKey key=geometry.getMaterial().getTextureParam(“DiffuseMap”).getTextureValue().getKey();
if (key != null && assetManager.getFromCache(key) != null) {
assetManager.deleteFromCache(key);
}
But I use " geometry.getMaterial().getKey() " function, Always return null,
How can i do?
My English is a little weak, please don’t mind.
pspeed
February 13, 2019, 7:57am
2
Did you load a j3m?
…else that material did not come from the asset manager.
What is it that you are actually trying to do?
ezpstmb
February 13, 2019, 3:41pm
3
I have two different ogre format file.
The *.material file almost the same,
The only difference is Texture.
I try the following
Spatial model = assetManager.loadModel(modelPath);
BinaryExporter exporter = BinaryExporter.getInstance();
String spatialName = modelPath.substring(0, modelPath.lastIndexOf("."));
File j3ofile = new File(spatialName.concat(".j3o"));
exporter.save(model , j3ofile);
First j3o file is Ok,But the second j3o file is the first material data.
oxplay2
February 13, 2019, 4:24pm
5
if it would be about loading, then i would say why not just change texture.
but i read your below code and i see you want to export into j3o (that i do via SDK myself)
in this case i would say: can’t you look at SDK sourcecode and see how its done there?
ezpstmb
February 14, 2019, 1:25am
6
I know, I can call clearCache() function,Is rigth.
But i don’t want to do it.
Because total cache will be released, I just want to clear the last cache.
pspeed
February 14, 2019, 2:22am
7
If that’s true then the loaded object also had the wrong values. Check it in code.
…no amount of cache clearing is going to fix that as the Material is instantiated at runtime and it’s parameters set. It was not “cached”.
ezpstmb
February 14, 2019, 3:21am
9
I have compiled the example.
In this example, I call clearCache() function can be solved the problem.