# !/usr/bin/perl -w

# to show usage of fireplaces and other furniture stuff

# (c) Copyright by Tels 1999-2000. All Rights Reserved.

use Cowgen::Bunch;                  # for a bunch of brushes
use Cowgen::Dromed;                 # for some Thief constants and specifics
use Cowgen::Texture;                # to get texture mappings
use Cowgen::Architecture::Building; # to get stairs etc
use Cowgen::Architecture::Basics;   # to get grid, hole
use Cowgen::Architecture::Inside;   # tables, boards, bed etc
use Cowgen::Architecture::Tempel;   # some tempel stuff

print "Demo script to show usage of furniture, fireplaces and shed\n\n";

$vbr = Cowgen::Vbr->create("houses.mis");
$core = Cowgen::Texture->create($vbr->getTXT());
$gf = Cowgen::Gamfile->create();
print $gf->obj("Default Room"),"\n";

# get commandline parameter
$outfile = shift || "data/inside.mis";

my $bunch = Cowgen::Bunch->create("Rooms with furniture and fireplace");

my $brick = $core->texture("blubrik1");
$bunch->setDefTexture($brick);

my $sky = $core->texture("sky");
my $dirt = $core->texture("cavedirt");
# basic layout
$bunch->addBrush(air(),cube(),0,0,0,32,32,16); # room1
$bunch->addBrush(air(),cube(),34,0,0,32,32,16); # room 2
$bunch->addBrush(air(),cube(),-4,-34,4,32,64,24,$sky); # room 3
$bunch->addBrush(air(),cube(),-4,-34,-2,32,64,12,
  $dirt,0,0,0,$brick,$brick,$brick,$brick); # room 3 wall
$bunch->addBrush(air(),cube(),30,18,0,2,60,16,$sky); # sky1
$bunch->addBrush(air(),cube(),52,0,0,32,2,16,$sky); # sky2
$bunch->addBrush(air(),cube(),34,-17-5,-4,8,8,10); # privy

#$p = { texture => createTexture($core->texture("wdplnk2g"),15,90), 
#       yin => 1,zin => 1, yout => 2, zout => 2, facing => aSouth(),
#     };
#$bunch->merge( brokenHole(0, 0, 0, 8, 2, 8, $p) );

# for some testing only
#$p = { texture => { t => $core->texture("sandy"), s => 15 }, thick => 0.5, 
#     };
#$bunch->merge( gratedLight ( 0, 11, 0, 6, 6, 12, $p) );

#$bunch->autoRoom(); $bunch->autoFlow(); optimizeSky($bunch);
#$bunch->debug(on()); 
#$bunch->write2File("data/$outfile",1,$vbr);
#exit;

$p = { texture => $core->texture("core/wetbrick"),
       facing => aSouth(), framethick => 0.5,
     };
$bunch->merge( frame( 17, -4, -4, 5, 3, 9, $p) ); # door
$p->{facing} = aEast();
$bunch->merge( frame( 34, -17, -4, 5, 3, 9, $p) ); # privydoor
$bunch->merge( frame( -4, -17, -4, 5, 3, 9, $p) ); # outdoor

# put some stuff inside
# create an anonymous hash and put a reference to it into p
$p = { outertexture => $core->texture("core/rufgry"), innertexture => $core->texture("bricks"),
       thick => 1, opendepth => 2, openheight => 3, facing => aSouth(),
     };
$bunch->merge( fireplace(-12,0,-4,12,8,8, $p) );

$p = { texture => $core->texture("wdplnkg"), legs => 2, legwidth => 0.75, support => false(),
       thick => 0.5, legwidthspacing => 0.5
     };
$bunch->merge( table( 12, 4, -6.5, 12,4,3,$p) );
$p->{legwidthspacing} = 1; $p->{thick} = 0.75; $p->{legs} = 4; $p->{support} = true();
$p->{texture} = $core->texture("wdplnk2");
$bunch->merge( table( 2, -8, -5.5, 12,6,5,$p) );

$p = { boardtexture => $core->texture("wdplnkg"), thick => 0.25, wedgewidth => 0.5,
       wedgespacing => 1
     };
$bunch->merge( shelf( -15, 11, -3, 8, 2, 1,$p) );
$p->{thick} = 0.5; 
$bunch->merge( shelf( -15+35, 8, -3, 12, 4, 1.5,$p) );
$p->{wedgetexture} = $core->texture("r24"); 
$p->{wedgewidth} = 0.25;
$p->{wedgespacing} = 0.5;
$p->{facing} = aNorth();
$p->{thick} = 0.25; 
$bunch->merge( shelf( 37.5, -22, -3, 6, 1.5, 0.75, $p) );

$p->{facing} = aWest(); 
$bunch->merge( shelf( -15+46, 14, -3, 12, 4, 1.5, $p) );

$p = { texture => $core->texture("wood"), thick => 0.25, rows => 2, cols => 2 };
$bunch->merge( counter( 34+10, -6, -5.5, 20, 4, 5, $p) );

$p = { texture => $core->texture("wdplnk"), thick => 0.5, rows => 1, cols => 1,
       facing => aNorth(), wallthick => 1.5 };
$bunch->merge( counter( 34-4, -6, -6, 20, 3, 4, $p) );

$p = { texture => $core->texture("wdplnk"), thick => 0.5, rows => 1, cols => 1,
       facing => aEast(), wallthick => 1.5 };
$bunch->merge( counter( 34, 8, -6, 20, 3, 4, $p) );

$p = { texture => $core->texture("wdplnk"), facing => aEast(), diameter => 3, 
       waterheight => 5 };
$bunch->merge( privy( 34, -17-7, -7.5-5, 8, 4, 13, $p) );

$p = { frametexture => $core->texture("wdplnk2g"), gridtexture => $core->texture("wood"),
       facing => aEast(), gridthick => 0.5, framethick => 0.5,
       barsy => 2, barsz => 2 };
$bunch->merge( frameGrid( 44, 16, 3, 7, 2, 7, $p) );
$bunch->merge( frameGrid( 24, 16, 3, 7, 2, 7, $p) );
$bunch->merge( frameGrid( 8, 16, 3, 7, 2, 7, $p) );

$p->{facing} = aSouth();
$bunch->merge( frameGrid( 50, 8, 3, 7, 2, 7, $p) );

$p = { walltexture => $core->texture("wdplnk2"), rooftoptexture => $core->texture("rooftile"),
       frametexture => $brick,
       rooftexture => $core->texture("core/wood"), roofthick => 0.5, roofheight => 3,
       roofspacing => 0.5, facing => aSouth(), wallthick => 0.5, placedoor => aSouth(),
       };
$bunch->merge( shed( 20, -40, -1.5, 8, 8, 14, $p) );
$p->{facing} = aWest(); 
$bunch->merge( shed( -10, -35, -2.5, 9, 9, 12, $p) );

# show usage of texture hashs
$t = { t => $core->texture("core/rufgry"), s => 15};
$p = { texture => $t, innertexture => createTexture($core->texture("bricks"),15) ,
       floortexture => $core->texture("core/mosaic3"),
       thick => 1, waterheight => 1.5, floorthick => 1, facing => aWest(),
     };
$bunch->merge( basin(-30, -30, -8, 12,8,4, $p) );

$p = { texture => createTexture($core->texture("odstone"),15), 
       floortexture => $core->texture("core/cave"),
       thick => 1, waterheight => 0, floorthick => 1.5, facing => aSouth(),
     };
$bunch->merge( basin(6, -45, -8, 8, 6, 2, $p) );

$p = { texture => createTexture($core->texture("wdplnk2g"),15,90), 
       bodyheight => 1.5, 
       toptexture => $core->texture("core/cave"), 
       posttexture => createTexture($core->texture("wdplnk2g"),15), 
       postwidth => 0.5, woodheight => 2, woodthick => 0.25, facing => aSouth(),
       floorheight => 0.25,
     };
$bunch->merge( bed(0, 11, -5.5, 5, 8, 5, $p) );

$bunch->autoRoom(); $bunch->autoFlow(); optimizeSky($bunch);
$bunch->debug(on()); 
$vbr->missionEAX ( eax => eax_stoneRoom() );
$vbr->renderParams ( ambient => 20 ); # always use this!
$vbr->saveMission($gf,$bunch,$outfile);
print "Done. Enjoy data/$outfile\n";

# EOF

1;
