]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/model.hxx
remove CopyPolicy from ModelRegistry
[simgear.git] / simgear / scene / model / model.hxx
1 // model.hxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __MODEL_HXX
7 #define __MODEL_HXX 1
8
9 #ifndef __cplusplus
10 # error This library requires C++
11 #endif
12
13 #include <simgear/compiler.h>
14
15 #include <vector>
16 #include <set>
17
18 #include <osg/Node>
19 #include <osg/Texture2D>
20 #include <osgDB/ReaderWriter>
21
22 #include <simgear/misc/sg_path.hxx>
23 #include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
24
25 osg::Texture2D*
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);
29
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)
34 {
35     return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels);
36 }
37
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)
43 {
44     return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv,
45                            mipmaplevels);
46 }
47
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)
53 {
54     return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv,
55                            mipmaplevels);
56 }
57
58 namespace simgear
59 {
60 osg::Node* copyModel(osg::Node* model);
61
62 // Change the StateSets of a model to hold different textures based on
63 // a livery path.
64
65 class TextureUpdateVisitor : public NodeAndDrawableVisitor
66 {
67 public:
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
72 protected:
73     osg::Texture2D* textureReplace(int unit, const osg::StateAttribute* attr);
74     osg::StateSet* cloneStateSet(const osg::StateSet* stateSet);
75 private:
76     osgDB::FilePathList _pathList;
77 };
78
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
83 {
84 public:
85     UserDataCopyVisitor();
86     virtual void apply(osg::Node& node);
87 };
88
89 }
90 #endif // __MODEL_HXX