Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

3 XML

3 XML

DukeAtreides076
IBTL · · 1 min read
661 15
I decided it was time to clean up my XML environment loader.

I had been using tinybind to bind everything, but it turned into a bit of a mess with all the map entities. Tinybind is easy to setup and use; it took all of about five lines to load my environment. The problem is, it produced XML like this:

"1.0" ?> 	Dummy	DummyResources	FileSystem	../assets/maps/dummy	1						AmbientLight												Color					0.1,0.1,0.1,1.0														PointLight												Ogre Name					Light1													Position					0.0,0.0,50.0													Diffuse					0.5,0.5,0.5,1.0													Specular					0.0,0.5,0.5,1.0														FreeCam										StaticMesh												Mesh File					Table.mesh													Entity Name					TableMesh													Position					100.0,0.0,0.0														Robot						


I also needed a little bit of special hackery majiks for map containers, since tinybind doesn't really support them. It is pretty likely that I'll be editing at least some of the XML environments by hand, so I decided I needed something cleaner. The result is this:

"1.0" ?> "dummy">	"DummyResources" type="FileSystem" path="../assets/maps/dummy" />	"1" />			class="AmbientLight">			"Color" value="0.1,0.1,0.1,1.0" />				class="PointLight">			"Ogre Name" value="Light1" />			"Position" value="0.0,0.0,50.0" />			"Diffuse" value="0.5,0.5,0.5,1.0" />			"Specular" value="0.5,0.5,0.5,1.0" />				class="FreeCam" />		class="Robot" />		class="StaticMesh">			"Mesh File" value="Table.mesh" />			"Entity Name" value="TableMesh" />			"Position" value="100.0,0.0,0.0" />			


Still a little clunky, but much cleaner and more compact. It uses straight tinyxml, so the actual loading code is a bit longer, but it is definitely worth it.

In case you're intrested, here's what the dummy environment looks like:



I'm *almost* back on schedule. I just need to finish integrating ODE into the rest of the engine and implement load/save. Then I'll just have to write game entities and create content and hope I can finish it all by the end of November.

Discussion

Loading comments...