]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/model.hxx
Improved tile cache priority scheme.
[simgear.git] / simgear / scene / model / model.hxx
index bef5a32246d65f9d8691f7eef05da70f91a89d0a..c2097fdcd52930cab553b80cd5cae13b53cc4ea7 100644 (file)
 #include <osgDB/ReaderWriter>
 
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
+
+namespace simgear
+{
+class SGReaderWriterXMLOptions;
+}
 
 osg::Texture2D*
 SGLoadTexture2D(bool staticTexture, const std::string& path,
@@ -54,4 +61,64 @@ SGLoadTexture2D(bool staticTexture, const SGPath& path,
                            mipmaplevels);
 }
 
+namespace simgear
+{
+osg::Node* copyModel(osg::Node* model);
+
+// Change the StateSets of a model to hold different textures based on
+// a livery path.
+
+class TextureUpdateVisitor : public NodeAndDrawableVisitor
+{
+public:
+    TextureUpdateVisitor(const osgDB::FilePathList& pathList);
+    virtual void apply(osg::Node& node);
+    virtual void apply(osg::Drawable& drawable);
+    // Copied from Mathias' earlier SGTextureUpdateVisitor
+protected:
+    osg::Texture2D* textureReplace(int unit, const osg::StateAttribute* attr);
+    osg::StateSet* cloneStateSet(const osg::StateSet* stateSet);
+private:
+    osgDB::FilePathList _pathList;
+};
+
+// Create new userdata structs in a copied model.
+// The BVH trees are shared with the original model, but the velocity fields
+// should usually be distinct fields for distinct models.
+class UserDataCopyVisitor : public osg::NodeVisitor
+{
+public:
+    UserDataCopyVisitor();
+    virtual void apply(osg::Node& node);
+};
+
+/**
+ * Transform an OSG subgraph by substituting Effects and EffectGeodes
+ * for osg::Geodes with osg::StateSets. This is only guaranteed to
+ * work for models prouced by the .ac loader.
+ *
+ * returns a copy if any nodes are changed
+ */
+osg::ref_ptr<osg::Node>
+instantiateEffects(osg::Node* model,
+                   PropertyList& effectProps,
+                   const SGReaderWriterXMLOptions* options);
+
+/**
+ * Transform an OSG subgraph by substituting the Effects and
+ * EffectGeodes for osg::Geodes with osg::StateSets, inheriting from
+ * the default model effect. This is only guaranteed to work for
+ * models prouced by the .ac loader.
+ *
+ * returns a copy if any nodes are changed
+ */
+
+inline osg::ref_ptr<osg::Node>
+instantiateEffects(osg::Node* model,
+                   const SGReaderWriterXMLOptions* options)
+{
+    PropertyList effectProps;
+    return instantiateEffects(model, effectProps, options);
+}
+}
 #endif // __MODEL_HXX