]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/model.hxx
Better encapsulation for personality
[simgear.git] / simgear / scene / model / model.hxx
1 // model.hxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __MODEL_HXX
7 #define __MODEL_HXX 1
8
9 #ifndef __cplusplus
10 # error This library requires C++
11 #endif
12
13 #include <simgear/compiler.h>
14
15 #include <vector>
16 #include <set>
17
18 SG_USING_STD(vector);
19 SG_USING_STD(set);
20
21 #include <plib/sg.h>
22 #include <plib/ssg.h>
23
24 #include <simgear/misc/sg_path.hxx>
25 #include <simgear/props/props.hxx>
26
27
28 // Has anyone done anything *really* stupid, like making min and max macros?
29 #ifdef min
30 #undef min
31 #endif
32 #ifdef max
33 #undef max
34 #endif
35
36
37 /**
38  * Abstract class for adding data to the scene graph.  modelLoaded() is
39  * called by sgLoad3DModel() after the model was loaded, and the destructor
40  * when the branch is removed from the graph.
41  */
42 class SGModelData : public ssgBase {
43 public:
44     virtual ~SGModelData() {}
45     virtual void modelLoaded( const string& path, SGPropertyNode *prop,
46                               ssgBranch *branch) {}
47 };
48
49
50 /**
51  * Load a 3D model with or without XML wrapper.  Note, this version
52  * Does not know about or load the panel/cockpit information.  Use the
53  * "model_panel.hxx" version if you want to load an aircraft
54  * (i.e. ownship) with a panel.
55  *
56  * If the path ends in ".xml", then it will be used as a property-
57  * list wrapper to add animations to the model.
58  *
59  * Subsystems should not normally invoke this function directly;
60  * instead, they should use the FGModelLoader declared in loader.hxx.
61  */
62 ssgBranch *
63 sgLoad3DModel( const string& fg_root, const string &path,
64                           SGPropertyNode *prop_root, double sim_time_sec,
65                           ssgEntity *(*load_panel)(SGPropertyNode *) = 0,
66                           SGModelData *data = 0 );
67
68
69 /**
70  * Make an offset matrix from rotations and position offset.
71  */
72 void
73 sgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
74                      double x_off, double y_off, double z_off );
75
76 /**
77  * Make the animation
78  */
79 void
80 sgMakeAnimation( ssgBranch * model,
81                  const char * name,
82                  vector<SGPropertyNode_ptr> &name_nodes,
83                  SGPropertyNode *prop_root,
84                  SGPropertyNode_ptr node,
85                  double sim_time_sec,
86                  SGPath &texture_path,
87                  set<ssgBranch *> &ignore_branches );
88
89 /**
90  * Set the filter state on models
91  */
92 bool
93 sgSetModelFilter( bool filter );
94
95 /**
96  * Check if the ssg node contains an animation
97  */
98 bool 
99 sgCheckAnimationBranch (ssgEntity * entity);
100
101 /**
102  * Enable or disable Display list usage
103  */
104 extern bool sgUseDisplayList;
105
106 #endif // __MODEL_HXX