]> git.tdb.fi Git - libs/gl.git/blobdiff - source/object.h
Inherit Loaders from the ObjectLoader classes
[libs/gl.git] / source / object.h
index 9c1ea7f7fbbf9533afab934b8d20d4df24263230..bf4a05249436f5453ec678a274431958597a61fb 100644 (file)
@@ -9,7 +9,6 @@ Distributed under the LGPL
 #define MSP_GL_OBJECT_H_
 
 #include <vector>
-#include <msp/datafile/collection.h>
 #include "objectpass.h"
 #include "renderable.h"
 
@@ -41,20 +40,11 @@ private:
        const Material *material;
 
 public:
-       class Loader: public DataFile::Loader
+       class Loader: public DataFile::CollectionObjectLoader<Object>
        {
-       public:
-               typedef DataFile::Collection Collection;
-
-       protected:
-               Object &obj;
-               Collection &coll;
-       
        public:
                Loader(Object &, Collection &);
 
-               Object &get_object() const { return obj; }
-               Collection &get_collection() const { return coll; }
        private:
                virtual void finish();
                void lod_mesh(unsigned, const std::string &);
@@ -70,8 +60,6 @@ public:
 
        const Technique *get_technique() const { return technique; }
 
-       virtual bool has_pass(const Tag &) const;
-
        /**
        Renders the object.  A tag can be provided to render a non-default pass.
        */
@@ -93,6 +81,9 @@ public:
        template<typename Iter>
        void render(Iter begin, Iter end, const Tag &tag=Tag()) const
        {
+               if(!can_render(tag))
+                       return;
+
                const ObjectPass *pass=get_pass(tag);
                setup_render(pass);
                for(Iter i=begin; i!=end; ++i)
@@ -100,6 +91,7 @@ public:
                finish_render(pass);
        }
 private:
+       bool can_render(const Tag &) const;
        const ObjectPass *get_pass(const Tag &) const;
        void setup_render(const ObjectPass *) const;
        void finish_render(const ObjectPass *) const;