OK,
This is what I have so far. At the moment all the object does is load a scene or number of scenes. This is not a Tutorial but I am just showing you what I have done so I know if I should continue with it or not.
This is the xml file that stored my scenes. I place it in the Content/Scene folder off the Demo assembly and named it TestScene.xml.
<?xml version="1.0" encoding="utf-8" ?>
<sceneManager name="TestScene" sceneCount="1">
<shaders>
<shader id="0" name="BasicShader" asset="Content/Shaders/BasicShader"/>
<shader id="1" name="TrandformTexture" asset="Content/Shaders/TransformTexture"/>
</shaders>
<skyboxs skyboxCount="1">
<skybox id="0" name="MountainLake"
front="Content/Textures/Skybox/MountainLake/front"
back="Content/Textures/Skybox/MountainLake/back"
left="Content/Textures/Skybox/MountainLake/left"
right="Content/Textures/Skybox/MountainLake/right"
top="Content/Textures/Skybox/MountainLake/top"
bottom="Content/Textures/Skybox/MountainLake/bottom"/>
</skyboxs>
<models modelCount="2">
<model id="0" name="skull" asset="Content/Models/skullocc" specularPower="16">
<ambientLight red="1" green="1" blue="0" alpha="1"/>
<diffuseColor red="1" green="0.8431373" blue="0" alpha="1"/>
</model>
<model id="1" name="tiger" asset="Content/Models/tiger" specularPower="16">
<ambientLight red="1" green="0" blue="0" alpha="1"/>
<diffuseColor red="0" green="0" blue="1" alpha="1"/>
</model>
</models>
<scene id="0" name="Scene1" maxX="1000" minX="-1000" maxY="1000" minY="-1000" maxZ="1000" minZ="-1000">
<skybox id="0" name="MountainLake" scalingX="9999" scalingY="9999" scalingZ="9999" offsetXYZ="0.5" shader="TrandformTexture"/>
<models>
<model id="0" name="skull" positionX="0.5" positionY="0" positionZ="0" rotationX="0" rotationY="0" rotationZ="1" scalingX="0.5" scalingY="0.5" scalingZ="0.5" shader="BasicShader"/>
<model id="1" name="skull2" positionX="5" positionY="0" positionZ="0" rotationX="0" rotationY="0" rotationZ="1" scalingX="2" scalingY="2" scalingZ="2" shader="TrandformTexture"/>
</models>
</scene>
</sceneManager>
I have put name and id attributes on most elements so later I can access them in there respective object arrays buy either method. They are not fully implemented yet though.
The top level element (root) is the sceneManager element, this has a name to identify it as you never know you may have multiple SceneManager objects in the future. It also has a scene count as we are storing the scenes in a simple array at the moment and not in something like an array list so this tells my SceneLoader how many scenes to load.
Then we have four areas of interest, the <shaders/>, <skyboxes/>, <models/> and <scene/> objects . <shaders/> holds ALL the shaders to be used in ALL the scenes loaded into this SceneManager, the same goes for <skyboxes/> and <models/>. <scene/> holds all the objects and a skybox to be used in a given scene and the skybox and models are references to the instances in the previous elements (<skyboxes/>, <models/> etc...)
Here is the SceneLoader class (replace my RC objects with your notation, in the case of the tutorial here replace with HM)
[EDIT]
Forgot to add that you need the following in your Scene source file:
using System.Xml;
using System.Xml.XPath;
[/EDIT]
public class RCSceneLoader
{
private string myXMLAsset;
public RCSkyBox[] mySkyBoxs;
public RCModel[] myModels;
public RCSceneGraph[] myScenes;
private string myName;
public string Name
{
get { return myName; }
}
public int SceneCount
{
get { return myScenes.Length; }
}
public RCSceneLoader(string newXMLAsset)
{
XmlTextReader xtr = new XmlTextReader(newXMLAsset);
myXMLAsset = newXMLAsset;
XmlDocument doc = new XmlDocument();
doc.Load(xtr);
xtr.Close();
XmlNode node = doc.FirstChild.NextSibling;
myName = node.Attributes["name"].Value;
myScenes = new RCSceneGraph[Convert.ToInt32(node.Attributes["sceneCount"].Value)];
// Load shaders.
node = doc.SelectSingleNode("sceneManager/shaders");
node = node.FirstChild;
do
{
RCShader shader = new RCShader(node.Attributes["asset"].Value);
RCShaderManager.AddShader(shader, node.Attributes["name"].Value);
} while ((node = node.NextSibling) != null);
// Load Skyboxs.
node = doc.SelectSingleNode("sceneManager/skyboxs");
mySkyBoxs = new RCSkyBox[Convert.ToInt32(node.Attributes["skyboxCount"].Value)];
node = node.FirstChild;
for(int box=0;box<mySkyBoxs.Length;box++)
{
string skyboxName = node.Attributes["name"].Value;
mySkyBoxs[box] = new RCSkyBox(new string[] { node.Attributes["top"].Value, node.Attributes["bottom"].Value,
node.Attributes["left"].Value, node.Attributes["right"].Value,
node.Attributes["front"].Value, node.Attributes["back"].Value });
}
// Load Objects/Models.
node = doc.SelectSingleNode("sceneManager/models");
myModels = new RCModel[Convert.ToInt32(node.Attributes["modelCount"].Value)];
node = node.FirstChild;
for(int mod=0;mod<myModels.Length;mod++)
{
myModels[mod] = new RCModel(node.Attributes["asset"].Value);
myModels[mod].SpecularPower = (float)Convert.ToDouble(node.Attributes["specularPower"].Value);
XmlNode modNode = node.SelectSingleNode("ambientLight");
myModels[mod].AmbientLightColor = new Vector4((float)Convert.ToDouble(modNode.Attributes["red"].Value),
(float)Convert.ToDouble(modNode.Attributes["green"].Value),
(float)Convert.ToDouble(modNode.Attributes["blue"].Value),
(float)Convert.ToDouble(modNode.Attributes["alpha"].Value));
modNode = node.SelectSingleNode("diffuseColor");
myModels[mod].DiffuseColor = new Vector4((float)Convert.ToDouble(modNode.Attributes["red"].Value),
(float)Convert.ToDouble(modNode.Attributes["green"].Value),
(float)Convert.ToDouble(modNode.Attributes["blue"].Value),
(float)Convert.ToDouble(modNode.Attributes["alpha"].Value));
node = node.NextSibling;
}
// Load Scenes
node = doc.FirstChild.NextSibling.SelectSingleNode("scene");
for (int scn = 0; scn < myScenes.Length; scn++)
{
myScenes[scn] = new RCSceneGraph();
XmlNode skyboxNode = node.SelectSingleNode("skybox");
XmlNode modelsNode = node.SelectSingleNode("models");
// Add skybox
mySkyBoxs[Convert.ToInt32(skyboxNode.Attributes["id"].Value)].SetShader(skyboxNode.Attributes["shader"].Value);
mySkyBoxs[Convert.ToInt32(skyboxNode.Attributes["id"].Value)].Scaling = new Vector3((float)Convert.ToDecimal(skyboxNode.Attributes["scalingX"].Value),
(float)Convert.ToDecimal(skyboxNode.Attributes["scalingY"].Value),
(float)Convert.ToDecimal(skyboxNode.Attributes["scalingZ"].Value));
myScenes[scn].AddObject(mySkyBoxs[Convert.ToInt32(skyboxNode.Attributes["id"].Value)]);
modelsNode = modelsNode.FirstChild;
int mod = 0;
do
{
myModels[Convert.ToInt32(modelsNode.Attributes["id"].Value)].SetShader(modelsNode.Attributes["shader"].Value);
myModels[Convert.ToInt32(modelsNode.Attributes["id"].Value)].Position = new Vector3((float)Convert.ToDecimal(modelsNode.Attributes["positionX"].Value),
(float)Convert.ToDecimal(modelsNode.Attributes["positionY"].Value),
(float)Convert.ToDecimal(modelsNode.Attributes["positionZ"].Value));
myModels[Convert.ToInt32(modelsNode.Attributes["id"].Value)].Scaling = new Vector3((float)Convert.ToDecimal(modelsNode.Attributes["scalingX"].Value),
(float)Convert.ToDecimal(modelsNode.Attributes["scalingY"].Value),
(float)Convert.ToDecimal(modelsNode.Attributes["scalingZ"].Value));
myScenes[scn].AddObject(myModels[Convert.ToInt32(modelsNode.Attributes["id"].Value)]);
mod++;
} while ((modelsNode = modelsNode.NextSibling) != null);
}
node = node.NextSibling;
}
}
Add an instance of the new object to RCGame (HMGame)
private RCSceneLoader myLoadedScenes;
And a new function to load the xml file
public void LoadScenesFomXML(string XmlFile)
{
myLoadedScenes = new RCSceneLoader(XmlFile);
myScene = myLoadedScenes.myScenes[SelectedScene];
}
So all I have to do is call the following code from the SetupScene in the EngineDemo
game.LoadScenesFomXML("Content/Scenes/TestScene.xml");
I have a few things I will probably change and that is move the lighting for models into the <scene><models><model/> element so you can then have different lighting effects for the same model.
I also have to write the save method to put any changes back to the xml or to just build one from scratch.
I will put some resilience in there to, nothing like users to miss values out or put characters where numbers are expected

Also you wll notice that some elements are not yet used in my loader, the Scene min/max XYZ and a models rotation, I will probably get on to those things after the new year, come on guys it's Christmas, I need a break too!
Nelson,
What you are doing is probably best but I think that can make the xml hard to edit for a player that just wants to create there own scene or add there own model, I think this way is easier for players to edit and understand.
All,
Please add any ideas you have or if you think I am doing something glaringly stupid, let me know and I will put it right, we are all here to learn from each other after all.