00001
00002
00003
00004
00005
00006 #ifndef __MODEL_HXX
00007 #define __MODEL_HXX 1
00008
00009 #ifndef __cplusplus
00010 # error This library requires C++
00011 #endif
00012
00013 #include <simgear/compiler.h>
00014
00015 #include <vector>
00016 #include <set>
00017
00018 #include <osg/Node>
00019 #include <osg/Texture2D>
00020 #include <osgDB/ReaderWriter>
00021
00022 #include <simgear/misc/sg_path.hxx>
00023 #include <simgear/props/props.hxx>
00024 #include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
00025
00026 osg::Texture2D*
00027 SGLoadTexture2D(bool staticTexture, const std::string& path,
00028 const osgDB::ReaderWriter::Options* options = 0,
00029 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1);
00030
00031 inline osg::Texture2D*
00032 SGLoadTexture2D(const std::string& path,
00033 const osgDB::ReaderWriter::Options* options = 0,
00034 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1)
00035 {
00036 return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels);
00037 }
00038
00039 inline osg::Texture2D*
00040 SGLoadTexture2D(const SGPath& path,
00041 const osgDB::ReaderWriter::Options* options = 0,
00042 bool wrapu = true, bool wrapv = true,
00043 int mipmaplevels = -1)
00044 {
00045 return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv,
00046 mipmaplevels);
00047 }
00048
00049 inline osg::Texture2D*
00050 SGLoadTexture2D(bool staticTexture, const SGPath& path,
00051 const osgDB::ReaderWriter::Options* options = 0,
00052 bool wrapu = true, bool wrapv = true,
00053 int mipmaplevels = -1)
00054 {
00055 return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv,
00056 mipmaplevels);
00057 }
00058
00059 namespace simgear
00060 {
00061 osg::Node* copyModel(osg::Node* model);
00062
00063
00064
00065
00066 class TextureUpdateVisitor : public NodeAndDrawableVisitor
00067 {
00068 public:
00069 TextureUpdateVisitor(const osgDB::FilePathList& pathList);
00070 virtual void apply(osg::Node& node);
00071 virtual void apply(osg::Drawable& drawable);
00072
00073 protected:
00074 osg::Texture2D* textureReplace(int unit, const osg::StateAttribute* attr);
00075 osg::StateSet* cloneStateSet(const osg::StateSet* stateSet);
00076 private:
00077 osgDB::FilePathList _pathList;
00078 };
00079
00080
00081
00082
00083 class UserDataCopyVisitor : public osg::NodeVisitor
00084 {
00085 public:
00086 UserDataCopyVisitor();
00087 virtual void apply(osg::Node& node);
00088 };
00089
00097 osg::ref_ptr<osg::Node>
00098 instantiateEffects(osg::Node* model,
00099 PropertyList& effectProps,
00100 const osgDB::ReaderWriter::Options* options);
00101
00111 inline osg::ref_ptr<osg::Node>
00112 instantiateEffects(osg::Node* model,
00113 const osgDB::ReaderWriter::Options* options)
00114 {
00115 PropertyList effectProps;
00116 return instantiateEffects(model, effectProps, options);
00117 }
00118 }
00119 #endif // __MODEL_HXX