]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/material/Effect.hxx
Random buildings - initial commit.
[simgear.git] / simgear / scene / material / Effect.hxx
index 0690db3a76a5f17e36334fafd24429a1b778b2e9..0a5ffe2b333008e7c86d3d479528a85576389fc8 100644 (file)
@@ -24,6 +24,7 @@
 #include <boost/functional/hash.hpp>
 
 #include <osg/Object>
+#include <osg/observer_ptr>
 #include <osgDB/ReaderWriter>
 
 #include <simgear/props/props.hxx>
@@ -45,7 +46,7 @@ namespace simgear
 {
 class Technique;
 class Effect;
-class SGReaderWriterXMLOptions;
+class SGReaderWriterOptions;
 
 /**
  * Object to be initialized at some point after an effect -- and its
@@ -80,6 +81,31 @@ public:
     Effect(const Effect& rhs,
            const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
     osg::StateSet* getDefaultStateSet();
+
+    enum Buffer
+    {
+        DEPTH_BUFFER,
+        NORMAL_BUFFER,
+        DIFFUSE_BUFFER,
+        SPEC_EMIS_BUFFER,
+        LIGHTING_BUFFER,
+        MIDDLE_BLOOM_BUFFER,
+        BLOOM_BUFFER,
+        AO_BUFFER,
+        SHADOW_BUFFER
+    };
+
+    // Define what needs to be generated for this effect
+    enum Generator
+    {
+        NORMAL,
+        TANGENT,
+        BINORMAL
+    };
+    void setGenerator(Generator what, int where) { generator[what] = where; }
+    int getGenerator(Generator what) const;  // Returns -1 if generator should not be used
+    std::map<Generator, int> generator;  // What is generated into which attribute location
+
     std::vector<osg::ref_ptr<Technique> > techniques;
     SGPropertyNode_ptr root;
     // Pointer to the parameters node, if it exists
@@ -90,7 +116,7 @@ public:
     /**
      * Build the techniques from the effect properties.
      */
-    bool realizeTechniques(const SGReaderWriterXMLOptions* options = 0);
+    bool realizeTechniques(const SGReaderWriterOptions* options = 0);
     /**
      * Updaters that should be derefed when the effect is
      * deleted. Updaters arrange to be run by listening on properties
@@ -134,7 +160,7 @@ protected:
             bool operator()(const Key& lhs, const Key& rhs) const;
         };
     };
-    typedef std::tr1::unordered_map<Key, osg::ref_ptr<Effect>,
+    typedef std::tr1::unordered_map<Key, osg::observer_ptr<Effect>,
                                     boost::hash<Key>, Key::EqualTo> Cache;
     Cache* getCache()
     {
@@ -145,7 +171,7 @@ protected:
     Cache* _cache;
     friend size_t hash_value(const Key& key);
     friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
-                              const SGReaderWriterXMLOptions* options);
+                              const SGReaderWriterOptions* options);
     bool _isRealized;
 };
 // Automatic support for boost hash function
@@ -154,11 +180,11 @@ size_t hash_value(const Effect::Key&);
 
 Effect* makeEffect(const std::string& name,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options = 0);
+                   const SGReaderWriterOptions* options = 0);
 
 Effect* makeEffect(SGPropertyNode* prop,
                    bool realizeTechniques,
-                   const SGReaderWriterXMLOptions* options = 0);
+                   const SGReaderWriterOptions* options = 0);
 
 bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
                                 const osg::StateSet* ss);