[Gtkradiant] Re: xml?

Joseph, William gtkradiant@zerowing.idsoftware.com
Tue, 25 Sep 2001 22:50:23 +0100


I'm experimenting with loading code for files using the format below - to
see if the <primitive type="bleh"> <surf> arrangement is actually any better
than using <brush> <plane> and <patch> <matrix>. One reason i like the
abstract primitive/surf idea is demonstrated below with a "polymesh"
primitive using the same format. My hope is that i can use a standard set of
functions to convert the xml tree data into the format desired by each
primitive, instead of some custom-made specific functions for each
primitive. This should make things generally more extensible in theory..


<?xml version="1.0"?>

<!DOCTYPE map [

  <!--entity contains one or more epairs, and zero or more primitives-->
  <!ELEMENT map         (entity+)> 
  <!ATTLIST map         type        CDATA  #REQUIRED>

  <!--entity contains one or more epairs, and zero or more primitives-->
  <!ELEMENT entity      (epair+, prim*)> 

  <!ELEMENT epair       EMPTY> 
  <!ATTLIST epair       key         CDATA  #REQUIRED>
  <!ATTLIST epair       value       CDATA  #REQUIRED>

  <!--primitive contains one or more surfaces-->
  <!ELEMENT primitive   (surf+)>
  <!ATTLIST primitive   type        CDATA  #REQUIRED>

  <!--surface contains vector and an optional texdef-->
  <!ELEMENT surface     (vector, texdef?)>

  <!--vector contains geometric data in #PCDATA-->
  <!ELEMENT surface     (#PCDATA)>
  <!ATTLIST surface     numdim      CDATA  #REQUIRED>
  <!ATTLIST surface     dimensions  CDATA  #REQUIRED>

  <!--texdef contains texdef data in #PCDATA-->
  <!ELEMENT texdef      (#PCDATA?)>
  <!ATTLIST texdef      shader      CDATA  #REQUIRED>
  <!ATTLIST texdef      type        CDATA  "default">
  <!ATTLIST texdef      flags       CDATA  "0">

]>


<map type="quake3">
  <!--Entity 0-->
  <entity>
    <epair key="classname" value="worldspawn"/>
    <epair key="message" value="bleh"/>
    <!--Brush 0-->
    <primitive type="brush">
      <surface>
        <vector numdim="2" dimensions="3 3">x y z x y z x y z</vector>
        <texdef shader="textures/radiant/notex" type="quake3" flags="15">0 0
0.5 0.5 0</texdef>
      </surface>
    </primitive>
    <!--Brush 1-->
    <primitive type="patch">
      <surface>
        <vector numdim="3" dimensions="3 3 5">x y z s t x y z s t x y z s t
x y z s t x y z s t x y z s t x y z s t x y z s t x y z s t</vector>
        <texdef shader="textures/radiant/notex"></texdef>
      </surface>
    </primitive>
    <!--Brush 1-->
    <primitive type="polymesh">
      <surface>
        <vector numdim="2" dimensions="3 8">x y z nx ny nz s t x y z nx ny
nz s t x y z nx ny nz s t</vector>
        <texdef shader="textures/radiant/notex"></texdef>
      </surface>
    </primitive>
  </entity>
  <!--Entity 1-->
  <entity>
    <epair key="classname" value="info_player_deathmatch"/>
    <epair key="origin" value="x y z"/>
    <epair key="angle" value="90"/>
  </entity>
  <!--Entity 2-->
  <entity>
    <epair key="classname" value="item_armor_combat"/>
    <epair key="origin" value="x y z"/>
  </entity>
</map>