Problem with daeDatabase::typeLookup

Hi,

I was using daeDatabase::getElementCount and daeDatabase::getElement to retrieve all instance_material elements, it used to work, but now it returns no matches even though there are instance_material elements in the document.

I checked the daeDatabase header and found out the two methods are deprecated, to use daeDatabase::typeLookup instead, so I change the code to do so, however I still get zero hits, I tried this:


std::vector<daeElement*> instance_material_vector;		dae.getDatabase()->typeLookup(COLLADA_TYPE::INSTANCE_MATERIAL,instance_material_vector,NULL);

as well as this:


std::vector<daeElement*> instance_material_vector;				dae.getDatabase()->typeLookup(COLLADA_TYPE::INSTANCE_MATERIAL,instance_material_vector,dae.getDoc(argv[1]));

both return zero items in instance_material_vector, any ideas? am I missing something?

Also, I was using daeURI::setElement and daeURI::resolveURI to change what an instance_material pointed to, but those where removed, whats the workaround?

Thanks.

I was using daeDatabase::getElementCount and daeDatabase::getElement to retrieve all instance_material elements, it used to work, but now it returns no matches even though there are instance_material elements in the document.
Ouch. Even though those methods are deprecated, they should still work properly. I’ll look into it.

Use domElement::ID() to get a particular element’s type ID. These IDs are different from the COLLADA_TYPE IDs, which are no longer used due to some uniqueness problems.

Alright!


dae.getDatabase()->typeLookup(domInstance_material::ID(),instance_material_vector,dae.getDoc(argv[1]));

Does work, now I just need to see if the workaround for daeURI::setElement and daeURI::resolveURI I wrote works, basically:


daeURI uri(dae,mat1->getID());
instance_material->setTarget(mat1->getID());

Thanks.

Update: Nope, doesn’t work, what I need is a daeURI to an element I have the pointer for, daeURI::setElement and daeURI::resolveURI did the job, but how do you do it now?

Sorry, forgot to reply to that part of your post.

daeURI uri(dae, string("#") + element->getAttribute(“id”));

Looks like you just forgot the ‘#’.

I was using daeDatabase::getElementCount and daeDatabase::getElement to retrieve all instance_material elements, it used to work, but now it returns no matches even though there are instance_material elements in the document.
This seems to work fine for me. In fact I already have an automated test in domTest called databaseLookup that checks to make sure the daeDatabase::getElement and daeDatabase::getElementCount functions still work properly.

I wrote some new code to check <instance_material> specifically.

CheckResult(database.getElementCount(NULL, "instance_material") != 0);
daeElement* elt;
database.getElement(&elt, NULL, NULL, "instance_material");
CheckResult(elt);

This code works fine. Let me know if you have some more info about how to reproduce the problem.

prepending “#” works, thanks.

I have already changed the code to use typeLookup, but I may have other calls for the old code in there somewhere, if it resurfaces I’ll see what I can find.

This is the call I was using which was returning 0:


daeInt instance_material_count = dae.getDatabase()->getElementCount(0,"instance_material",argv[1]);

It could be that MSVC sets NULL to 0xcccccccc for debug builds if I am not mistaken, and since I was using 0, this could be it, I think I might had been using the release build when using 1.4.

That means URIs must be assembled by hand which is error prone. What when the referenced element is in a different file? That case was handled automatically by the old daeURI::setElement.

http://collada.org/mediawiki/index.php/ … RI_Strings

This page still uses the old:
setElement()
resolveURI()