#include <GL/glut.h>
#include <XGL/xgl.h>
-#if defined ( __sun__ )
-extern "C" void *memmove(void *, const void *, size_t);
-extern "C" void *memset(void *, int, size_t);
-#endif
+#include <Include/compiler.h>
-#include <list> // STL list
+#include <vector>
+#include STL_STRING
#include <Bucket/bucketutils.h>
-#include <Include/fg_types.h>
#include <Math/mat3.h>
+#include <Math/point3d.hxx>
#include <Objects/fragment.hxx>
-#ifdef NEEDNAMESPACESTD
-using namespace std;
-#endif
+FG_USING_STD(string);
+FG_USING_STD(vector);
+#ifdef FG_HAVE_NATIVE_SGI_COMPILERS
+#include <strings.h>
+#endif
// Scenery tile class
class fgTILE {
public:
+ typedef vector < fgFRAGMENT > container;
+ typedef container::iterator FragmentIterator;
+ typedef container::const_iterator FragmentConstIterator;
+
+public:
// node list (the per fragment face lists reference this node list)
double (*nodes)[3];
int ncount;
// culling data for whole tile (course grain culling)
- fgPoint3d center;
+ Point3D center;
double bounding_radius;
- fgPoint3d offset;
+ Point3D offset;
GLdouble model_view[16];
// this tile's official location in the world
fgBUCKET tile_bucket;
// the tile cache will mark here if the tile is being used
- int used;
+ bool used;
+
+ container fragment_list;
+
+public:
+
+ FragmentIterator begin() { return fragment_list.begin(); }
+ FragmentConstIterator begin() const { return fragment_list.begin(); }
+
+ FragmentIterator end() { return fragment_list.end(); }
+ FragmentConstIterator end() const { return fragment_list.end(); }
+
+ void add_fragment( fgFRAGMENT& frag ) {
+ frag.tile_ptr = this;
+ fragment_list.push_back( frag );
+ }
+
+ //
+ size_t num_fragments() const {
+ return fragment_list.size();
+ }
- list < fgFRAGMENT > fragment_list;
+ // Step through the fragment list, deleting the display list, then
+ // the fragment, until the list is empty.
+ void release_fragments();
+
+// int ObjLoad( const string& path, const fgBUCKET& p );
// Constructor
fgTILE ( void );
~fgTILE ( void );
// Calculate this tile's offset
- void
- fgTILE::SetOffset( fgPoint3d *off)
+ void SetOffset( const Point3D& off)
{
- offset.x = center.x - off->x;
- offset.y = center.y - off->y;
- offset.z = center.z - off->z;
+ offset = center - off;
}
// Calculate the model_view transformation matrix for this tile
inline void
- fgTILE::UpdateViewMatrix(GLdouble *MODEL_VIEW)
+ UpdateViewMatrix(GLdouble *MODEL_VIEW)
{
-#ifdef WIN32
+#if defined( USE_MEM ) || defined( WIN32 )
memcpy( model_view, MODEL_VIEW, 16*sizeof(GLdouble) );
-#else
+#else
bcopy( MODEL_VIEW, model_view, 16*sizeof(GLdouble) );
#endif
// This is equivalent to doing a glTranslatef(x, y, z);
- model_view[12] += (model_view[0]*offset.x + model_view[4]*offset.y +
- model_view[8]*offset.z);
- model_view[13] += (model_view[1]*offset.x + model_view[5]*offset.y +
- model_view[9]*offset.z);
- model_view[14] += (model_view[2]*offset.x + model_view[6]*offset.y +
- model_view[10]*offset.z);
+ model_view[12] += (model_view[0]*offset.x() +
+ model_view[4]*offset.y() +
+ model_view[8]*offset.z());
+ model_view[13] += (model_view[1]*offset.x() +
+ model_view[5]*offset.y() +
+ model_view[9]*offset.z());
+ model_view[14] += (model_view[2]*offset.x() +
+ model_view[6]*offset.y() +
+ model_view[10]*offset.z() );
// m[15] += (m[3]*x + m[7]*y + m[11]*z);
// m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
// so m[15] is unchanged
}
+private:
+
+ // not defined
+ fgTILE( const fgTILE& );
+ fgTILE& operator = ( const fgTILE& );
};
// $Log$
+// Revision 1.25 1999/03/02 01:03:30 curt
+// Tweaks for building with native SGI compilers.
+//
+// Revision 1.24 1999/02/26 22:10:02 curt
+// Added initial support for native SGI compilers.
+//
+// Revision 1.23 1999/02/02 20:13:41 curt
+// MSVC++ portability changes by Bernie Bright:
+//
+// Lib/Serial/serial.[ch]xx: Initial Windows support - incomplete.
+// Simulator/Astro/stars.cxx: typo? included <stdio> instead of <cstdio>
+// Simulator/Cockpit/hud.cxx: Added Standard headers
+// Simulator/Cockpit/panel.cxx: Redefinition of default parameter
+// Simulator/Flight/flight.cxx: Replaced cout with FG_LOG. Deleted <stdio.h>
+// Simulator/Main/fg_init.cxx:
+// Simulator/Main/GLUTmain.cxx:
+// Simulator/Main/options.hxx: Shuffled <fg_serial.hxx> dependency
+// Simulator/Objects/material.hxx:
+// Simulator/Time/timestamp.hxx: VC++ friend kludge
+// Simulator/Scenery/tile.[ch]xx: Fixed using std::X declarations
+// Simulator/Main/views.hxx: Added a constant
+//
+// Revision 1.22 1998/12/03 01:18:16 curt
+// Converted fgFLIGHT to a class.
+// Tweaks for Sun Portability.
+// Tweaked current terrain elevation code as per NHV.
+//
+// Revision 1.21 1998/11/09 23:40:47 curt
+// Bernie Bright <bbright@c031.aone.net.au> writes:
+// I've made some changes to the Scenery handling. Basically just tidy ups.
+// The main difference is in tile.[ch]xx where I've changed list<fgFRAGMENT> to
+// vector<fgFRAGMENT>. Studying our usage patterns this seems reasonable.
+// Lists are good if you need to insert/delete elements randomly but we
+// don't do that. All access seems to be sequential. Two additional
+// benefits are smaller memory usage - each list element requires pointers
+// to the next and previous elements, and faster access - vector iterators
+// are smaller and faster than list iterators. This should also help
+// Charlie Hotchkiss' problem when compiling with Borland and STLport.
+//
+// ./Lib/Bucket/bucketutils.hxx
+// Convenience functions for fgBUCKET.
+//
+// ./Simulator/Scenery/tile.cxx
+// ./Simulator/Scenery/tile.hxx
+// Changed fragment list to a vector.
+// Added some convenience member functions.
+//
+// ./Simulator/Scenery/tilecache.cxx
+// ./Simulator/Scenery/tilecache.hxx
+// use const fgBUCKET& instead of fgBUCKET* where appropriate.
+//
+// ./Simulator/Scenery/tilemgr.cxx
+// ./Simulator/Scenery/tilemgr.hxx
+// uses all the new convenience functions.
+//
+// Revision 1.20 1998/10/16 00:55:46 curt
+// Converted to Point3D class.
+//
// Revision 1.19 1998/09/17 18:36:17 curt
// Tweaks and optimizations by Norman Vine.
//