Newer
Older
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
35
36
37
38
#! /usr/bin/perl
if(-t STDIN && @ARGV == 0) {
print STDERR "Usage: $0 [infile.vect] > outfile.obj
Convert a geomview/OOGL .vect file into a .obj model,
using 2-vertex \"faces\" to represent single line segments.
";
exit(1);
}
while(<>) {
s/#.*//;
next if /^\s*$/;
push(@tok, split(' '));
}
unless(shift(@tok) eq "VECT") {
print STDERR "$ARGV: not a VECT file\n";
exit(1);
}
($nvects, $nverts, $ncolors) = splice(@tok, 0, 3);
@nv = splice(@tok, 0, $nvects);
@nc = splice(@tok, 0, $nvects);
for($i = 0; $i < $nverts; $i++) {
print "v ", join(" ", @tok[$i*3 .. $i*3+2]), "\n";
}
$vno = 1;
for($i = 0; $i < $nvects; $i++) {
$nvnow = $nv[$i];
for($j = 1; $j < $nvnow; $j++) {
printf "f %d %d\n", $vno, $vno+1;
$vno++;
}
$vno++;
}