#!/usr/bin/perl -w

# (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::Basics;  # to get beams

print "Demo script to show alignment, dimensions, cloning and beams\n\n";

$vbr = Cowgen::Vbr->create("houses.mis");

$txt = Cowgen::Texture->create($vbr->getTXT());

# get commandline parameter
$outfile = shift || "align.mis";

my $bunch = Cowgen::Bunch->create("Alignments");

my $wood = $txt->texture("wood");
my $stone = $txt->texture("rufgr");
my $stone2 = $txt->texture("brick");
my $stone3 = $txt->texture("brik1");
$bunch->setDefTexture($stone);

$brush = $bunch->addBrush (air()+MROOM,cube(),0,0,10,64,64,48,$stone);
$bunch->setTexture ($brush,top(),sky());

$p = { texture => $wood, facing => aWest() };
my $bu = supportBeamSingle(0,0,-4,2,8,16,$p);
$bunch->merge($bu);

$bunch->debug();
$p = { texture => $wood, facing => aSouth() };
$bu = supportBeamSingle(0,0,-7,1,6,14,$p);
$bu->translate(-18,-20,0);

my @d = $bu->dimensions;
print "Beam:\n  SizeX:  $d[0]   sizey:  $d[1]  sizez:   $d[2]\n";
print "  CenterX: $d[3]  Center: $d[4]  Centerz: $d[5]\n";

$bu = $bu->cloneRow(6,0,6,0);
$bu->addBrush ( solid(), cube(), -18, -5, 0.5, 36, 6, 1, $wood);
$bunch->merge($bu);

$p = { texture => $stone3, facing => aSouth(), spacing => 4 };
$bu = supportBeamDouble(20,0,-7,1,20,14,$p);
$bunch->merge($bu);

# show cloning
$bu = Cowgen::Bunch->create ("original");
$bu->addBrush (solid(),cube(),0,0,16,4,4,2,$stone2);
$bu->addBrush (solid(),cube(),0,0,12,2,2,6,$wood);
my $clone = $bu->cloneRow(5,0,-5,-2);
$bunch->merge ( $clone );

$bu = Cowgen::Bunch->create ("original");
$bu->addBrush (solid(),cube(),-32+2,-32+2,0,4,4,2,$stone2,0,0,0,$wood,$wood,$wood,$wood,$stone3);
$clone = $bu->cloneRow(7,6,0,2);
$bunch->merge ( $clone );

$bu = Cowgen::Bunch->create ("original");
$bu->addBrush (solid(),cube(),-32+2,-32+14,-4,4,4,2,$stone2,0,0,0,$wood,$wood,$wood,$wood,$stone3);
$clone = $bu->cloneRow(4,0,6,-2);
$bunch->merge ( $clone );

$bu = Cowgen::Bunch->create ("original");
$bu->addBrush (solid(),cube(),-32+2,-32+8,-2,4,4,2,$stone2,0,0,0,$wood,$wood,$wood,$wood,$stone3);
$bunch->merge ( $bu );

$p = { texture => $stone3, facing => aSouth(), thick => 1, innertexture => $stone,
       floortexture => $stone2, sides => 10, };
$bunch->merge ( arch( 0, 20, -4, 10, 4,20, $p) );

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

# EOF

1;
