I’m currently implementing COLLADA as our mid-format for developing assets for our next game, and i’m having a bit of a trouble, while trying to save an effect_instance tag trough COLLADA DOM. I use this simple bit of code:
The path is correct, but it won’t work if i rename or move the file, which is a big problem for me. I am trying to make the URI relative to the file name (i.e. the url to be just “#default”), but i don’t seem to find a way to do this. A collegue of mine hacked it a bit and replaced the setUrl code with:
Instance->setUrl ( uriEffect.getOriginalURI() );
and this really writes only the relative reference, but it also makes the next DAE::Load() to crash (i recreate the DAE Object on every save and load). Any ideas?
OK, i spent two weeks in trying to overcome my saving problems and i finally did it! First of all i’d like to ask which is the right way to create a reference for the file i’m currently saving. I.e. just “#default” except of “file:///C:\Documents%20and%20Settings\hacy\Desktop\material_test_8.dae#default”? I did it like this:
daeURI effect ( "#default" );
as this seems to work. Thou the above URI can’t be resolved by the save and i’m pretty sure it can lead to a problem at a later stage.
Still i found out a lot of things that hasn’t been added to any documentation and created a lot of problems when i tryed to do a complex loader. I currently have two arrays that keep my strings for the IDs and URIs until i call DAE::save() and clears them after that because the DOM doesn’t copy their data in it’s internal memory, but just keeps a reference to the memory i have allocated to generate them. Plus calling DAE::unload() doesn’t free the memory i have used to create my DOM model in the RAM and i end up with a ton of memory leaks. Having to keep my URIs and IDs isn’t such a problem, but having the memory leaks really gets me frustrated. Which is the right way to unload a collection? DAE::unload() and at the end of my program DAE::cleanup()? Or am i missing something?