diff options
author | epoch <epoch@hacking.allowed.org> | 2019-02-05 21:48:29 -0600 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2019-02-05 21:48:29 -0600 |
commit | 420eeee620a287ac5bf133f8a17329a7182d5bbf (patch) | |
tree | 407cd59748e0e5ef4f88b15305dd303aa64cf8da /bin/obj2dat.pl | |
parent | 848a823b1287d8804e8d6170c3ca30ccf7689784 (diff) | |
download | hackvr-420eeee620a287ac5bf133f8a17329a7182d5bbf.tar.gz hackvr-420eeee620a287ac5bf133f8a17329a7182d5bbf.zip |
forgot to add bin dir that contains a LOT of the handy stuff
Diffstat (limited to 'bin/obj2dat.pl')
-rwxr-xr-x | bin/obj2dat.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/obj2dat.pl b/bin/obj2dat.pl new file mode 100755 index 0000000..a1f177e --- /dev/null +++ b/bin/obj2dat.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use strict; + +die "usage: obj2dat.pl file\n" unless $ARGV[0]; + +my $i; +my $j; +my $com; +my @vertices; +my @faces; +my @linepart; +my @parts; +my @points; +my @tmp; +my $tmp; +my $color=2; +open(FILE,$ARGV[0]) if $ARGV[0]; +while(<FILE>) { + chomp; + $_ =~ s/[\r\n]//g; + @linepart=split(/ /,$_,2); + $com=$linepart[0]; + if($com eq "v") { + push(@vertices,$linepart[1]); + } + if($com eq "f") { + push(@faces,$linepart[1]); + } +} + +foreach $tmp (@faces) { + @points=split(/ /,$tmp); + @points = map { $_ =~ s/\/.+$//g; $_; } @points; + for($i=0;$i<(@points);$i++) { + print $vertices[$points[$i]-1]; + print "\n"; + } + print "\n"; + print "\n"; +} |