]> git.mxchange.org Git - flightgear.git/blob - Objects/fragment.hxx
Moved from ../Scenery
[flightgear.git] / Objects / fragment.hxx
1 // fragment.hxx -- routines to handle "atomic" display objects
2 //
3 // Written by Curtis Olson, started August 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifndef _FRAGMENT_HXX
26 #define _FRAGMENT_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 #if defined ( __sun__ )
45 extern "C" void *memmove(void *, const void *, size_t);
46 extern "C" void *memset(void *, int, size_t);
47 #endif
48
49 #include <list>         // STL list
50
51 #include <Bucket/bucketutils.h>
52 #include <Include/fg_types.h>
53 #include <Math/mat3.h>
54
55 #ifdef NEEDNAMESPACESTD
56 using namespace std;
57 #endif
58
59
60 // Maximum nodes per tile
61 #define MAX_NODES 2000
62
63
64 // Forward declarations
65 class fgTILE;
66 class fgMATERIAL;
67
68
69 class fgFACE {
70 public:
71     int n1, n2, n3;
72
73     fgFACE();
74     ~fgFACE();
75     fgFACE( const fgFACE & image );
76     bool operator < ( const fgFACE & rhs );
77     bool operator == ( const fgFACE & rhs );
78 };
79
80
81 // Object fragment data class
82 class fgFRAGMENT {
83
84 public:
85     // culling data for this object fragment (fine grain culling)
86     fgPoint3d center;
87     double bounding_radius;
88
89     // variable offset data for this object fragment for this frame
90     // fgCartesianPoint3d tile_offset;
91
92     // saved transformation matrix for this fragment (used by renderer)
93     // GLfloat matrix[16];
94     
95     // tile_ptr & material_ptr are set so that when we traverse the
96     // list of fragments we can quickly reference back the tile or
97     // material property this fragment is assigned to.
98
99     // material property pointer
100     fgMATERIAL *material_ptr;
101
102     // tile pointer
103     fgTILE *tile_ptr;
104
105     // OpenGL display list for fragment data
106     GLint display_list;
107
108     // face list (this indexes into the master tile vertex list)
109     list < fgFACE > faces;
110
111     // number of faces in this fragment
112     int num_faces;
113
114     // Add a face to the face list
115     void add_face(int n1, int n2, int n3);
116
117     // test if line intesects with this fragment.  p0 and p1 are the
118     // two line end points of the line.  If side_flag is true, check
119     // to see that end points are on opposite sides of face.  Returns
120     // 1 if it intersection found, 0 otherwise.  If it intesects,
121     // result is the point of intersection
122     int intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag,
123                    fgPoint3d *result);
124
125     // Constructors
126     fgFRAGMENT ();
127     fgFRAGMENT ( const fgFRAGMENT &image );
128
129     // Destructor
130     ~fgFRAGMENT ( );
131
132     // operators
133     fgFRAGMENT & operator = ( const fgFRAGMENT & rhs );
134     bool operator == ( const fgFRAGMENT & rhs );
135     bool operator <  ( const fgFRAGMENT & rhs );
136 };
137
138
139 #endif // _FRAGMENT_HXX 
140
141
142 // $Log$
143 // Revision 1.1  1998/08/25 16:51:23  curt
144 // Moved from ../Scenery
145 //
146 //