4
\$\begingroup\$

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?

\$\endgroup\$
  • 1
    \$\begingroup\$ I realized I can add my XML files as resources to the Content Manager specifying I don't want any binary conversion to take place and I want the files to get copied. Then, I can load the XML files as in a normal C# program. \$\endgroup\$ – David Saltares Nov 29 '11 at 15:15
  • \$\begingroup\$ If that's an answer you should put it in the answer section so that you can "accept" it and the question doesn't get bumped up because it's "unanswered". \$\endgroup\$ – Tetrad Nov 29 '11 at 16:01
1
\$\begingroup\$

I would actually recommend using the newer XDocument class instead of XmlDocument. Check:

https://stackoverflow.com/questions/1542073/xdocument-or-xmldocument

According to that thread it's also compatible with XBox and WP7, but I haven't tried since I'm currently developing for Windows.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

I realized I can add my XML files as resources to the Content Manager specifying I don't want any binary conversion to take place and I want the files to get copied. Then, I can load the XML files as in a normal C# program:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Content.RootDirectory + "\\XML\\file.xml");
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Does this work on Xbox or WP7? \$\endgroup\$ – Nate Nov 29 '11 at 23:40
  • 2
    \$\begingroup\$ The answer is yes to both \$\endgroup\$ – ClassicThunder Nov 30 '11 at 1:41
  • \$\begingroup\$ Another option, is to create a custom content processor, which might be worth it, but is more involved. \$\endgroup\$ – George Duckett Nov 30 '11 at 15:53
  • \$\begingroup\$ The problem here is the loss of compression without the binary conversion. \$\endgroup\$ – Sinthia V Jul 4 '12 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.