1999-03-22 23:51:51 +00:00
|
|
|
// 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$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _GENOBJ_HXX
|
|
|
|
#define _GENOBJ_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-03-27 05:23:22 +00:00
|
|
|
#include <Include/compiler.h>
|
|
|
|
|
|
|
|
#include STL_STRING
|
|
|
|
|
1999-03-25 19:04:21 +00:00
|
|
|
#include <Bucket/newbucket.hxx>
|
1999-03-23 22:02:03 +00:00
|
|
|
#include <Math/fg_geodesy.hxx>
|
1999-03-23 17:44:49 +00:00
|
|
|
#include <Math/point3d.hxx>
|
1999-03-29 13:11:00 +00:00
|
|
|
|
1999-03-31 23:46:48 +00:00
|
|
|
#include <Combine/genfans.hxx>
|
1999-03-29 13:11:00 +00:00
|
|
|
#include <Main/construct_types.hxx>
|
1999-05-02 18:41:24 +00:00
|
|
|
#include <Main/construct.hxx>
|
1999-03-22 23:51:51 +00:00
|
|
|
#include <Triangulate/triangle.hxx>
|
|
|
|
|
1999-03-27 05:23:22 +00:00
|
|
|
FG_USING_STD(string);
|
|
|
|
FG_USING_STD(vector);
|
|
|
|
|
1999-03-22 23:51:51 +00:00
|
|
|
|
1999-05-12 02:09:02 +00:00
|
|
|
typedef vector < int_list > tex_list;
|
|
|
|
typedef tex_list::iterator tex_list_iterator;
|
|
|
|
typedef tex_list::const_iterator const_tex_list_iterator;
|
|
|
|
|
1999-03-23 17:44:49 +00:00
|
|
|
class FGGenOutput {
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
1999-05-02 18:41:24 +00:00
|
|
|
// node list in geodetic coordinates
|
1999-03-23 22:02:03 +00:00
|
|
|
point_list geod_nodes;
|
|
|
|
|
|
|
|
// triangles (by index into point list)
|
|
|
|
triele_list tri_elements;
|
|
|
|
|
1999-05-12 02:09:02 +00:00
|
|
|
// texture coordinates
|
|
|
|
FGTriNodes tex_coords;
|
|
|
|
|
1999-03-29 13:11:00 +00:00
|
|
|
// fan list
|
1999-03-30 23:50:43 +00:00
|
|
|
fan_list fans[FG_MAX_AREA_TYPES];
|
1999-03-29 13:11:00 +00:00
|
|
|
|
1999-05-12 02:09:02 +00:00
|
|
|
// textures pointer list
|
|
|
|
tex_list textures[FG_MAX_AREA_TYPES];
|
|
|
|
|
1999-03-23 22:02:03 +00:00
|
|
|
// global bounding sphere
|
|
|
|
Point3D gbs_center;
|
|
|
|
double gbs_radius;
|
|
|
|
|
|
|
|
// calculate the global bounding sphere. Center is the average of
|
|
|
|
// the points.
|
1999-05-02 18:41:24 +00:00
|
|
|
void calc_gbs( FGConstruct& c );
|
1999-03-23 22:02:03 +00:00
|
|
|
|
1999-03-27 14:06:42 +00:00
|
|
|
// caclulate the bounding sphere for a list of triangle faces
|
1999-05-02 18:41:24 +00:00
|
|
|
void calc_group_bounding_sphere( FGConstruct& c, const fan_list& fans,
|
1999-03-27 14:06:42 +00:00
|
|
|
Point3D *center, double *radius );
|
|
|
|
|
1999-03-23 22:02:03 +00:00
|
|
|
// caclulate the bounding sphere for the specified triangle face
|
1999-05-02 18:41:24 +00:00
|
|
|
void calc_bounding_sphere( FGConstruct& c, const FGTriEle& t,
|
1999-03-27 14:06:42 +00:00
|
|
|
Point3D *center, double *radius );
|
1999-03-23 17:44:49 +00:00
|
|
|
|
1999-05-12 02:09:02 +00:00
|
|
|
// traverse the specified fan and attempt to calculate "none
|
|
|
|
// stretching" texture coordinates
|
|
|
|
int_list calc_tex_coords( point_list geod_nodes, int_list fan );
|
|
|
|
|
1999-03-23 17:44:49 +00:00
|
|
|
public:
|
|
|
|
|
1999-03-23 22:02:03 +00:00
|
|
|
// Constructor && Destructor
|
|
|
|
inline FGGenOutput() { }
|
|
|
|
inline ~FGGenOutput() { }
|
|
|
|
|
|
|
|
// build the necessary output structures based on the
|
|
|
|
// triangulation data
|
1999-05-02 22:11:30 +00:00
|
|
|
int build( FGConstruct& c );
|
1999-03-23 17:44:49 +00:00
|
|
|
|
1999-03-23 22:02:03 +00:00
|
|
|
// write out the fgfs scenery file
|
1999-05-02 18:41:24 +00:00
|
|
|
int write( FGConstruct &c );
|
1999-03-23 22:02:03 +00:00
|
|
|
};
|
1999-03-22 23:51:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif // _GENOBJ_HXX
|
|
|
|
|
|
|
|
|