X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmodel%2Fmodellib.hxx;h=cdd6d820440a50f6c337d0c04f79f4b45b42b5fe;hb=32a6bd78d8bf143f40922f1a0bc7a88ea7706a7d;hp=806b7f23b51328ccf84702fe1ad9f89d63687543;hpb=733e6fa14ff507a1022ecab8d55cc9bf587bee40;p=simgear.git diff --git a/simgear/scene/model/modellib.hxx b/simgear/scene/model/modellib.hxx index 806b7f23..cdd6d820 100644 --- a/simgear/scene/model/modellib.hxx +++ b/simgear/scene/model/modellib.hxx @@ -27,11 +27,14 @@ #include #include +#include #include +#include -SG_USING_STD(map); -SG_USING_STD(string); +namespace osg { + class PagedLOD; +} namespace simgear { @@ -45,33 +48,44 @@ class SGModelLib public: typedef osg::Node *(*panel_func)(SGPropertyNode *); - static void init(const string &root_dir); + static void init(const std::string &root_dir, SGPropertyNode* root); + static void resetPropertyRoot(); + + static void setPanelFunc(panel_func pf); + // Load a 3D model (any format) // data->modelLoaded() will be called after the model is loaded - static osg::Node* loadModel(const string &path, - SGPropertyNode *prop_root, - SGModelData *data=0); - - // Load a 3D model (any format) - // with a panel_func to load a panel - static osg::Node* loadModel(const string &path, - SGPropertyNode *prop_root, - panel_func pf); + static osg::Node* loadModel(const std::string &path, + SGPropertyNode *prop_root = NULL, + SGModelData *data=0, bool load2DPanels=false); // Load a 3D model (any format) through the DatabasePager. - // Most models should be loaded using this function! - // This function will initially return an SGPagedLOD node. - // data->modelLoaded() will be called after the model is loaded and - // connected to the scene graph. See AIModelData on how to use this. - // NOTE: AIModelData uses observer_ptr to avoid circular references. - static osg::Node* loadPagedModel(const string &path, - SGPropertyNode *prop_root, + // This function initially just returns a proxy node that refers to + // the model file. Once the viewer steps onto that node the + // model will be loaded. + static osg::Node* loadDeferredModel(const std::string &path, + SGPropertyNode *prop_root = NULL, + SGModelData *data=0); + // Load a 3D model (any format) through the DatabasePager. + // This function initially just returns a PagedLOD node that refers to + // the model file. Once the viewer steps onto that node the + // model will be loaded. When the viewer does no longer reference this + // node for a long time the node is unloaded again. + static osg::PagedLOD* loadPagedModel(const std::string &path, + SGPropertyNode *prop_root = NULL, SGModelData *data=0); + static std::string findDataFile(const std::string& file, + const osgDB::Options* opts = NULL, + SGPath currentDir = SGPath()); protected: SGModelLib(); ~SGModelLib (); + +private: + static SGPropertyNode_ptr static_propRoot; + static panel_func static_panelFunc; }; @@ -83,16 +97,9 @@ protected: class SGModelData : public osg::Referenced { public: virtual ~SGModelData() {} - virtual void modelLoaded( const string& path, SGPropertyNode *prop, - osg::Node*branch) = 0; - - virtual void setProps(SGPropertyNode *p) - { _props = p; } - - SGPropertyNode *getProperties() - { return _props; } -protected: - SGPropertyNode_ptr _props; + virtual void modelLoaded(const std::string& path, SGPropertyNode *prop, + osg::Node* branch) = 0; + virtual SGModelData* clone() const = 0; }; }