]> git.mxchange.org Git - simgear.git/blob - simgear/scene/tgdb/userdata.hxx
Random object support from Stuart Buchanan
[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  - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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/sg.h>
33
34 #include <osg/Referenced>
35 #include <osg/Geometry>
36 #include <osg/Group>
37
38 SG_USING_STD(string);
39
40 class SGMaterial;
41 class SGMatModel;
42 class SGMatModelGroup;
43 class SGModelLib;
44 class SGPropertyNode;
45
46
47 /**
48  * the application must call sgUserDataInit() and specify the
49  * following values (needed by the model loader callback at draw time)
50  * before drawing any scenery.
51  */
52 void sgUserDataInit( SGModelLib *m, const string &r,
53                      SGPropertyNode *p, double t );
54
55 /**
56  * Get a random model.
57  */
58 osg::Node* sgGetRandomModel(SGMatModel *obj);
59
60 /**
61  * Get a specific model.
62  */
63 osg::Node* sgGetModel(int i, SGMatModel *obj);
64
65 /**
66  * User data for populating leaves when they come in range.
67  */
68 class SGLeafUserData : public osg::Referenced
69 {
70 public:
71     bool is_filled_in;
72     osg::Geometry *leaf;
73     SGMaterial *mat;
74     osg::Group *branch;
75     float sin_lat;
76     float cos_lat;
77     float sin_lon;
78     float cos_lon;
79
80     void setup_triangle( int i );
81 };
82
83
84 /**
85  * User data for populating triangles when they come in range.
86  */
87 class SGTriUserData : public osg::Referenced
88 {
89 public:
90     bool is_filled_in;
91     float * p1;
92     float * p2;
93     float * p3;
94     osg::Vec3 center;
95     double area;
96     SGMatModelGroup * object_group;
97     osg::Group * branch;
98     SGLeafUserData * leafData;
99     unsigned int seed;
100
101     void fill_in_triangle();
102     void add_object_to_triangle(SGMatModel * object);
103     void makeWorldMatrix (sgMat4 ROT, double hdg_deg );
104 };
105
106 #endif // _SG_USERDATA_HXX