#!/usr/bin/perl
use strict;
use Travertine;
use Getopt::Std;
use vars qw($opt_d $opt_f $opt_s);

getopts ("d:f:s:");

my $SCR_DIR = defined $opt_d ? $opt_d : "$ENV{HOME}/quake3/src/screenshots";
my $FRAME_RATE = defined $opt_f ? $opt_f : 20;
my $SCALE_SIZE = defined $opt_s ? $opt_s : 50;

my $qmap = shift;
if (!defined $qmap) { 
    twarn "Usage: qviz <q3map>";
    exit 1;
}

my $dimsfile = "$SCR_DIR/$qmap.dims";
my $imagfile = "$SCR_DIR/p2-$qmap.jpg";    # has power-of-2 dimensions

tdie "$dimsfile does not exists or is not readable" if !-r $dimsfile;
tdie "$imagfile does not exists or is not readable" if !-r $imagfile;

psystem ("./viz -P -L --scalesize $SCALE_SIZE -i $imagfile -d $dimsfile -f $FRAME_RATE");
