]> git.mxchange.org Git - flightgear.git/commitdiff
Fixed problem with averaged vertex normals.
authorcurt <curt>
Tue, 2 Dec 1997 13:13:32 +0000 (13:13 +0000)
committercurt <curt>
Tue, 2 Dec 1997 13:13:32 +0000 (13:13 +0000)
Tri2obj/Makefile
Tri2obj/tri2obj.c

index 9e4025bf1c814101a524a5f992176d47e9b9876d..87ddbbd49c26f8dd7f93f26ad9e091510d93b443 100644 (file)
@@ -33,7 +33,7 @@ OFILES = $(CFILES:.c=.o)
 include ../make.inc
 
 
-CFLAGS = $(FG_CFLAGS) -g
+CFLAGS = $(FG_CFLAGS) -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math
 
 
 #---------------------------------------------------------------------------
@@ -66,6 +66,9 @@ tri2obj.o: tri2obj.c
 
 #---------------------------------------------------------------------------
 # $Log$
+# Revision 1.3  1997/12/02 13:13:32  curt
+# Fixed problem with averaged vertex normals.
+#
 # Revision 1.2  1997/11/14 00:29:13  curt
 # Transform scenery coordinates at this point in pipeline when scenery is
 # being translated to .obj format, not when it is being loaded into the end
index cc529dd1ddd46034063c5f01a6f00d40fca0aec8..ef1007e6754d41b90cca0a613b414d9cfc42d15d 100644 (file)
@@ -171,7 +171,7 @@ void triload(char *basename) {
 /* dump in WaveFront .obj format */
 void dump_obj(char *basename) {
     char objname[256];
-    double n1[3], n2[3], n3[3];
+    double n1[3], n2[3], n3[3], norm[3], temp;
     FILE *obj;
     int i, t1, t2, t3, count;
 
@@ -214,10 +214,13 @@ void dump_obj(char *basename) {
            count = 3;
        }
 
-       fprintf(obj, "vn %.4f %.4f %.4f\n", 
-               ( n1[0] + n2[0] + n3[0] ) / (double)count,
-               ( n1[1] + n2[1] + n3[1] ) / (double)count,
-               ( n1[2] + n2[2] + n3[2] ) / (double)count );
+       norm[0] = ( n1[0] + n2[0] + n3[0] ) / (double)count;
+       norm[1] = ( n1[1] + n2[1] + n3[1] ) / (double)count;
+       norm[2] = ( n1[2] + n2[2] + n3[2] ) / (double)count;
+
+       MAT3_NORMALIZE_VEC(norm, temp);
+       
+       fprintf(obj, "vn %.4f %.4f %.4f\n", norm[0], norm[1], norm[2]);
     }
 
     /* dump faces */
@@ -248,9 +251,12 @@ int main(int argc, char **argv) {
 
 
 /* $Log$
-/* Revision 1.3  1997/11/15 18:05:05  curt
-/* minor tweaks ...
+/* Revision 1.4  1997/12/02 13:13:32  curt
+/* Fixed problem with averaged vertex normals.
 /*
+ * Revision 1.3  1997/11/15 18:05:05  curt
+ * minor tweaks ...
+ *
  * Revision 1.2  1997/11/14 00:29:13  curt
  * Transform scenery coordinates at this point in pipeline when scenery is
  * being translated to .obj format, not when it is being loaded into the end