]> git.tdb.fi Git - libs/gl.git/blobdiff - source/object.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / object.cpp
diff --git a/source/object.cpp b/source/object.cpp
deleted file mode 100644 (file)
index 938e83f..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <msp/datafile/collection.h>
-#include <msp/strings/formatter.h>
-#include "except.h"
-#include "material.h"
-#include "mesh.h"
-#include "object.h"
-#include "objectinstance.h"
-#include "program.h"
-#include "programdata.h"
-#include "technique.h"
-#include "texture.h"
-#include "texunit.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Object::Object():
-       meshes(1),
-       technique(0),
-       own_mesh(false),
-       own_technique(false)
-{ }
-
-Object::~Object()
-{
-       if(own_technique)
-               delete technique;
-       if(own_mesh)
-               delete meshes[0];
-}
-
-void Object::render(const Tag &tag) const
-{
-       const RenderPass *pass = get_pass(tag);
-       if(!pass)
-               return;
-
-       Bind bind(*pass);
-       meshes[0]->draw();
-}
-
-void Object::render(const ObjectInstance &inst, const Tag &tag) const
-{
-       const RenderPass *pass = get_pass(tag);
-       if(!pass)
-               return;
-
-       Bind bind(*pass);
-       render_instance(inst, tag);
-       meshes[0]->draw();
-}
-
-const RenderPass *Object::get_pass(const Tag &tag) const
-{
-       if(!technique->has_pass(tag))
-               return 0;
-       return &technique->get_pass(tag);
-}
-
-void Object::render_instance(const ObjectInstance &inst, const Tag &tag) const
-{
-       inst.setup_render(tag);
-       unsigned lod = min<unsigned>(inst.get_level_of_detail(), meshes.size()-1);
-       meshes[lod]->draw();
-       inst.finish_render(tag);
-}
-
-
-Object::Loader::Loader(Object &o):
-       DataFile::CollectionObjectLoader<Object>(o, 0)
-{
-       init();
-}
-
-Object::Loader::Loader(Object &o, Collection &c):
-       DataFile::CollectionObjectLoader<Object>(o, &c)
-{
-       init();
-}
-
-void Object::Loader::init()
-{
-       allow_pointer_reload = false;
-
-       add("lod_mesh", &Loader::lod_mesh);
-       add("mesh",     static_cast<void (Loader::*)()>(&Loader::mesh));
-       add("mesh",     static_cast<void (Loader::*)(const std::string &)>(&Loader::mesh));
-       add("technique", &Loader::technique);
-       add("technique", &Object::technique);
-}
-
-void Object::Loader::lod_mesh(unsigned l, const string &n)
-{
-       obj.meshes.resize(l+1, 0);
-       obj.meshes[l] = get_collection().get<Mesh>(n);
-}
-
-void Object::Loader::mesh()
-{
-       if(obj.meshes[0])
-               throw InvalidState("A mesh is already loaded");
-
-       RefPtr<Mesh> msh = new Mesh;
-       load_sub(*msh);
-       obj.meshes[0] = msh.release();
-       obj.own_mesh = true;
-}
-
-void Object::Loader::mesh(const std::string &n)
-{
-       if(obj.meshes[0])
-               throw InvalidState("A mesh is already loaded");
-
-       obj.meshes[0] = get_collection().get<Mesh>(n);
-}
-
-void Object::Loader::technique()
-{
-       RefPtr<Technique> tech = new Technique;
-       if(coll)
-               load_sub(*tech, get_collection());
-       else
-               load_sub(*tech);
-       obj.technique = tech.release();
-       obj.own_technique = true;
-}
-
-} // namespace GL
-} // namespace Msp