diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/dat2hackvr.pl | 34 | ||||
-rwxr-xr-x | tools/obj2hackvr.pl | 17 |
2 files changed, 50 insertions, 1 deletions
diff --git a/tools/dat2hackvr.pl b/tools/dat2hackvr.pl new file mode 100755 index 0000000..2a2fbe1 --- /dev/null +++ b/tools/dat2hackvr.pl @@ -0,0 +1,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 "; + print $line . " 0 " . $prev . " 0"; + print "\n"; + } + $prev=""; + } + if($first eq "") { + $first=$line; + } + $prev=$line; + } +} diff --git a/tools/obj2hackvr.pl b/tools/obj2hackvr.pl index 793b5ea..d8727e2 100755 --- a/tools/obj2hackvr.pl +++ b/tools/obj2hackvr.pl @@ -32,13 +32,28 @@ while(<FILE>) { # } #} +#foreach $tmp (@faces) { +# @points=split(/ /,$tmp); +# @points = map { $_ =~ s/\/.+$//g; $_; } @points; +## print @points; +# print $ARGV[0]; +# print " addshape "; +# print @points+0; +# for($i=0;$i<(@points+0);$i++) { +# print " "; +# print $vertices[$points[$i]]; +# } +# print "\n"; +#} + +#convert to triangles foreach $tmp (@faces) { @points=split(/ /,$tmp); @points = map { $_ =~ s/\/.+$//g; $_; } @points; # print @points; for($i=2;$i<(@points);$i++) { print $ARGV[0]; - print " addtriangle "; + print " addshape 3 "; print $vertices[$points[0]-1]; print " "; print $vertices[$points[$i-1]-1]; |