<?xml version="1.0" encoding="utf-8" ?> 
<world>
  <variables>
    <variable name="LodM" value="-0.00666667" />
    <variable name="LodA" value="1.33333" />
  </variables>

  <plugins>
    <plugin name="thingFact">crystalspace.mesh.loader.factory.thing</plugin>
    <plugin name="thing">crystalspace.mesh.loader.thing</plugin>
    <plugin name="genmeshFactory">crystalspace.mesh.loader.factory.genmesh</plugin>
    <plugin name="genmesh">crystalspace.mesh.loader.genmesh</plugin>
    <plugin name="terrainFact">crystalspace.mesh.loader.factory.terrain</plugin>
    <plugin name="terrain">crystalspace.mesh.loader.terrain</plugin>
    <plugin name="foliageFact">crystalspace.mesh.loader.factory.foliage</plugin>
    <plugin name="foliage">crystalspace.mesh.loader.foliage</plugin>
    <!--
    <plugin name="instFact">crystalspace.mesh.loader.factory.instmesh</plugin>
    <plugin name="inst">crystalspace.mesh.loader.instmesh</plugin>
    -->
  </plugins>

  <textures>
    <texture name="andrew_marble4.jpg">
      <file>/lib/stdtex/andrew_marble4.jpg</file>
    </texture>
    <texture name="stone4.gif">
      <file>/lib/std/stone4.gif</file>
    </texture>
    <texture name="grass.png">
      <file>/lev/terrain/grass.png</file>
    </texture>
    <texture name="materialmap_base.png">
      <file>/lev/terrain/materialmap_base.png</file>
    </texture>
        <texture name="clouds">
            <file>clouddome.jpg</file>
        </texture>
        <texture name="sky_up">
            <file>skybox_u.jpg</file>
        </texture>
        <texture name="sky_down">
            <file>skybox_d.jpg</file>
        </texture>
        <texture name="sky_left">
            <file>skybox_l.jpg</file>
        </texture>
        <texture name="sky_right">
            <file>skybox_r.jpg</file>
        </texture>
        <texture name="sky_front">
            <file>skybox_f.jpg</file>
        </texture>
        <texture name="sky_back">
            <file>skybox_b.jpg</file>
        </texture>
  </textures>

  <shaders>
    <shader><file>/shader/terrain_fixed_base.xml</file></shader>
    <shader><file>/shader/terrain_fixed_splatting.xml</file></shader>
  </shaders>

  <materials>
    <material name="ScatterSky">
      <color red="0" green="0" blue="0" /> 
    </material>
    <material name="Base">
      <texture>materialmap_base.png</texture>
      <shader type="ambient">terrain_fixed_base</shader>
    </material>
    <material name="Marble">
      <texture>andrew_marble4.jpg</texture>
      <shadervar name="texture scale" type="vector2">32,32</shadervar>
      <shader type="terrain splat">terrain_fixed_splatting</shader>
    </material>
    <material name="Stone">
      <texture>stone4.gif</texture>
      <shadervar name="texture scale" type="vector2">128,128</shadervar>
      <shader type="terrain splat">terrain_fixed_splatting</shader>
    </material>
    <material name="Grass">
      <texture>grass.png</texture>
      <shadervar name="texture scale" type="vector2">256,256</shadervar>
      <shader type="terrain splat">terrain_fixed_splatting</shader>
    </material>
    <material name="box1">
      <texture>grass.png</texture>
    </material>
    <material name="box2">
      <texture>andrew_marble4.jpg</texture>
    </material>
        <material name="clouds">
            <texture>clouds</texture>
        </material>
        <material name="sky_up">
            <texture>sky_up</texture>
        </material>
        <material name="sky_down">
            <texture>sky_down</texture>
        </material>
        <material name="sky_left">
            <texture>sky_left</texture>
        </material>
        <material name="sky_right">
            <texture>sky_right</texture>
        </material>
        <material name="sky_front">
            <texture>sky_front</texture>
        </material>
        <material name="sky_back">
            <texture>sky_back</texture>
        </material>
  </materials>

  <library>grass.lib</library>
  <library>rock.lib</library>
  <library>tree.lib</library>
  <library>tree_skimp.lib</library>
  <library>treebark_bare.lib</library>
  <library>bush2.lib</library>

  <addon>
    <plugin>crystalspace.renderloop.loop.loader</plugin>
    <paramsfile>/shader/std_rloop_terrainfixed.xml</paramsfile>
  </addon>
    
  <settings>
    <clearzbuf>yes</clearzbuf>
    <lightmapcellsize>16</lightmapcellsize>
    <renderloop>std_rloop_terrainfixed</renderloop>
  </settings>

  <start>
    <sector>room</sector>
    <position x="0" y="30" z="0" />
    <forward x="0" y="0" z="1" />
    <up x="0" y="1" z="0" />
  </start>

  <meshfact name="skydome">
    <plugin>genmeshFactory</plugin>
    <params>
      <sphere rimvertices="6" reversed="true">
	<radius x="1000" y="1000" z="1000" />
      </sphere>
    </params>
  </meshfact>

  <addon plugin="crystalspace.terraformer.simple.loader">
      <name>simple</name>
      <heightmap>/lev/terrain/heightmap_257x257.png</heightmap>
      <!--<heightmap image="/lev/terrain/heightmap_2049x2049.png"/>-->
      <scale x="256" y="32" z="256" />
      <materialmap image="/lev/terrain/materialmap.png" />
  </addon>

    <!--
    <meshfact name="squareInst">
        <plugin>instFact</plugin>
        <params>
                <box>
                    <min x="-.2" y="-.2" z="-.2" />
                    <max x=".2" y=".2" z=".2" />
                </box>
                <material>box2</material>
        </params>
    </meshfact>
    -->

  <meshfact name="TerrainFact">
    <plugin>terrainFact</plugin>
    <params>
      <plugin>crystalspace.mesh.object.terrain.bruteblock</plugin>
      <terraformer>simple</terraformer>
      <sampleregion>
        <min x="-256" y="-256" />
        <max x="256" y="256" />
      </sampleregion>
    </params>
  </meshfact>

  <sector name="room">
     <light name="sun">
       <center x="-50000" y="86030" z="0" />
       <color red="0.85903" green="0.80995" blue="0.70420" />
       <radius>1000000</radius>
     </light>

    <meshobj name="Terrain">
      <plugin>terrain</plugin>
      <params>
        <factory>TerrainFact</factory>
        <material>Base</material>
        <materialpalette>
          <material>Grass</material>
          <material>Marble</material>
          <material>Stone</material>
        </materialpalette>
        <lodvalue name="splatting distance">200</lodvalue>
        <lodvalue name="block resolution">16</lodvalue>
        <lodvalue name="block split distance">8</lodvalue>
        <lodvalue name="minimum block size">32</lodvalue>
        <lodvalue name="cd resolution">256</lodvalue>
        <staticlighting>yes</staticlighting>
        <castshadows>yes</castshadows>
      </params>
      <move> 
        <v x="0" y="0" z="0" /> 
      </move>
      <priority>wall</priority>
    </meshobj>

        <meshobj name="clouds">
            <plugin>genmesh</plugin>
            <params>
                <factory>skydome</factory>
                <mixmode> <add /> </mixmode>
                <material>clouds</material>
                <lighting>no</lighting>
                <color red="0.5" green="0.5" blue="0.5" />
            </params>
            <znone />
            <priority>portal</priority>
	    <noshadows/>
            <camera />
        </meshobj>
        <meshobj name="sky">
	    <noshadows/>
            <plugin>thing</plugin>
            <params>
                <v x="-1000" y="-1000" z="1000" />
                <v x="1000" y="-1000" z="1000" />
                <v x="-1000" y="-1000" z="-1000" />
                <v x="1000" y="-1000" z="-1000" />
                <v x="-1000" y="1000" z="1000" />
                <v x="1000" y="1000" z="1000" />
                <v x="-1000" y="1000" z="-1000" />
                <v x="1000" y="1000" z="-1000" />
                <p name="up">
                    <v>6</v>
                    <v>7</v>
                    <v>5</v>
                    <v>4</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_up</material>
                    <lighting>no</lighting>
                </p>
                <p name="down">
                    <v>3</v>
                    <v>2</v>
                    <v>0</v>
                    <v>1</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_down</material>
                    <lighting>no</lighting>
                </p>
                <p name="back">
                    <v>7</v>
                    <v>6</v>
                    <v>2</v>
                    <v>3</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_back</material>
                    <lighting>no</lighting>
                </p>
                <p name="front">
                    <v>4</v>
                    <v>5</v>
                    <v>1</v>
                    <v>0</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_front</material>
                    <lighting>no</lighting>
                </p>
                <p name="left">
                    <v>6</v>
                    <v>4</v>
                    <v>0</v>
                    <v>2</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_left</material>
                    <lighting>no</lighting>
                </p>
                <p name="right">
                    <v>5</v>
                    <v>7</v>
                    <v>3</v>
                    <v>1</v>
                    <texmap>
                        <uv idx="0" u="0.005" v="0.005" />
                        <uv idx="1" u="0.995" v="0.005" />
                        <uv idx="2" u="0.995" v="0.995" />
                    </texmap>
                    <material>sky_right</material>
                    <lighting>no</lighting>
                </p>
            </params>
            <camera />
            <zfill />
            <priority>sky</priority>
        </meshobj>
        <key name="cmd_AnimateSky" value="clouds,y,.005" />

     <meshgen name="grass">
        <geometry>
	    <factory maxdist="30" name="treebark_bare" />
	    <radius>1</radius>
	    <density>0.02</density>
	    <materialfactor material="Grass" factor=".4" />
	    <defaultmaterialfactor>.7</defaultmaterialfactor>
        </geometry>
        <geometry>
	    <factory maxdist="30" name="tree" />
	    <radius>1</radius>
	    <density>0.02</density>
	    <materialfactor material="Grass" factor="1" />
	    <defaultmaterialfactor>.1</defaultmaterialfactor>
        </geometry>
        <geometry>
	    <factory maxdist="30" name="tree_skimp" />
	    <radius>1</radius>
	    <density>0.01</density>
	    <materialfactor material="Grass" factor="1" />
	    <defaultmaterialfactor>.1</defaultmaterialfactor>
        </geometry>
        <geometry>
	    <factory maxdist="10" name="Grass" />
	    <factory maxdist="30" name="GrassLow" />
	    <radius>1</radius>
	    <density>0.4</density>
	    <materialfactor material="Grass" factor="1" />
        </geometry>
        <geometry>
	    <factory maxdist="30" name="bush2" />
	    <radius>1</radius>
	    <density>0.04</density>
	    <materialfactor material="Marble" factor="1" />
	    <materialfactor material="Stone" factor="1" />
	    <defaultmaterialfactor>.1</defaultmaterialfactor>
        </geometry>
        <geometry>
	    <factory maxdist="10" name="TallGrass" />
	    <factory maxdist="30" name="TallGrassLow" />
	    <radius>1</radius>
	    <density>.08</density>
	    <materialfactor material="Grass" factor="1" />
        </geometry>
        <geometry>
	    <factory maxdist="30" name="Rock" />
	    <radius>1</radius>
	    <density>.010</density>
	    <materialfactor material="Marble" factor="1" />
	    <materialfactor material="Stone" factor="0" />
	    <defaultmaterialfactor>.3</defaultmaterialfactor>
        </geometry>
        <geometry>
	    <factory maxdist="30" name="RockSmall" />
	    <radius>1</radius>
	    <density>.10</density>
	    <materialfactor material="Marble" factor="1" />
	    <materialfactor material="Stone" factor="0" />
	    <defaultmaterialfactor>.3</defaultmaterialfactor>
        </geometry>
	<!--
        <geometry>
	    <factory maxdist="30" name="squareInst" />
	    <radius>1</radius>
	    <density>.3</density>
        </geometry>
	-->
	<!--<densityscale mindist="26" maxdist="30" maxfactor="0" />-->
	<alphascale mindist="22" maxdist="30" />
	<samplebox>
	    <min x="-256" y="-200" z="-256" />
	    <max x="256" y="200" z="256" />
	</samplebox>
	<meshobj>Terrain</meshobj>
     </meshgen>

    <!-- Uncomment for ...fog: -->
    <!--fog red=".3" green=".27" blue=".27" density="0.002" /-->
  </sector>
</world>
