From 6e8431f9d9d186adaff74f2c6debc65caf07ffca Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Thu, 23 Apr 2015 11:05:23 +0200 Subject: [PATCH] moved all ModelClasses to SubDirectory Model created Model.h as Header for all Models included winrar.bat (zip game files only) --- Weave/Game.cpp | 2 -- Weave/Graphix/Model.h | 47 +++---------------------- Weave/Graphix/Model/BBox.cpp | 32 +++++++++++++++++ Weave/Graphix/Model/BBox.h | 13 +++++++ Weave/Graphix/{ => Model}/IMesh.cpp | 8 ++--- Weave/Graphix/{ => Model}/IMesh.h | 2 +- Weave/Graphix/{ => Model}/IMetaMesh.cpp | 4 +-- Weave/Graphix/{ => Model}/IMetaMesh.h | 2 +- Weave/Graphix/{ => Model}/Model.cpp | 27 +++++++------- Weave/Graphix/Model/Model.h | 46 ++++++++++++++++++++++++ Weave/Graphix/{ => Model}/SkyBox.cpp | 9 +++-- Weave/Graphix/{ => Model}/SkyBox.h | 2 ++ Weave/Graphix/SceneObject.cpp | 3 +- Weave/Weave.vcxproj | 17 +++++---- Weave/Weave.vcxproj.filters | 25 ++++++++----- winrar.bat | 5 +++ 16 files changed, 159 insertions(+), 85 deletions(-) create mode 100644 Weave/Graphix/Model/BBox.cpp create mode 100644 Weave/Graphix/Model/BBox.h rename Weave/Graphix/{ => Model}/IMesh.cpp (97%) rename Weave/Graphix/{ => Model}/IMesh.h (97%) rename Weave/Graphix/{ => Model}/IMetaMesh.cpp (96%) rename Weave/Graphix/{ => Model}/IMetaMesh.h (95%) rename Weave/Graphix/{ => Model}/Model.cpp (93%) create mode 100644 Weave/Graphix/Model/Model.h rename Weave/Graphix/{ => Model}/SkyBox.cpp (81%) rename Weave/Graphix/{ => Model}/SkyBox.h (68%) create mode 100644 winrar.bat diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 5445140..a44fbbd 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -18,8 +18,6 @@ #include "Fps.h" #include "Events.h" -#include "Graphix\SkyBox.h" - #include "Graphix\Model.h" #include "Message.h" diff --git a/Weave/Graphix/Model.h b/Weave/Graphix/Model.h index 8d82927..0a85701 100644 --- a/Weave/Graphix/Model.h +++ b/Weave/Graphix/Model.h @@ -1,45 +1,6 @@ #pragma once -#include "GLM.h" -#include - -class Shader; -class Texture; - -typedef unsigned int uint; - -class Model -{ -public: - Model(); - virtual ~Model(); - - /* Binds Model to the Model*/ - virtual void bindShader(Shader* shader); - - /* Draws Model */ - virtual void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const; - - /* Draws a BoundingBox around the Model */ - virtual void drawBBox() const; - -protected: - uint numvertices, numfaces; - uint vertexBuffer, indexBuffer, normalBuffer, uvBuffer; - - std::unordered_map shader_map; - - void updateBB(const vec3& min, const vec3& max); - - void genBuffer(uint &buffer, uint size, void* value); - void bindBuffer(const uint &buffer, const uint index, const uint dim = 3); - - virtual void useModel(Shader* shader) const; - virtual void useTexture(Texture* texture, Shader* shader) const; - virtual void useModelMat(const mat4& model, Shader* shader) const; - -private: - vec3 BBsize, BBposition; - -}; - +#include "Model\Model.h" +#include "Model\IMetaMesh.h" +#include "Model\SkyBox.h" +#include "Model\BBox.h" \ No newline at end of file diff --git a/Weave/Graphix/Model/BBox.cpp b/Weave/Graphix/Model/BBox.cpp new file mode 100644 index 0000000..af07531 --- /dev/null +++ b/Weave/Graphix/Model/BBox.cpp @@ -0,0 +1,32 @@ +#include "BBox.h" +#include "GL\glew.h" + +uint indexL1[4]{ 0, 1, 2, 3 }, +indexL2[4]{ 4, 5, 6, 7}, +indexS1[8]{0, 4, 1, 5, 2, 6, 3, 7}; + +BBox::BBox() +{ + numvertices = 4; + numfaces = 2; + + float vertex[] { -.5f, -.5f, -.5f, .5f, -.5f, -.5f, .5f, .5f, -.5f, -.5f, .5f, -.5f, -.5f, -.5f, .5f, .5f, -.5f, .5f, .5f, .5f, .5f, -.5f, .5f, .5f }; + + //import("skybox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0); + + genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); + +} + + +BBox::~BBox() +{ +} + +void BBox::drawModel() const +{ + glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL1); + glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL2); + glDrawElements(GL_LINE_STRIP, 8, GL_UNSIGNED_INT, indexS1); + glBindVertexArray(0); +} \ No newline at end of file diff --git a/Weave/Graphix/Model/BBox.h b/Weave/Graphix/Model/BBox.h new file mode 100644 index 0000000..c56c518 --- /dev/null +++ b/Weave/Graphix/Model/BBox.h @@ -0,0 +1,13 @@ +#pragma once +#include "Model.h" +class BBox : + public Model +{ +public: + BBox(); + ~BBox(); + + void drawModel() const; + +}; + diff --git a/Weave/Graphix/IMesh.cpp b/Weave/Graphix/Model/IMesh.cpp similarity index 97% rename from Weave/Graphix/IMesh.cpp rename to Weave/Graphix/Model/IMesh.cpp index 3bd5fb9..bcb2bfe 100644 --- a/Weave/Graphix/IMesh.cpp +++ b/Weave/Graphix/Model/IMesh.cpp @@ -5,11 +5,11 @@ #include #include -#include "Shader.h" -#include "Texture.h" -#include "../Message.h" +#include "../Shader.h" +#include "../Texture.h" +#include "../../Message.h" -#include "Graphix.h" +#include "../Graphix.h" diff --git a/Weave/Graphix/IMesh.h b/Weave/Graphix/Model/IMesh.h similarity index 97% rename from Weave/Graphix/IMesh.h rename to Weave/Graphix/Model/IMesh.h index c090379..fa025ba 100644 --- a/Weave/Graphix/IMesh.h +++ b/Weave/Graphix/Model/IMesh.h @@ -1,7 +1,7 @@ #pragma once #include -#include "GLM.h" +#include "../GLM.h" #include "Model.h" diff --git a/Weave/Graphix/IMetaMesh.cpp b/Weave/Graphix/Model/IMetaMesh.cpp similarity index 96% rename from Weave/Graphix/IMetaMesh.cpp rename to Weave/Graphix/Model/IMetaMesh.cpp index 811c5ab..d094020 100644 --- a/Weave/Graphix/IMetaMesh.cpp +++ b/Weave/Graphix/Model/IMetaMesh.cpp @@ -5,8 +5,8 @@ #include #include "IMesh.h" -#include "Shader.h" -#include "../Message.h" +#include "../Shader.h" +#include "../../Message.h" IMetaMesh::IMetaMesh(const string& _modelpath) diff --git a/Weave/Graphix/IMetaMesh.h b/Weave/Graphix/Model/IMetaMesh.h similarity index 95% rename from Weave/Graphix/IMetaMesh.h rename to Weave/Graphix/Model/IMetaMesh.h index c88e4eb..bb3bbdd 100644 --- a/Weave/Graphix/IMetaMesh.h +++ b/Weave/Graphix/Model/IMetaMesh.h @@ -4,7 +4,7 @@ #include #include -#include "GLM.h" +#include "../GLM.h" using std::string; diff --git a/Weave/Graphix/Model.cpp b/Weave/Graphix/Model/Model.cpp similarity index 93% rename from Weave/Graphix/Model.cpp rename to Weave/Graphix/Model/Model.cpp index 05b13b5..408d571 100644 --- a/Weave/Graphix/Model.cpp +++ b/Weave/Graphix/Model/Model.cpp @@ -1,12 +1,12 @@ #include "Model.h" #include -#include "../Message.h" +#include "../../Message.h" -#include "Shader.h" -#include "Texture.h" +#include "../Shader.h" +#include "../Texture.h" -#include "Graphix.h" +#include "../Graphix.h" Model::Model() : numfaces(0), @@ -32,12 +32,6 @@ void Model::bindShader(Shader* _shader) //Graphix::getGlError(); //Message::info("Do Stuff"); - if (indexBuffer == (uint)-1) - { - Message::error("Model: IndexBuffer wurde nicht geladen."); - return; - } - uint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); @@ -57,7 +51,8 @@ void Model::bindShader(Shader* _shader) //Message::info("aNormal"); //Graphix::getGlError(); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); + if (indexBuffer != (uint)-1) + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); //Message::info("bindIndexBuffer"); //Graphix::getGlError(); @@ -73,6 +68,12 @@ void Model::bindShader(Shader* _shader) //Message::info("Done"); } +void Model::drawModel() const +{ + glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0); + glBindVertexArray(0); +} + void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const { //Message::info("Error from before?"); @@ -86,15 +87,15 @@ void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) useModelMat(_modelMat, _shader); //Message::info("IMesh loading MMatrix"); //Graphix::getGlError(); - glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0); + drawModel(); //Message::info("IMesh drawing Elements"); //Graphix::getGlError(); - glBindVertexArray(0); //system("pause"); } void Model::drawBBox() const { + } void Model::updateBB(const vec3& _min, const vec3& _max) diff --git a/Weave/Graphix/Model/Model.h b/Weave/Graphix/Model/Model.h new file mode 100644 index 0000000..19b7a93 --- /dev/null +++ b/Weave/Graphix/Model/Model.h @@ -0,0 +1,46 @@ +#pragma once + +#include "../GLM.h" +#include + +class Shader; +class Texture; + +typedef unsigned int uint; + +class Model +{ +public: + Model(); + virtual ~Model(); + + /* Binds Model to the Model*/ + virtual void bindShader(Shader* shader); + + /* Draws Model */ + virtual void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const; + + /* Draws a BoundingBox around the Model */ + virtual void drawBBox() const; + +protected: + uint numvertices, numfaces; + uint vertexBuffer, indexBuffer, normalBuffer, uvBuffer; + + std::unordered_map shader_map; + + void updateBB(const vec3& min, const vec3& max); + + void genBuffer(uint &buffer, uint size, void* value); + void bindBuffer(const uint &buffer, const uint index, const uint dim = 3); + + virtual void useModel(Shader* shader) const; + virtual void useTexture(Texture* texture, Shader* shader) const; + virtual void useModelMat(const mat4& model, Shader* shader) const; + virtual void drawModel() const; + +private: + vec3 BBsize, BBposition; + +}; + diff --git a/Weave/Graphix/SkyBox.cpp b/Weave/Graphix/Model/SkyBox.cpp similarity index 81% rename from Weave/Graphix/SkyBox.cpp rename to Weave/Graphix/Model/SkyBox.cpp index 8e85a03..7cb2708 100644 --- a/Weave/Graphix/SkyBox.cpp +++ b/Weave/Graphix/Model/SkyBox.cpp @@ -1,7 +1,7 @@ #include "SkyBox.h" #include "GL/glew.h" -#include "Graphix.h" +#include "../Graphix.h" SkyBox::SkyBox() @@ -32,7 +32,12 @@ void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat glEnable(GL_DEPTH_TEST); } -void SkyBox::useModelMat(const mat4& model, Shader* shader) const +void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const +{ + +} + +void SkyBox::useTexture(Texture* _texture, Shader* _shader) const { } diff --git a/Weave/Graphix/SkyBox.h b/Weave/Graphix/Model/SkyBox.h similarity index 68% rename from Weave/Graphix/SkyBox.h rename to Weave/Graphix/Model/SkyBox.h index d6f6963..be5e88b 100644 --- a/Weave/Graphix/SkyBox.h +++ b/Weave/Graphix/Model/SkyBox.h @@ -11,7 +11,9 @@ public: void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const; + //uncommend following lines to use default Loaders void useModelMat(const mat4& model, Shader* shader) const; + void useTexture(Texture* texture, Shader* shader) const; }; diff --git a/Weave/Graphix/SceneObject.cpp b/Weave/Graphix/SceneObject.cpp index e74437e..8201e5f 100644 --- a/Weave/Graphix/SceneObject.cpp +++ b/Weave/Graphix/SceneObject.cpp @@ -12,8 +12,7 @@ #include "Scene.h" #include "Texture.h" -#include "IMesh.h" -#include "IMetaMesh.h" +#include "Model.h" #include "Graphix.h" diff --git a/Weave/Weave.vcxproj b/Weave/Weave.vcxproj index d21a26d..9f0dd6a 100644 --- a/Weave/Weave.vcxproj +++ b/Weave/Weave.vcxproj @@ -92,42 +92,45 @@ - + + - + - + - + + + - + - + - + diff --git a/Weave/Weave.vcxproj.filters b/Weave/Weave.vcxproj.filters index 4820f10..8c9156f 100644 --- a/Weave/Weave.vcxproj.filters +++ b/Weave/Weave.vcxproj.filters @@ -54,16 +54,19 @@ Source Files - + Source Files - + Source Files - + Source Files - + + Source Files + + Source Files @@ -107,16 +110,22 @@ Header Files - + Header Files - + + Header Files + + + Header Files + + Header Files - + Header Files - + Header Files diff --git a/winrar.bat b/winrar.bat new file mode 100644 index 0000000..9ae18d0 --- /dev/null +++ b/winrar.bat @@ -0,0 +1,5 @@ +@echo off + +C:\Programme\WinRar\rar a -r -x*.blend -x*.blend* -x*.pdb -x*.psb -x*.psd CGUE.zip textures models shader bin + +#pause \ No newline at end of file -- 2.47.3