1 // tile.hxx -- routines to handle a scenery tile
3 // Written by Curtis Olson, started May 1998.
5 // Copyright (C) 1998 Curtis L. Olson - curt@infoplane.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
43 #include <Include/compiler.h>
48 #include <Bucket/newbucket.hxx>
49 #include <Math/mat3.h>
50 #include <Math/point3d.hxx>
51 #include <Objects/fragment.hxx>
53 #ifdef FG_HAVE_NATIVE_SGI_COMPILERS
66 typedef vector < fgFRAGMENT > container;
67 typedef container::iterator FragmentIterator;
68 typedef container::const_iterator FragmentConstIterator;
71 // node list (the per fragment face lists reference this node list)
75 // culling data for whole tile (course grain culling)
77 double bounding_radius;
79 GLdouble model_view[16];
81 // this tile's official location in the world
84 // the tile cache will mark here if the tile is being used
87 container fragment_list;
91 FragmentIterator begin() { return fragment_list.begin(); }
92 FragmentConstIterator begin() const { return fragment_list.begin(); }
94 FragmentIterator end() { return fragment_list.end(); }
95 FragmentConstIterator end() const { return fragment_list.end(); }
97 void add_fragment( fgFRAGMENT& frag ) {
99 fragment_list.push_back( frag );
103 size_t num_fragments() const {
104 return fragment_list.size();
107 // Step through the fragment list, deleting the display list, then
108 // the fragment, until the list is empty.
109 void release_fragments();
111 // int ObjLoad( const string& path, const fgBUCKET& p );
119 // Calculate this tile's offset
120 void SetOffset( const Point3D& off)
122 offset = center - off;
126 // Calculate the model_view transformation matrix for this tile
128 UpdateViewMatrix(GLdouble *MODEL_VIEW)
131 #if defined( USE_MEM ) || defined( WIN32 )
132 memcpy( model_view, MODEL_VIEW, 16*sizeof(GLdouble) );
134 bcopy( MODEL_VIEW, model_view, 16*sizeof(GLdouble) );
137 // This is equivalent to doing a glTranslatef(x, y, z);
138 model_view[12] += (model_view[0]*offset.x() +
139 model_view[4]*offset.y() +
140 model_view[8]*offset.z());
141 model_view[13] += (model_view[1]*offset.x() +
142 model_view[5]*offset.y() +
143 model_view[9]*offset.z());
144 model_view[14] += (model_view[2]*offset.x() +
145 model_view[6]*offset.y() +
146 model_view[10]*offset.z() );
147 // m[15] += (m[3]*x + m[7]*y + m[11]*z);
148 // m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
149 // so m[15] is unchanged
155 fgTILE( const fgTILE& );
156 fgTILE& operator = ( const fgTILE& );