#!/usr/bin/perl -w

# test script for the new CoW stuff

use CoW::Thing;
use CoW::Cell;
use CoW::Coord qw /ALIGN_OUTSIDE/;
use CoW::Light;
use CoW::Architecture::Frame;

use strict;

sub construct
  {
  # construct a world and return it

  # first construct a frame for every rooms ceiling:

  # Just consider that the size/position is determined before rotating
  # Since we rotate the frame by 90 degrees, the height of the frame must be
  # the length of the room, while l becomes the new height. W just remains.

  my $cf = new CoW::Architecture::Frame ( 
    thick => 1, l => 1, hor_bars => 1, ver_bars => 1,
    h => CoW::Size->new ( rel => '_parent::l', val => 1 ),
    w => CoW::Size->new ( rel => '_parent::w', val => 1 ),
    z => CoW::Coord->new ( rel => '_parent::h,_parent::z', 
    val => 0.5, space => 2 ),
    );
  $cf->rotate(0,90,0);	# make the frame lying, instead of standing

  # insert a light into it, offset 0.5 foot from the frames upper edge
  my $l = new CoW::Light ( h => 0.5, s => 1, l => 80,
    z => CoW::Coord->new ( rel => '_parent::h,_parent::z', 
    val => 0.5, align => ALIGN_OUTSIDE, space => 0.5 ),
    ); 
  $cf->insert($l);

  # now create a world:
  my $world = new CoW::Cell ( 
    x => 0, y => 0, z => 0, 
    w => 64, l => 96, h => 20,
    rx => 0, ry => 0, rz => 0,
  );
  # and split the world into some cells:
  $world->grid (3,2);

  # then add the frames
  $world->for_each ( sub { my $thing = shift; $thing->insert($cf); } );

  # done, return and rest
  return $world;
  }
    
1;
