1
0
Fork 0

Initial revision.

This commit is contained in:
curt 1999-03-22 23:51:51 +00:00
parent 4525fcbd55
commit da6ff21001
3 changed files with 142 additions and 0 deletions

9
GenOutput/Makefile.am Normal file
View file

@ -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

85
GenOutput/genobj.cxx Normal file
View file

@ -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.
//

48
GenOutput/genobj.hxx Normal file
View file

@ -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.
//