#!/usr/bin/perl -w

# (c) Copyright by Tels 1999-2000. All Rights Reserved.
# file to be called via "perl vtutorial.pl 8"

# 2000-05-06 fixed brush bug

sub createWorld
  {
  my ($txt,$gf) = @_; # get texture mapping and gamfile as params
  print "Tutorial Section 8\n\n";

  $room = { texture => { t => $txt->texture("brickfl3"), r => 90, } , 
            floortexture => $txt->texture('rufgry'),
            ceilingtexture => $txt->texture('rufgry'),
            wallthick => 2, floorthick => 4, ceilingthick => 3,
            nowall => NOWALL,
    };                                                     
  $centerroom = { };
  $moonlightwindow = { 
    name =>  'moonlightwindow##num##', 
    gen => \&Cowgen::Architecture::Basics::brush,
    brtype => cube(), brkind => air(),
    texture => $txt->texture("rufgry"), 
    ceilingtexture => { t => sky(), s => 24, },
    width => -0.75, length => -0.75, height => 6,
    inherit => TRUE, az => atCell(),
    };

  $moonlight = { 
    name =>  'moonlight##num##', 
    base => $gf->obj('spotlightpoint'),
    prop => { light => "55, 0,0,0, 25", },
    relativeto => 'moonlightwindow', 
    dx => 0, dy => 0, dz => 1,
    rx => 25, rz => 10,
    inherit => TRUE,
    };

  $east = cell ( name => "East", size => 12, min => 12, max => 12, div => inX(), 
    clobberwall => aWest(), );          
  $west = cell ( name => "West", size => 12, min => 12, max => 12, div => inX(), 
    clobberwall => aEast(), );          

  $south = cell ( name => "South", size => 12, min => 12, max => 12, div => inY(), 
    clobberwall => aNorth(), );          
  $north = cell ( name => "North", size => 12, min => 12, max => 12, div => inY(), 
    clobberwall => aSouth(), );          

  addCells ($east, 6, "6", "east##num##");
  addCells ($west, 6, "6", "west##num##");
  addCells ($south, 4, "6", "south##num##");
  addCells ($north, 4, "6", "north##num##");

  # no clobbering for edge/corner cells
  $east->{cells}->[0]->{clobberwall} = 0;
  $east->{cells}->[-1]->{clobberwall} = 0;
  $west->{cells}->[0]->{clobberwall} = 0;
  $west->{cells}->[-1]->{clobberwall} = 0;

  my $depressive = { name => "step", gen => \&Cowgen::Architecture::Basics::brush, 
     width => -1, height => 2, length => -1,
     sx => 2, sy => 2, ax => atThing(), ay => atThing(), az => atWall(), faces => 10,
     brkind => air(), brtype => cylinder(), texture => $txt->texture('rufgry'),
     sidetexture => { t=> $txt->texture("marble"), r => 90, },
     };
  my $de2 = copyHash($depressive);
  $de2->{sx} = 4;
  $de2->{sy} = 4;
  $de2->{height} = 5;

  my $de3 = copyHash($de2);
  $de3->{width} = 6; $de3->{length} = 6; $de3->{brkind} = solid();

  $center = cell ( name => "Center", size => 1, nowall => 0, room => $centerroom, 
    things => [ thing(0,0,-0.5,aSouth(),$depressive), thing(0,0,-0.5,aSouth(),$de2),
      thing(0,0,-0.5,aSouth(),$de3), omniLight(0,0,0, { light => 185 } )
    ] );          

  
  $middle = cell ( name => "West", size => 1, div => inX(), 
    cells => [ $north, $center, $south, ],
    );

  $world = cell ( name => "Temple", room => $room, div => inY(),                                          
    cells => [ $west, $middle, $east, ],
    things => [ 
     objThing(0,0,0.5,aSouth(),$moonlightwindow),
     objThing(0,0,-0.75,aSouth(),$moonlight),
    ], );

  $world->{debug} = 1;
  $bunch = worldAsBunch ( 0, 0, 0, 72, 72, 32, $world );   

  return $bunch;
  }

# EOF
1;

