- my $nfaces = ($#faces+1)/3;
- for ($i = 0; $i < $nfaces; $i++) {
- my $a = $faces[$i*3];
- my $b = $faces[$i*3+1];
- my $c = $faces[$i*3+2];
-
- my $x1 = $verts[$a*3]; my $nx1 = $norms[$a*3];
- my $y1 = $verts[$a*3+1]; my $ny1 = $norms[$a*3+1];
- my $z1 = $verts[$a*3+2]; my $nz1 = $norms[$a*3+2];
-
- my $x2 = $verts[$b*3]; my $nx2 = $norms[$b*3];
- my $y2 = $verts[$b*3+1]; my $ny2 = $norms[$b*3+1];
- my $z2 = $verts[$b*3+2]; my $nz2 = $norms[$b*3+2];
-
- my $x3 = $verts[$c*3]; my $nx3 = $norms[$c*3];
- my $y3 = $verts[$c*3+1]; my $ny3 = $norms[$c*3+1];
- my $z3 = $verts[$c*3+2]; my $nz3 = $norms[$c*3+2];
-
- if (!defined($nz3)) {
- my ($nx, $ny, $nz) = face_normal ($x1, $y1, $z1,
- $x2, $y2, $z2,
- $x3, $y3, $z3);
- $nx1 = $nx2 = $nx3 = $nx;
- $ny1 = $ny2 = $ny3 = $ny;
- $nz1 = $nz2 = $nz3 = $nz;
- }