]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/userdata.hxx
Clean up a class renaming mistake.
[simgear.git] / simgear / scene / tgdb / userdata.hxx
1 // userdata.hxx -- two classes for populating ssg user data slots in association
2 //                 with our implimenation of random surface objects.
3 //
4 // Written by David Megginson, started December 2001.
5 //
6 // Copyright (C) 2001 - 2003  Curtis L. Olson  - curt@flightgear.org
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24
25 #ifndef _SG_USERDATA_HXX
26 #define _SG_USERDATA_HXX
27
28 #include <simgear/compiler.h>
29
30 #include STL_STRING
31
32 #include <plib/ssg.h>
33
34 SG_USING_STD(string);
35
36 class SGMaterial;
37 class SGMatModel;
38 class SGMatModelGroup;
39 class SGModelLib;
40 class SGPropertyNode;
41
42
43 /**
44  * the application must call sgUserDataInit() and specify the
45  * following values (needed by the model loader callback at draw time)
46  * before drawing any scenery.
47  */
48 void sgUserDataInit( SGModelLib *m, const string &r,
49                      SGPropertyNode *p, double t );
50
51
52 /**
53  * User data for populating leaves when they come in range.
54  */
55 class SGLeafUserData : public ssgBase
56 {
57 public:
58     bool is_filled_in;
59     ssgLeaf *leaf;
60     SGMaterial *mat;
61     ssgBranch *branch;
62     float sin_lat;
63     float cos_lat;
64     float sin_lon;
65     float cos_lon;
66
67     void setup_triangle( int i );
68 };
69
70
71 /**
72  * User data for populating triangles when they come in range.
73  */
74 class SGTriUserData : public ssgBase
75 {
76 public:
77     bool is_filled_in;
78     float * p1;
79     float * p2;
80     float * p3;
81     sgVec3 center;
82     double area;
83     SGMatModelGroup * object_group;
84     ssgBranch * branch;
85     SGLeafUserData * leafData;
86     unsigned int seed;
87
88     void fill_in_triangle();
89     void add_object_to_triangle(SGMatModel * object);
90     void makeWorldMatrix (sgMat4 ROT, double hdg_deg );
91 };
92
93
94 /**
95  * ssgEntity with a dummy bounding sphere, to fool culling.
96  *
97  * This forces the in-range and out-of-range branches to be visited
98  * when appropriate, even if they have no children.  It's ugly, but
99  * it works and seems fairly efficient (since branches can still
100  * be culled when they're out of the view frustum).
101  */
102 class SGDummyBSphereEntity : public ssgBranch
103 {
104 public:
105   SGDummyBSphereEntity (float radius)
106   {
107     bsphere.setCenter(0, 0, 0);
108     bsphere.setRadius(radius);
109   }
110   virtual ~SGDummyBSphereEntity () {}
111   virtual void recalcBSphere () { bsphere_is_invalid = false; }
112 };
113
114
115 #endif // _SG_USERDATA_HXX