summaryrefslogtreecommitdiff
path: root/bin/dat2hackvr.pl
blob: 03c5315fdb623f35fd468f8be05d12cb8d70021f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl

use strict;

die "usage: dat2hackvr.pl name file\n" unless $ARGV[0];

my $line;
my $prev;
my $first;
open(FILE,$ARGV[1]) if $ARGV[1];
while($line=<FILE>) {
 chomp $line;
 if(!($line =~ m/^#/)) {
  if($line eq "") {
#   print $ARGV[0];
#   print " addtriangle ";
#   print $prev . " 0 " . $first . " 0 " . $first . " 0";
#   print "\n";
   $first="";
  } else {
   if($prev ne "") {
    print $ARGV[0];
    print " addshape 2 2 ";
    print $line . " 0 " . $prev . " 0";
    print "\n";
   }
   $prev="";
  }
  if($first eq "") {
   $first=$line;
  }
  $prev=$line;
 }
}