1 // model.hxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
10 # error This library requires C++
13 #include <simgear/compiler.h>
22 #include <osg/Texture2D>
23 #include <osgDB/ReaderWriter>
25 #include <simgear/misc/sg_path.hxx>
26 #include <simgear/props/props.hxx>
29 // Has anyone done anything *really* stupid, like making min and max macros?
39 * Abstract class for adding data to the scene graph. modelLoaded() is
40 * called by sgLoad3DModel() after the model was loaded, and the destructor
41 * when the branch is removed from the graph.
43 class SGModelData : public osg::Referenced {
45 virtual ~SGModelData() {}
46 virtual void modelLoaded( const string& path, SGPropertyNode *prop,
47 osg::Node*branch) = 0;
52 * Load a 3D model with or without XML wrapper. Note, this version
53 * Does not know about or load the panel/cockpit information. Use the
54 * "model_panel.hxx" version if you want to load an aircraft
55 * (i.e. ownship) with a panel.
57 * If the path ends in ".xml", then it will be used as a property-
58 * list wrapper to add animations to the model.
60 * Subsystems should not normally invoke this function directly;
61 * instead, they should use the FGModelLoader declared in loader.hxx.
64 sgLoad3DModel( const string& fg_root, const string &path,
65 SGPropertyNode *prop_root, double sim_time_sec,
66 osg::Node *(*load_panel)(SGPropertyNode *) = 0,
67 SGModelData *data = 0,
68 const SGPath& texturePath = SGPath() );
75 sgMakeAnimation( osg::Node* model,
77 vector<SGPropertyNode_ptr> &name_nodes,
78 SGPropertyNode *prop_root,
79 SGPropertyNode_ptr node,
82 set<osg::Node*> &ignore_branches );
85 SGLoadTexture2D(bool staticTexture, const std::string& path,
86 const osgDB::ReaderWriter::Options* options = 0,
87 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1);
89 inline osg::Texture2D*
90 SGLoadTexture2D(const std::string& path,
91 const osgDB::ReaderWriter::Options* options = 0,
92 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1)
94 return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels);
97 inline osg::Texture2D*
98 SGLoadTexture2D(const SGPath& path,
99 const osgDB::ReaderWriter::Options* options = 0,
100 bool wrapu = true, bool wrapv = true,
101 int mipmaplevels = -1)
103 return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv,
107 inline osg::Texture2D*
108 SGLoadTexture2D(bool staticTexture, const SGPath& path,
109 const osgDB::ReaderWriter::Options* options = 0,
110 bool wrapu = true, bool wrapv = true,
111 int mipmaplevels = -1)
113 return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv,
117 #endif // __MODEL_HXX