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:
domEffect* Effect = (domEffect*) EffectLibrary->createAndPlace(COLLADA_ELEMENT_EFFECT);
and later on i do this:
domInstance_effect* Instance = (domInstance_effect*) Material->createAndPlace(COLLADA_ELEMENT_INSTANCE_EFFECT);
Instance->setUrl ( uriEffect );
Everything works as expected, thou in the COLLADA file i save, i get something like this:
<material id="1" name="1">
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?
btw, the call stack on the DAE::Load () crash is:
COLLADATest.exe!safeCreate() + 0x15 bytes
COLLADATest.exe!daeURI::validate() + 0x2dc bytes
COLLADATest.exe!daeURI::resolveElement() + 0x23 bytes
COLLADATest.exe!daeResolverType::resolve() + 0x3f bytes
COLLADATest.exe!daeMetaAttribute::resolve() + 0x5f bytes
COLLADATest.exe!daeElement::resolveAll() + 0xb9 bytes
COLLADATest.exe!daeLIBXMLPlugin::read() + 0x141 bytes
I was unable to build and turn on the debug mode on the COLLADA DOM to trace the error to the specific C++ line of code.
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?
COLLADA DOM bugs should be reported to the project’s bug tracker.
COLLADA DOM Bug Tracker