]> git.mxchange.org Git - flightgear.git/commitdiff
Initial revision.
authorcurt <curt>
Mon, 22 Mar 1999 23:51:51 +0000 (23:51 +0000)
committercurt <curt>
Mon, 22 Mar 1999 23:51:51 +0000 (23:51 +0000)
GenOutput/Makefile.am [new file with mode: 0644]
GenOutput/genobj.cxx [new file with mode: 0644]
GenOutput/genobj.hxx [new file with mode: 0644]

diff --git a/GenOutput/Makefile.am b/GenOutput/Makefile.am
new file mode 100644 (file)
index 0000000..28ad535
--- /dev/null
@@ -0,0 +1,9 @@
+noinst_LIBRARIES = libGenOutput.a
+
+libGenOutput_a_SOURCES = genobj.cxx genobj.hxx
+
+INCLUDES += \
+       -I$(top_builddir) \
+       -I$(top_builddir)/Lib \
+       -I$(top_builddir)/Tools/Lib \
+       -I$(top_builddir)/Tools/Construct
diff --git a/GenOutput/genobj.cxx b/GenOutput/genobj.cxx
new file mode 100644 (file)
index 0000000..634765d
--- /dev/null
@@ -0,0 +1,85 @@
+// genobj.hxx -- Generate the flight gear "obj" file format from the
+//               triangle output
+//
+// Written by Curtis Olson, started March 1999.
+//
+// Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+// (Log is kept at end of this file)
+
+
+#include "genobj.hxx"
+
+
+// Calculate the global bounding sphere from all the input points.
+// Center is the average of the points.
+static void calc_gbs( const trinode_list& nodelist, Point3D *center, 
+                     double *radius )
+{
+    double x = 0;
+    double y = 0;
+    double z = 0;
+
+    double dist_squared;
+    double radius_squared = 0;
+    
+    const_trinode_list_iterator current = nodelist.begin();
+    const_trinode_list_iterator last = nodelist.end();
+
+    for ( ; current != last; ++current ) {
+       x += current->x();
+       y += current->y();
+       z += current->z();
+    }
+
+    x /= nodelist.size();
+    y /= nodelist.size();
+    z /= nodelist.size();
+
+    *center = Point3D(x, y, z);
+
+    current = nodelist.begin();
+    for ( ; current != last; ++current ) {
+        dist_squared = center->distance3Dsquared(*current);
+       if ( dist_squared > radius_squared ) {
+            radius_squared = dist_squared;
+        }
+    }
+
+    *radius = sqrt(radius_squared);
+}
+
+
+// generate the flight gear format from the triangulation
+int fgGenOutput( const FGTriangle& t ) {
+    Point3D gbs;
+    double gradius;
+
+    FGTriNodes trinodes = t.get_out_nodes();
+    trinode_list nodelist = trinodes.get_node_list();
+
+    calc_gbs( nodelist, &gbs, &gradius );
+    cout << "center = " << gbs << " radius = " << gradius << endl;
+    return 1;
+}
+
+
+// $Log$
+// Revision 1.1  1999/03/22 23:51:51  curt
+// Initial revision.
+//
diff --git a/GenOutput/genobj.hxx b/GenOutput/genobj.hxx
new file mode 100644 (file)
index 0000000..45f2b00
--- /dev/null
@@ -0,0 +1,48 @@
+// genobj.hxx -- Generate the flight gear "obj" file format from the
+//               triangle output
+//
+// Written by Curtis Olson, started March 1999.
+//
+// Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+// (Log is kept at end of this file)
+
+
+#ifndef _GENOBJ_HXX
+#define _GENOBJ_HXX
+
+
+#ifndef __cplusplus                                                          
+# error This library requires C++
+#endif                                   
+
+
+#include <Triangulate/triangle.hxx>
+
+
+// generate the flight gear format from the triangulation
+int fgGenOutput( const FGTriangle& t );
+
+
+#endif // _GENOBJ_HXX
+
+
+// $Log$
+// Revision 1.1  1999/03/22 23:51:51  curt
+// Initial revision.
+//