vivienneanthony
Hi
I’m trying to transfer a xml with nodes into the scene. I have to parse through each element because I have to add each node invidiually.
I created the following code but I think I’m doing something wrong. Most definitely.
Vivienne
[code]/// Load account information from a account file
int Manager::LoadManagedNodes(const char *filename)
{
/// Grab resources
ResourceCache * cache = GetSubsystem<ResourceCache>();
FileSystem * filesystem = GetSubsystem<FileSystem>();
/// Check if scene exist
if(scene_==NULL)
{
return 1;
}
/// Force .xml on Load
if(!string(filename).find(".xml"))
{
return 0;
}
/// Create String
String Loadsceneexport;
/// Set directory
Loadsceneexport.Append(filesystem->GetProgramDir().CString());
Loadsceneexport.Append("/");
Loadsceneexport.Append(filename);
XMLFile * loadingfile = new XMLFile(context_);
/// Create a file in current context
File LoadFile(context_, Loadsceneexport.CString(), FILE_READ);
loadingfile->Load(LoadFile);
XMLElement nextElement = loadingfile -> GetRoot().GetChild("node");
do
{
if(nextElement==0)
{
break;
}
/// Create pointer
Node * newNode;
newNode -> LoadXML (nextElement, false);
scene_->AddChild(newNode);
/// push
ManagedNodes.Push(newNode);
cout << newNode -> GetID() <<endl;
nextElement=nextElement.GetNext("node");
} while(nextElement!=NULL);
return 1;
}
[/code]