From 11844154cb30223fdaa977d659b98626e99f00ce Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 18 Oct 2016 20:22:38 -0500 Subject: lets see if this works.. --- tools/obj2hackvr.pl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tools/obj2hackvr.pl (limited to 'tools') diff --git a/tools/obj2hackvr.pl b/tools/obj2hackvr.pl new file mode 100755 index 0000000..610e04e --- /dev/null +++ b/tools/obj2hackvr.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use strict; + +my $i; +my $j; +my $com; +my @vertices; +my @faces; +my @linepart; +my @parts; +my @points; +my @tmp; +my $tmp; +while(<>) { + chomp; + @linepart=split(/ /,$_,2); + $com=$linepart[0]; + if($com eq "v") { + push(@vertices,$linepart[1]); + } + if($com eq "f") { + push(@faces,$linepart[1]); + } +} +#foreach $tmp (@vertices) { +# foreach(@$tmp) { +# print $tmp . "\n"; +# } +#} + +foreach $tmp (@faces) { + @points=split(/ /,$tmp); + @points = map { $_ =~ s/\/.+$//g; $_; } @points; +# print @points; + for($i=2;$i<(@points);$i++) { + print "deer addtriangle "; + print $vertices[$points[0]-1]; + print " "; + print $vertices[$points[$i-1]-1]; + print " "; + print $vertices[$points[$i]-1]; + print "\n"; + } +} -- cgit v1.2.3