#endif
#include <GL/glut.h>
-#include <XGL/xgl.h>
+#include <simgear/xgl/xgl.h>
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
#include <vector>
#include STL_STRING
-#include <plib/sg.h>
+#include <plib/ssg.h> // plib includes
+
+#include <simgear/bucket/newbucket.hxx>
+#include <simgear/math/point3d.hxx>
-#include <Bucket/newbucket.hxx>
-#include <Math/mat3.h>
-#include <Math/point3d.hxx>
#include <Objects/fragment.hxx>
-#ifdef FG_HAVE_NATIVE_SGI_COMPILERS
+#if defined( sgi )
#include <strings.h>
#endif
// Tile state
enum tile_state {
Unused = 0,
- Scheduled = 1,
- Loaded = 2
+ Scheduled_for_use = 1,
+ Scheduled_for_cache = 2,
+ Loaded = 3,
+ Cached = 4
};
public:
typedef container::iterator FragmentIterator;
typedef container::const_iterator FragmentConstIterator;
+ typedef vector < sgVec3 * > free_vec3_list;
+ typedef vector < sgVec2 * > free_vec2_list;
+ typedef vector < unsigned short * > free_index_list;
+
public:
// node list (the per fragment face lists reference this node list)
point_list nodes;
double bounding_radius;
Point3D offset;
- // model view matrix for this tile
- GLfloat 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
+ // the tile cache will keep track here if the tile is being used
tile_state state;
container fragment_list;
+ // ssg related structures
+ // sgVec3 *vtlist;
+ // sgVec3 *vnlist;
+ // sgVec2 *tclist;
+
+ // list of pointers to memory chunks that need to be freed when
+ // tile entry goes away
+ free_vec3_list vec3_ptrs;
+ free_vec2_list vec2_ptrs;
+ free_index_list index_ptrs;
+
+ // ssg tree structure for this tile is as follows:
+ // ssgRoot(scene)
+ // - ssgBranch(terrain)
+ // - ssgSelector(tile)
+ // - ssgTransform(tile)
+ // - ssgRangeSelector(tile)
+ // - ssgEntity(tile)
+ // - kid1(fan)
+ // - kid2(fan)
+ // ...
+ // - kidn(fan)
+
+ // selector (turn tile on/off)
+ ssgSelector *select_ptr;
+
+ // pointer to ssg transform for this tile
+ ssgTransform *transform_ptr;
+
+ // pointer to ssg range selector for this tile
+ ssgRangeSelector *range_ptr;
+
public:
// Constructor
}
// Step through the fragment list, deleting the display list, then
- // the fragment, until the list is empty.
- void release_fragments();
+ // the fragment, until the list is empty. Also delete the arrays
+ // used by ssg as well as the whole ssg branch
+ void free_tile();
// Calculate this tile's offset
- void SetOffset( const Point3D& off)
+ void SetOffset( const Point3D& p)
{
- offset = center - off;
+ offset = center - p;
}
// Return this tile's offset
inline Point3D get_offset( void ) const { return offset; }
-
- // Calculate the model_view transformation matrix for this tile
- inline void update_view_matrix(GLfloat *MODEL_VIEW)
- {
-
-#if defined( USE_MEM ) || defined( WIN32 )
- memcpy( model_view, MODEL_VIEW, 16*sizeof(GLfloat) );
-#else
- bcopy( MODEL_VIEW, model_view, 16*sizeof(GLfloat) );
-#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() );
- // 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
- }
-
inline bool is_unused() const { return state == Unused; }
+ inline bool is_scheduled_for_use() const {
+ return state == Scheduled_for_use;
+ }
+ inline bool is_scheduled_for_cache() const {
+ return state == Scheduled_for_cache;
+ }
inline bool is_loaded() const { return state == Loaded; }
+ inline bool is_cached() const { return state == Cached; }
inline void mark_unused() { state = Unused; }
- inline void mark_scheduled() { state = Scheduled; }
+ inline void mark_scheduled_for_use() { state = Scheduled_for_use; }
+ inline void mark_scheduled_for_cache() { state = Scheduled_for_use; }
inline void mark_loaded() { state = Loaded; }
+
+
+ // when a tile is still in the cache, but not in the immediate
+ // draw l ist, it can still remain in the scene graph, but we use
+ // a range selector to disable it from ever being drawn.
+ void ssg_disable();
};