Recommended method for XML level loading in XNA

Posted by David Saltares Márquez on Game Development See other posts from Game Development or by David Saltares Márquez
Published on 2011-11-29T11:15:37Z Indexed on 2011/11/29 18:04 UTC
Read the original article Hit count: 489

Filed under:
|
|
|

I want to use Blender as my level designer tool for an XNA game. Using an existing plugin, I can export my levels to DotScene format which is basically an xml file like this one:

<scene formatVersion="1.0.0">
  <nodes>
    <node name="scene-staircase.001">
      <position x="10.500000" y="1.400000" z="-9.600000"/>
      <quaternion x="0.000000" y="0.000000" z="-0.000000" w="1.000000"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <entity name="scene-staircase.001" meshFile="staircase.mesh"/>
    </node>

    <node name="Lamp.003">
      <position x="11.024290" y="5.903862" z="9.658987"/>
      <quaternion x="-0.284166" y="0.726942" z="0.342034" w="0.523275"/>
      <scale x="1.000000" y="1.000000" z="1.000000"/>
      <light name="Spot.003" type="point">
        <colourDiffuse r="0.400000" g="0.154618" b="0.145180"/>
        <colourSpecular r="0.400000" g="0.154618" b="0.145180"/>
        <lightAttenuation range="5000.0" constant="1.000000" linear="0.033333" quadratic="0.000000"/>
      </light>
    </node>

    ...

  </nodes>
</scene>

Using naming conventions I could easily parse the file and load the correspondent in game content. I am new to XNA and I have seen that there are several methods to load XML files into a game like serializing and deserializing. Which one would you recommend?

© Game Development or respective owner

Related posts about XNA

Related posts about c#