setCharData for image init_from does not work


#1

Hello

I have a technical question regarding a problem with the colladadom.

I was navigating on the webpage and am not quite sure if this is the place to ask such a question. If it is not please tell me where should I ask it.

My problem is using the function setCharData() for a daeElement* of the type init_from.

So the code is declare an imagelib, then an image, then the init_from

daeElement* imageLib = root->add(“library_images”);
daeElement* image = imageLib->add(“image”);
image->setAttribute(“id”, “img”);
daeElement* init_from = image->add(“init_from”);

Then, I just use function setCharData to give the uri to the image file, called texture.bmp

init_from->setCharData("…/texture.bmp");

In the export.cpp, you have a similar more compacted example at line 194

image->add(“init_from”)->setCharData("…/texture.bmp");

The problem is that the setCharData does not work for the init_from (it works for other atributes, no problem). The xml file shows nothing in the init_from

<library_images>
<image id=“img” name=“myimage”>
<init_from/>
</image>
</library_images>

Since I know the function return a daeBool, I can do the following

printf(“result of adding char data %d
“, init_from->setCharData(”…/texture.bmp”))

And the result is 0 (it fails, this is why I don’t see anything in the xml)

Then I used the hasCharData function

printf("result of adding char data %d
", init_from->hasCharData())

And the result is 0 also, meaning that the atribute init_from does not allow charData as is suggested in the export example.

Can you help me with this problem?

Best regards

Miguel


#2

I am sorry but no one has answered this post.

Can somebody help me with this?

Its important for me.

Thank you

Miguel


#3

Hi Miguel,

why don’t you use oid setValue( const xsIDREF &val ) of the class domFx_surface_init_from_common_complexType?

It is uncommon to work on the base class daeElement, but to use the specialized classes. If you created the init_from class the way you, you can cast with daeSafeCast to domFx_surface_init_from_common_complexType. The cast should work because of the meta-class-system in the COLLADADOM.

Then you have to create an xsIDREF to your source file that can be set through setValue().

Hope this helps.

Steffen


#4

Hi Steffen

Thanks for the answer.

Is it possible to ask you for a little piece of code to exemplify the solution you suggest?

I mean, I am not a colladadom expert, the code I show is just from a colladadom example and it does not work.

Thanks

Miguel


#5

Hi Miguel,

daeDocument doc = …
domCOLLADA domRoot = daeSafeCast<domCOLLADA>( doc.getDomRoot() );
// creating the library
domLibrary_images
libImages = daeSafeCast<domLibrary_images>(domRoot->createAndPlace(COLLADA_ELEMENT_LIBRARY_IMAGES));

// and so on.
for every Element in the XSL there is a class in the COLLADADOM the represents all the methods for accessing and setting the data.

Regards
Steffen