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>
19 #include <osg/Texture2D>
20 #include <osgDB/ReaderWriter>
22 #include <simgear/misc/sg_path.hxx>
23 #include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
26 SGLoadTexture2D(bool staticTexture, const std::string& path,
27 const osgDB::ReaderWriter::Options* options = 0,
28 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1);
30 inline osg::Texture2D*
31 SGLoadTexture2D(const std::string& path,
32 const osgDB::ReaderWriter::Options* options = 0,
33 bool wrapu = true, bool wrapv = true, int mipmaplevels = -1)
35 return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels);
38 inline osg::Texture2D*
39 SGLoadTexture2D(const SGPath& path,
40 const osgDB::ReaderWriter::Options* options = 0,
41 bool wrapu = true, bool wrapv = true,
42 int mipmaplevels = -1)
44 return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv,
48 inline osg::Texture2D*
49 SGLoadTexture2D(bool staticTexture, const SGPath& path,
50 const osgDB::ReaderWriter::Options* options = 0,
51 bool wrapu = true, bool wrapv = true,
52 int mipmaplevels = -1)
54 return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv,
60 osg::Node* copyModel(osg::Node* model);
62 // Change the StateSets of a model to hold different textures based on
65 class TextureUpdateVisitor : public NodeAndDrawableVisitor
68 TextureUpdateVisitor(const osgDB::FilePathList& pathList);
69 virtual void apply(osg::Node& node);
70 virtual void apply(osg::Drawable& drawable);
71 // Copied from Mathias' earlier SGTextureUpdateVisitor
73 osg::Texture2D* textureReplace(int unit, const osg::StateAttribute* attr);
74 osg::StateSet* cloneStateSet(const osg::StateSet* stateSet);
76 osgDB::FilePathList _pathList;
79 // Create new userdata structs in a copied model.
80 // The BVH trees are shared with the original model, but the velocity fields
81 // should usually be distinct fields for distinct models.
82 class UserDataCopyVisitor : public osg::NodeVisitor
85 UserDataCopyVisitor();
86 virtual void apply(osg::Node& node);