Results 1 to 8 of 8

Thread: Problem with daeDatabase::typeLookup

  1. #1
    Member
    Join Date
    Dec 2007
    Location
    Costa Rica
    Posts
    42

    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:

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

    as well as this:
    Code :
    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.

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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.

  3. #3
    Member
    Join Date
    Dec 2007
    Location
    Costa Rica
    Posts
    42
    Alright!

    Code :
    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:

    Code :
    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?

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Sorry, forgot to reply to that part of your post.

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

    Looks like you just forgot the '#'.

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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.
    Code :
    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.

  6. #6
    Member
    Join Date
    Dec 2007
    Location
    Costa Rica
    Posts
    42
    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:

    Code :
    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.

  7. #7
    kex347
    Guest
    Quote Originally Posted by sthomas
    Sorry, forgot to reply to that part of your post.

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

    Looks like you just forgot the '#'.
    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.

  8. #8
    kex347
    Guest
    http://collada.org/mediawiki/index.php/ ... RI_Strings

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •