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>
24 #include <simgear/misc/sg_path.hxx>
25 #include <simgear/props/props.hxx>
28 // Has anyone done anything *really* stupid, like making min and max macros?
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.
42 class SGModelData : public osg::Referenced {
44 virtual ~SGModelData() {}
45 virtual void modelLoaded( const string& path, SGPropertyNode *prop,
46 osg::Node*branch) = 0;
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.
56 * If the path ends in ".xml", then it will be used as a property-
57 * list wrapper to add animations to the model.
59 * Subsystems should not normally invoke this function directly;
60 * instead, they should use the FGModelLoader declared in loader.hxx.
63 sgLoad3DModel( const string& fg_root, const string &path,
64 SGPropertyNode *prop_root, double sim_time_sec,
65 osg::Node *(*load_panel)(SGPropertyNode *) = 0,
66 SGModelData *data = 0,
67 const SGPath& texturePath = SGPath() );
74 sgMakeAnimation( osg::Node* model,
76 vector<SGPropertyNode_ptr> &name_nodes,
77 SGPropertyNode *prop_root,
78 SGPropertyNode_ptr node,
81 set<osg::Node*> &ignore_branches );
85 SGLoadTexture2D(const std::string& path, bool wrapu = true,
86 bool wrapv = true, int mipmaplevels = -1);
88 inline osg::Texture2D*
89 SGLoadTexture2D(const SGPath& path, bool wrapu = true, bool wrapv = true,
90 int mipmaplevels = -1)
92 return SGLoadTexture2D(path.str(), wrapu, wrapv, mipmaplevels);