]> git.mxchange.org Git - flightgear.git/blob - src/Objects/userdata.hxx
Attempt to work around a problem compiling ssgEntityArray.cxx against
[flightgear.git] / src / Objects / 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 #include <plib/ssg.h>
26
27 class SGMaterial;
28 class SGMatModel;
29 class SGMatModelGroup;
30
31
32 /**
33  * User data for populating leaves when they come in range.
34  */
35 class LeafUserData : public ssgBase
36 {
37 public:
38     bool is_filled_in;
39     ssgLeaf *leaf;
40     SGMaterial *mat;
41     ssgBranch *branch;
42     float sin_lat;
43     float cos_lat;
44     float sin_lon;
45     float cos_lon;
46
47     void setup_triangle( int i );
48 };
49
50
51 /**
52  * User data for populating triangles when they come in range.
53  */
54 class TriUserData : public ssgBase
55 {
56 public:
57     bool is_filled_in;
58     float * p1;
59     float * p2;
60     float * p3;
61     sgVec3 center;
62     double area;
63     SGMatModelGroup * object_group;
64     ssgBranch * branch;
65     LeafUserData * leafData;
66     unsigned int seed;
67
68     void fill_in_triangle();
69     void add_object_to_triangle(SGMatModel * object);
70     void makeWorldMatrix (sgMat4 ROT, double hdg_deg );
71 };
72
73
74 /**
75  * ssgEntity with a dummy bounding sphere, to fool culling.
76  *
77  * This forces the in-range and out-of-range branches to be visited
78  * when appropriate, even if they have no children.  It's ugly, but
79  * it works and seems fairly efficient (since branches can still
80  * be culled when they're out of the view frustum).
81  */
82 class DummyBSphereEntity : public ssgBranch
83 {
84 public:
85   DummyBSphereEntity (float radius)
86   {
87     bsphere.setCenter(0, 0, 0);
88     bsphere.setRadius(radius);
89   }
90   virtual ~DummyBSphereEntity () {}
91   virtual void recalcBSphere () { bsphere_is_invalid = false; }
92 };
93
94