Hi all.
I have a problem with tinyXML, I have used tinyXML many times before, but this is the first time I have encountered this problem. the problem is a runtime error.
This is a snippet of the code
//****************get animation data************
//go to library_animation
TiXmlElement *elmLibrary_animation=0;
elmLibrary_animation=RootNode->FirstChildElement("library_animations");
//spinn through the library_animations to get each animaton element
int numberofanimationelm=0;
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
node = elmLibrary_animation;
todoElement = node->ToElement();
for( node = todoElement->FirstChild( "animation" ); node; node = node->NextSibling( "animation" ) )
{
TiXmlElement* tmpElm;
tmpElm=node->ToElement();
SceneGraphAnimations[numberofanimationelm].id=tmpElm->Attribute("id");
//for each animation, spinn throgh sources
int numberofsources=0;
TiXmlNode* sourcenode=0;
TiXmlElement* todoSourceElement=0;
sourcenode=tmpElm;
todoSourceElement=sourcenode->ToElement();
the program breaks at the line
SceneGraphAnimations[numberofanimationelm].id=tmpElm->Attribute("id");
SceneGraphAnimations is defined as
animation *SceneGraphAnimations;
"animation" is
typedef struct
{
const char* id;
int numberofsources;
int numberofsamples;
int numberofchannels;
anim_source *sources;
anim_sampler *samples;
anim_channels *channels;
int numberof_Sources;
int numberof_Samples;
int numberof_Channels;
}animation;
If I comment out the line SceneGraphAnimations[numberofanimationelm].id=tmpElm->Attribute("id");
the app breaks at other places in the code like this one
//for each animation, spinn throgh sources
int numberofsources=0;
TiXmlNode* sourcenode=0;
TiXmlElement* todoSourceElement=0;
sourcenode=tmpElm;
todoSourceElement=sourcenode->ToElement();
for (sourcenode=todoSourceElement->FirstChild("source");sourcenode;sourcenode=sourcenode->NextSibling("source"))
{
TiXmlElement* tmpSourceElm=0;
tmpSourceElm=sourcenode->ToElement();
SceneGraphAnimations[numberofanimationelm].sources[numberofsources].id=tmpSourceElm->Attribute("id");
Here is a snippet from the XML file (it is a Collada dae file).
<library_animations>
<animation id="camera1.translate">
<source id="camera1.translate_camera1_translate.X-input">
<float_array id="camera1.translate_camera1_translate.X-input-array" count="14">.......</float_array>
<technique_common>
<accessor source="#camera1.translate_camera1_translate.X-input-array" count="14" stride="1">
<param name="TIME" type="float"/>
</accessor>
</technique_common>
<technique profile="MAYA">
<pre_infinity>CONSTANT</pre_infinity>
<post_infinity>CONSTANT</post_infinity>
</technique>
</source>
I would really appriciate any help, tips or tricks.