Just wondering what the best way of reloading assets would be, if they were marked as dirty while the game / application was running. Ideally I would like to have a model rendered in the viewport update to the latest version on disk once a change is detected.
I’m assuming there will be no native solution to this and that I’ll have to keep track of all models / filepaths in the scene myself. I’m a bit confused about how reloading an egg will be, as I seem to remember loading the same model on disk uses the cached bam version. Is there a way to empty the cache so I can reload the modified assets?
For reloading a model you can simply use loader.loadModel(“modelname.egg”, noCache=True) (see api)
For finding out what file changed there exist a few solutions, most of them being OS dependant. Watchdog, however, seems to work cross-plattform and has a nice API. I’ve never used it myself yet, but the linked site provides examples.
Is there any way in Panda to replace the geometry in one NodePath with another? Once I have my directory watcher set up and the change in the model is detected and loaded, I need to replace the assets in the scene. Some of these assets have tags, colours, etc. Would the easiest way to replace the mesh be something like:
oldNodePath.node().combineGeomsWith( newNodePath.node().getGeoms() )
Do you want this technique to be appliable to any 3d model?
If it is only about specific types of NodePaths, you could use an empty proxy NodePath. That empty NP is then used for positioning, rendering attributes, tags etc. and the actual geometry holding NP is its child. This way you can freely replace the geometry at any time by only removing the old node and loading up a new using loader.loadModel.
Alternatively you can exchange the Geom Nodes only, but since models can contain whole hierarchies, this might result in unexpected behaviour and will only work for simple one-part static models.
I like the idea of using a proxy NodePath. That would be ideal except that I would like to keep the scene hierarchy as close to the final game as possible since I want to implement it for my scene editor. Does the ModelRoot node contain any geometry? Can I not just disconnect all NodePaths under the ModelRoot, then reparent the new version’s children to it? Would that work?
Sorry for the double post, but also how what I live update textures on a model? Will simply reloading the model work or do I have to drill down to the textures used on the model and call some sort of reload method?