This project is read-only.
  • Loading entities and components from XML
  • Loading other assets from XML
    • The engine is currently setup to load a few types of objects from XML data. (as of v0.22), and all components and entities as well (as of v0.24). The eventual goal, is to have scenes made entirely from a level editor, and likely save out the data in an XML format, and load entire scenes from XML (except the heightmap).
    • For an example of how something like fog loads from XML, lets open an XML file that is used for fog. Look in the Content directory in the sample project. You will see an EnvironmentalEffects folder, and within that is a GrayLowLayingFog.xml, open that file up.
      • What you’ll see here is pretty straightforward. Each type within the Asset category is a variable that matches a variable in a class in the code. Near the top of the file you’ll see: <Asset Type="QuickStart.EnvironmentalSettings.FogSettings">The Asset Type is a direct reference to a class in the game engine. And each subtype within the asset is a variable of that class.
      • To load fog, you can simply use the Content system within XNA. Fog settings get passed to a scene. Each scene can have one type of fog settings.
        • In SampleScene’s constructor you’ll find this line:
        • this.LoadFog("EnvironmentalEffects/GrayLowLayingFog");
        • LoadFog is a function that a scene has to take a path to a fog settings XML file and load it. If we open that function we’ll see this:
        • fogSettings =<FogSettings>(fogPath);
        • Here’s where you can see that XNA very simply lets us load classes from XML files, which is does by using a method called ‘Reflection’. This method creates a FogSettings object, which we can save in ‘fogSettings’ for the scene.
        • The graphics system is automatically notified whenever fog settings are changed.

Last edited Jan 5, 2012 at 3:03 PM by LordIkon, version 3


No comments yet.