#!/usr/bin/perl -w

# (c) Copyright by Tels 1999. All Rights Reserved.
# 1999-12-25 second bridge type added

use Cowgen::Bunch;                  # for a bunch of brushes
use Cowgen::Dromed;
use Cowgen::Texture;                # to get texture mappings
use Cowgen::Architecture::Basics;   # to get dome
use Cowgen::Architecture::Building; # to get bridges

print "Demo script to show usage of bridges\n\n";

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

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

my $cave = $core->texture("cave");
my $dirt = $core->texture("dirt");
my $cement = $core->texture("clnbrik1");
my $slabs = $core->texture("brick1");
my $bunch = Cowgen::Bunch->create("Bridges");

my $br = $bunch->addBrush(air(),cube(),0,0,0,96,20,48,$cave); # canyon
$bunch->setTexture ($br, top(), sky());
$bunch->addBrush(air(),cube(),-20,0,0,32,20,16,$dirt); # left
$br = $bunch->addBrush(air(),cube(),20,0,8,32,20,32,$dirt); # right
$bunch->setTexture ($br,top(),sky());

$p = { texture => $cement, walltexture => $slabs };
$bunch->merge ( dome(-42,0,0,32,32,32,$p)) ; # dome

my $wood = $core->texture("wood");
my $stone = $core->texture("rockwa");

$p = { toptexture => $stone, sidetexture => $slabs, bottomtexture => $stone, 
       rtexture => $wood, rwidth => 1.5, rheight => 1, };
$bridge = bridge(0,-8,-7,12,24,2,$p);
$bunch->merge($bridge);

my $wood2 = $core->texture("woodblt");

# setting bars to 1 or ommiting it will create a solid walkway
# an odd value for bars (3,5,7) looks best
$p = { texture => $wood, bartexture => $wood2, barwidth => 1.5, thick => 1.5, 
       bars => 9,};
$bunch->merge( barBridge(0, 8,-2,12,24,12,$p) );

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

# EOF

1;
