summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2016-10-18 20:22:38 -0500
committerepoch <epoch@hacking.allowed.org>2016-10-18 20:22:38 -0500
commit11844154cb30223fdaa977d659b98626e99f00ce (patch)
tree4ebc9b0c0267365cb1f96da0ee1c917f2eec0696 /tools
parentbd213282ff7ed8f2854ab7d628a7aabb7efc85d9 (diff)
downloadhackvr-11844154cb30223fdaa977d659b98626e99f00ce.tar.gz
hackvr-11844154cb30223fdaa977d659b98626e99f00ce.zip
lets see if this works..
Diffstat (limited to 'tools')
-rwxr-xr-xtools/obj2hackvr.pl45
1 files changed, 45 insertions, 0 deletions
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";
+ }
+}