diff --git a/core/Drawable.h b/core/Drawable.h deleted file mode 100644 index 638485b..0000000 --- a/core/Drawable.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef DRAWABLE_H -#define DRAWABLE_H - -#include "Node.h" -#include "Material.h" - -class Drawable : virtual public Node { -public: - virtual bool IsDrawable() const {return true;} - virtual void Draw() = 0; - Material *material; -}; - -#endif /* DRAWABLE_H */ diff --git a/core/Mesh.cpp b/core/Mesh.cpp index f460904..3b2e3ad 100644 --- a/core/Mesh.cpp +++ b/core/Mesh.cpp @@ -38,6 +38,10 @@ void Mesh::SetupMesh() { glBindVertexArray(0); } +Mesh Mesh::FromFile(const char *filename) { + return Mesh(); +} + void Mesh::Draw() { glBindVertexArray(VAO); glDrawElements(GL_TRIANGLES, indices.size() * 3, GL_UNSIGNED_INT, 0); diff --git a/core/Mesh.h b/core/Mesh.h index ad9f769..c91c581 100644 --- a/core/Mesh.h +++ b/core/Mesh.h @@ -5,17 +5,20 @@ #include "types.h" #include "Spatial.h" -#include "Drawable.h" #include "Vertex.h" #include "Index.h" +#include "Material.h" -class Mesh : public Spatial, public Drawable { +class Mesh : public Spatial { public: VertexList vertices; IndexList indices; + Material *material; Mesh(); ~Mesh(); Mesh(VertexList vertices, IndexList indices); + static Mesh FromFile(const char *filename); + virtual bool IsDrawable() const {return true;} virtual void Draw(); virtual void SetupMesh(); private: diff --git a/core/Node.h b/core/Node.h index 79a023d..a5910ec 100644 --- a/core/Node.h +++ b/core/Node.h @@ -14,6 +14,7 @@ public: NodeList children; static Node *GetRoot(); virtual bool IsDrawable() const; + virtual void Draw(){}; virtual bool IsTransformable() const; private: static Node *root; diff --git a/core/Spatial.h b/core/Spatial.h index 35777fd..91d975e 100644 --- a/core/Spatial.h +++ b/core/Spatial.h @@ -4,7 +4,7 @@ #include "Node.h" #include "Transform.h" -class Spatial : virtual public Node { +class Spatial : public Node { public: Transform transform; virtual bool IsTransformable() const { return true;} diff --git a/core/couch.cpp b/core/couch.cpp index b9d0173..bc15a34 100644 --- a/core/couch.cpp +++ b/core/couch.cpp @@ -36,18 +36,18 @@ void render(Node *curr, Shader *shader, Matrix model) { model = glm::translate(model, spatial->transform.position); shader->UpdateModel(model); } - Drawable *drawable = dynamic_cast(curr); - if (drawable->material->usesColor) { - shader->UpdateColor(true, drawable->material->color); + Mesh *mesh = dynamic_cast(curr); + if (mesh->material->usesColor) { + shader->UpdateColor(true, mesh->material->color); } else { shader->UpdateColor(false); } - if (drawable->material->usesTex) { - shader->UpdateTex(true, drawable->material->tex); + if (mesh->material->usesTex) { + shader->UpdateTex(true, mesh->material->tex); } else { shader->UpdateTex(false); } - drawable->Draw(); + mesh->Draw(); } for (Node *child : curr->children) { render(child, shader, model); diff --git a/scripting/couch.i b/scripting/couch.i index 9580319..ee14760 100644 --- a/scripting/couch.i +++ b/scripting/couch.i @@ -7,7 +7,6 @@ #include "Node.h" #include "Transform.h" #include "Spatial.h" -#include "Drawable.h" #include "Material.h" #include "Mesh.h" #include "Ball.h" @@ -36,7 +35,6 @@ public: %include "Node.h" %include "Spatial.h" %include "Transform.h" -%include "Drawable.h" %include "Material.h" %include "Mesh.h" %include "Ball.h"