Results 1 to 2 of 2

Thread: Problem writting char data

  1. #1
    Gustavo Puche
    Guest

    Problem writting char data

    Hello guys, Can someone help me?
    I am developping a COLLADA 1.5 exporter to OpenRAVE (Robot simulator) and I have some troubles to achieve this. The problem is that I wish to write down some sensor features and I want to use the setCharData method of the daeElement class to store this info.But I don't know how to activate the char data. I have seen that there is a hasCharData method that indicates that the object has char data. In my case It is always false. Here there is a sample of the source that I am writting:

    sensor->getMeta()->setAllowsAny(true);
    domInstance_sensorRef element = daeSafeCast<domInstance_sensor>(domInstance_sensor ::create(*_collada.get()));
    element->setElementName("Elemento");
    element->setCharData(string("15.5"));
    sensor->getContents().append(element);

    for (size_t i = 0; i < sensor->getContents().getCount(); i++)
    {
    if (sensor->getContents()[i]->hasCharData())
    {
    RAVELOG_DEBUGA("Has Char Data\n");
    }
    else
    {
    RAVELOG_DEBUGA("Doesn't have Char Data\n");
    }

    RAVELOG_WARNA("Content %d Type ID %d Name %s:%s\n",
    i,
    sensor->getContents()[i]->typeID(),
    sensor->getContents()[i]->getElementName(),
    sensor->getContents()[i]->getCharData().c_str());
    }

    It always appears the message "Doesn't have Char Data\n" because the char data it is not allowed.

    Any help good be wellcome...

    Best regards

  2. #2
    Gustavo Puche
    Guest

    Solved: Problem writting char data

    I have found the solution to the problem with write parameters that are not part of the COLLADA specification. I write down the solution for help someone that will have the same problem.

    // Gets the meta element of the parent tag that will contain the parameter
    // sensor is the tag that represents a robot sensor

    daeMetaElement* meta = sensor->getMeta();

    // Allows to insert a parameter not present in the COLLADA specifications
    meta->setAllowsAny(true);

    // Adds sensor param to the COLLADA document
    // 'param_name' is a const char* variable that contains the name of the param
    // 'str_param_value' is a std::string variable that contains the value of the param

    sensor->add(meta->create('param_name'))->setCharData('str_param_value');

    I hope that this may be useful to someone

Posting Permissions

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