1 // Copyright (C) 2008 Till Busch buti@bux.at
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #ifndef _SG_MODEL_LIB_HXX
19 #define _SG_MODEL_LIB_HXX 1
22 # error This library requires C++
25 #include <simgear/compiler.h> // for SG_USING_STD
31 #include <simgear/props/props.hxx>
38 class SGModelData; // defined below
41 * Class for loading and managing models with XML wrappers.
46 typedef osg::Node *(*panel_func)(SGPropertyNode *);
48 static void init(const string &root_dir);
50 // Load a 3D model (any format)
51 // data->modelLoaded() will be called after the model is loaded
52 static osg::Node* loadModel(const string &path,
53 SGPropertyNode *prop_root,
56 // Load a 3D model (any format)
57 // with a panel_func to load a panel
58 static osg::Node* loadModel(const string &path,
59 SGPropertyNode *prop_root,
62 // Load a 3D model (any format) through the DatabasePager.
63 // Most models should be loaded using this function!
64 // This function will initially return an SGPagedLOD node.
65 // data->modelLoaded() will be called after the model is loaded and
66 // connected to the scene graph. See AIModelData on how to use this.
67 // NOTE: AIModelData uses observer_ptr to avoid circular references.
68 static osg::Node* loadPagedModel(const string &path,
69 SGPropertyNode *prop_root,
79 * Abstract class for adding data to the scene graph. modelLoaded() is
80 * called after the model was loaded, and the destructor when the branch
81 * is removed from the scene graph.
83 class SGModelData : public osg::Referenced {
85 virtual ~SGModelData() {}
86 virtual void modelLoaded(const string& path, SGPropertyNode *prop,
87 osg::Node* branch) = 0;
92 #endif // _SG_MODEL_LIB_HXX