From: Peter Schaefer Date: Mon, 28 Mar 2016 13:38:16 +0000 (+0200) Subject: defined a Name for Meshes X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=d522a5288566d38a2f582b5b01416b4074efffd0;p=cgue_weave.git defined a Name for Meshes added bind for Model, unbind for Model and Shader --- diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 009bccc..9375f8a 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -1,166 +1,166 @@ -#include "Game.h" - -#include - -#include "GLM.h" -#include - -#include -#include -#include - -#include - -#include "Scene.h" - -#include "Graphix\Shader.h" -#include "Graphix\Graphix.h" -#include "Graphix\Texture.h" -#include "Fps.h" -#include "Events.h" - -#include "Graphix\Model.h" - -#include "Message.h" - -//#include "PlayerI.h" - -#include -#include - -//#define FRAMERATE_FIX 60 - -using std::cout; -using std::endl; - -using std::string; - -typedef unsigned int uint; - -Game::Game() : playing(true) -{ - srand((int)time(NULL)); - // Hauptfenster - current_world = new Scene(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight(), 45, 0.1f, 40, vec3(0.0f, 0.0f, 0.f)); - - //Allg Shader - Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); - - // load LVL - - SceneObject* tmp_world = new Level(shader1, "level_1.dae", "model_levelTest_2D.jpg"); - - //tmp_world->ignore = true; - current_world->addObject(tmp_world); - -// current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, 1.f, 0.f)), vec4(1.0f, 1.0f, 1.0f, 3.0f), new BBox(), "")); - - //Player - SceneObject* tmp_playerObject = new Marvin(shader1, translate(vec3(1.f, 3.f, 1.f))*rotate((float)M_PI_4,vec3(0.f,1.f,0.f))); - - tmp_playerObject->yStatic= false; - - current_world->addObject(tmp_playerObject); - current_world->setLookAt(tmp_playerObject); - - //current_world->addObject(new SceneObject(shader1, glm::mat4(1.0f), "Player.dae", "model_player.png")); - //current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f))*scale(vec3(3.f)), "cow/cow.dae", "model_cow_2D.jpg")); - current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f)), vec4(3.0f, 0.5f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); - current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, .4f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); - current_world->addObject(new SceneObject(shader1, translate(vec3(0.f, .4f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "lever.dae", "model_duck_2D.png")); - - current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, 3.f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "SkyBox.dae", "model_SkyBox_2D.png")); - - //current_world->addObject(new EventBox(translate(vec3(3.f, .4f, 0.f)),EB_LOSTZONE)); - current_world->addObject(new EventBox(translate(vec3(3.f, .4f, -15.f)), EB_WINZONE)); - -} - - -Game::~Game() -{ - delete current_world; - - //RALLLY BAD HACK!!!! No Texture will be freed!!!! - //Texture::clean(); -} - - -void Game::play() -{ - Fps fps(0.3f); - int sleep_time=0; - float message_time=0; - int framecount = 0; - - while (!Events::halt){ - fps.step(); - -#ifdef FRAMERATE_FIX - sleep_time += (int)(1000./ FRAMERATE_FIX - fps.getTicks()); - - if (sleep_time < 0) - sleep_time = 0; - - Sleep(sleep_time); -#endif - if (Events::isKToggleActive(SDLK_F2)) - { - ++framecount; - message_time += fps.getDelta(); - if (message_time >= 1.5) - { - Message::info((string)"Fps: " + std::to_string((float)framecount/message_time)); - message_time = 0; - framecount = 0; - } - - } - - - - Events::processEvents(); - //Message::info(std::to_string(fps.getDelta())); - update(fps.getCappedDelta()); - - Graphix::clear(); - - draw(); - - Graphix::swap(); - - Graphix::getGlError(); - -// system("pause"); - } -} - -void Game::update(float deltaT) -{ - - if (Graphix::getWindowHeight() != current_world->getViewport().getHeight() || Graphix::getWindowWidth() != current_world->getViewport().getWidth()) - current_world->getViewport().setView(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight()); - if (playing){ - current_world->update(deltaT); - - // l_interface->update(deltaT); - } -// else -// l_menu->update(deltaT); -} - -void Game::draw() const -{ - if (playing){ - - //viewPort->bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f)); - //SkyBox->draw(); - - current_world->draw(); - - // l_interface->draw(); - } - //else - // l_menu->draw(); - +#include "Game.h" + +#include + +#include "GLM.h" +#include + +#include +#include +#include + +#include + +#include "Scene.h" + +#include "Graphix\Shader.h" +#include "Graphix\Graphix.h" +#include "Graphix\Texture.h" +#include "Fps.h" +#include "Events.h" + +#include "Graphix\Model.h" + +#include "Message.h" + +//#include "PlayerI.h" + +#include +#include + +//#define FRAMERATE_FIX 60 + +using std::cout; +using std::endl; + +using std::string; + +typedef unsigned int uint; + +Game::Game() : playing(true) +{ + srand((int)time(NULL)); + // Hauptfenster + current_world = new Scene(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight(), 45, 0.1f, 40, vec3(0.0f, 0.0f, 0.f)); + + //Allg Shader + Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); + + // load LVL + + SceneObject* tmp_world = new Level(shader1, "level_1.dae", "model_levelTest_2D.jpg"); + + //tmp_world->ignore = true; + current_world->addObject(tmp_world); + +// current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, 1.f, 0.f)), vec4(1.0f, 1.0f, 1.0f, 3.0f), new BBox(), "")); + + //Player + SceneObject* tmp_playerObject = new Marvin(shader1, translate(vec3(1.f, 3.f, 1.f))*rotate((float)M_PI_4,vec3(0.f,1.f,0.f))); + + tmp_playerObject->yStatic= false; + + current_world->addObject(tmp_playerObject); + current_world->setLookAt(tmp_playerObject); + + //current_world->addObject(new SceneObject(shader1, glm::mat4(1.0f), "Player.dae", "model_player.png")); + //current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f))*scale(vec3(3.f)), "cow/cow.dae", "model_cow_2D.jpg")); + current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f)), vec4(3.0f, 0.5f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); + current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, .4f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); + current_world->addObject(new SceneObject(shader1, translate(vec3(0.f, .4f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "lever.dae", "model_duck_2D.png")); + + current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, 3.f, 0.f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "SkyBox.dae", "model_SkyBox_2D.png")); + + //current_world->addObject(new EventBox(translate(vec3(3.f, .4f, 0.f)),EB_LOSTZONE)); + current_world->addObject(new EventBox(translate(vec3(3.f, .4f, -15.f)), EB_WINZONE)); + +} + + +Game::~Game() +{ + delete current_world; + + //RALLLY BAD HACK!!!! No Texture will be freed!!!! + //Texture::clean(); +} + + +void Game::play() +{ + Fps fps(0.3f); + int sleep_time=0; + float message_time=0; + int framecount = 0; + + while (!Events::halt){ + fps.step(); + +#ifdef FRAMERATE_FIX + sleep_time += (int)(1000./ FRAMERATE_FIX - fps.getTicks()); + + if (sleep_time < 0) + sleep_time = 0; + + Sleep(sleep_time); +#endif + if (Events::isKToggleActive(SDLK_F2)) + { + ++framecount; + message_time += fps.getDelta(); + if (message_time >= 1.5) + { + Message::info((string)"Fps: " + std::to_string((float)framecount/message_time)); + message_time = 0; + framecount = 0; + } + + } + + + + Events::processEvents(); + //Message::info(std::to_string(fps.getDelta())); + update(fps.getCappedDelta()); + + Graphix::clear(); + + draw(); + + Graphix::swap(); + + Graphix::getGlError(); + +// system("pause"); + } +} + +void Game::update(float deltaT) +{ + + if (Graphix::getWindowHeight() != current_world->getViewport().getHeight() || Graphix::getWindowWidth() != current_world->getViewport().getWidth()) + current_world->getViewport().setView(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight()); + if (playing){ + current_world->update(deltaT); + + // l_interface->update(deltaT); + } +// else +// l_menu->update(deltaT); +} + +void Game::draw() const +{ + if (playing){ + + //viewPort->bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f)); + //SkyBox->draw(); + + current_world->draw(); + + // l_interface->draw(); + } + //else + // l_menu->draw(); + } \ No newline at end of file diff --git a/Weave/Graphix/Model/BBox.cpp b/Weave/Graphix/Model/BBox.cpp index 5f84d7d..5de0e97 100644 --- a/Weave/Graphix/Model/BBox.cpp +++ b/Weave/Graphix/Model/BBox.cpp @@ -1,50 +1,46 @@ -#include "BBox.h" - -#include "GL\glew.h" -#include "../../GLM.h" - - -BBox::BBox() -{ - numvertices = 8; - - 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); -// genBuffer(indexBuffer, 4 * sizeof(float), (void*)indexL1); - - bt_collision_shape = new btBoxShape(btVector3(.5f,.5f,.5f)); - -} - -BBox::~BBox() -{ - //delete bt_collision_shape; //done inside Model.cpp - - glDeleteBuffers(1, &vertexBuffer); - //glDeleteBuffers(1, &indexBuffer); - //glDeleteBuffers(1, &normalBuffer); - //glDeleteBuffers(1, &uvBuffer); -} - - -void BBox::drawModel() const -{ - uint indexL1[4]{ 0, 1, 2, 3 }, - indexL2[4]{ 4, 5, 6, 7}, - indexS1[8]{0, 4, 1, 5, 2, 6, 3, 7}; - - //glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, 0); - glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL1); - glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL2); - glDrawElements(GL_LINES, 8, GL_UNSIGNED_INT, indexS1); - glBindVertexArray(0); -} - - -BBox::operator std::string() const -{ - return "BBox"; -} +#include "BBox.h" + +#include "GL\glew.h" +#include "../../GLM.h" + + +BBox::BBox() +{ + numvertices = 8; + + 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); + + bindModel(); + + name = "BBox"; + + bt_collision_shape = new btBoxShape(btVector3(.5f,.5f,.5f)); + +} + +BBox::~BBox() +{ + //delete bt_collision_shape; //done inside Model.cpp +} + + +void BBox::drawModel() const +{ + uint indexL1[4]{ 0, 1, 2, 3 }, + indexL2[4]{ 4, 5, 6, 7}, + indexS1[8]{0, 4, 1, 5, 2, 6, 3, 7}; + + //glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, 0); + glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL1); + glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL2); + glDrawElements(GL_LINES, 8, GL_UNSIGNED_INT, indexS1); + glBindVertexArray(0); +} + + +std::string BBox::type2str() const +{ + return "BBox"; +} diff --git a/Weave/Graphix/Model/BBox.h b/Weave/Graphix/Model/BBox.h index a9a7c5c..3d99b2d 100644 --- a/Weave/Graphix/Model/BBox.h +++ b/Weave/Graphix/Model/BBox.h @@ -1,16 +1,16 @@ -#pragma once - -#include "Model.h" - -class BBox : - public Model -{ -public: - BBox(); - ~BBox(); - - void drawModel() const override; - - operator std::string() const override; -}; - +#pragma once + +#include "Model.h" + +class BBox : + public Model +{ +public: + BBox(); + ~BBox(); + + void drawModel() const override; + + std::string type2str() const override; +}; + diff --git a/Weave/Graphix/Model/IMesh.cpp b/Weave/Graphix/Model/IMesh.cpp index 8cf696e..f9b04a3 100644 --- a/Weave/Graphix/Model/IMesh.cpp +++ b/Weave/Graphix/Model/IMesh.cpp @@ -1,99 +1,90 @@ -#include "IMesh.h" - -#include - - -#include "../../GLM.h" - -#include -#include - -#include "../Shader.h" -#include "../Texture.h" -#include "../../Message.h" - -#include "../Graphix.h" - -using std::string; -using std::list; -using std::array; - -//IMesh::IMesh(const string& _modelpath, uint _mindex) : modelpath(_modelpath), root(nullptr) -//{ -// -// import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex); -// -// btConvexHullShape* tmp_shape = new btConvexHullShape(); -// -// for (uint i = 0; i < numvertices; i += 3) -// tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2])); -// -// bt_collision_shape = tmp_shape; -// -// setBB(numvertices, vertex); -// -// genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); -// genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); -// genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); -// genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); -// -//} - -IMesh::IMesh(const aiMesh* _mesh, const vec3& _scale, bool _isConvex) : modelpath("IMesh") -{ - import(_mesh, numvertices, numfaces, vertex, uvs, normals, index, _scale); - - btTriangleIndexVertexArray* meshInterface = new btTriangleIndexVertexArray(); - btIndexedMesh part; - part.m_vertexBase = (const unsigned char*)vertex; - part.m_vertexStride = sizeof(float) * 3; - part.m_numVertices = numvertices; - part.m_triangleIndexBase = (const unsigned char*)index; - part.m_triangleIndexStride = sizeof(uint) * 3; - part.m_numTriangles = numfaces; - part.m_indexType = PHY_INTEGER; - - meshInterface->addIndexedMesh(part, PHY_INTEGER); - - if (_isConvex) - bt_collision_shape = new btConvexTriangleMeshShape(meshInterface, true); - else - bt_collision_shape = new btBvhTriangleMeshShape(meshInterface, true); - - genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); - genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); - genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); - genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); - -} - -IMesh::~IMesh() -{ - delete vertex, normals, uvs, index; - - glDeleteBuffers(1, &vertexBuffer); - glDeleteBuffers(1, &indexBuffer); - glDeleteBuffers(1, &normalBuffer); - glDeleteBuffers(1, &uvBuffer); -} - -//void IMesh::useModelMat(const mat4& _model, Shader* _shader) const -//{ -// // Model::useModelMat(_model, _shader); -// // Model::useModelMat(_model * modelMat, _shader); -// int tmp = _shader->getUniformLocation("uModel"); -// if (tmp >= 0) -// glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model* modelMat)); -//} - - -void IMesh::drawBBox(const mat4& _modelMat, const vec4& _color) const -{ - Model::drawBBox(_modelMat, _color); -} - - -IMesh::operator string() const -{ - return "IMesh"; -} +#include "IMesh.h" + +#include + + +#include "../../GLM.h" + +#include +#include + +#include "../Shader.h" +#include "../Texture.h" +#include "../../Message.h" + +#include "../Graphix.h" + +using std::string; +using std::list; +using std::array; + +//IMesh::IMesh(const string& _modelpath, uint _mindex) : modelpath(_modelpath), root(nullptr) +//{ +// +// import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex); +// +// btConvexHullShape* tmp_shape = new btConvexHullShape(); +// +// for (uint i = 0; i < numvertices; i += 3) +// tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2])); +// +// bt_collision_shape = tmp_shape; +// +// setBB(numvertices, vertex); +// +// genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); +// genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); +// genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); +// genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); +// +//} + +IMesh::IMesh(const aiMesh* _mesh, const vec3& _scale, bool _isConvex) : modelpath("IMesh") +{ + loadMesh(_mesh, numvertices, numfaces, vertex, uvs, normals, index, name, _scale); + btTriangleIndexVertexArray* meshInterface = new btTriangleIndexVertexArray(); + btIndexedMesh part; + part.m_vertexBase = (const unsigned char*)vertex; + part.m_vertexStride = sizeof(float) * 3; + part.m_numVertices = numvertices; + part.m_triangleIndexBase = (const unsigned char*)index; + part.m_triangleIndexStride = sizeof(uint) * 3; + part.m_numTriangles = numfaces; + part.m_indexType = PHY_INTEGER; + meshInterface->addIndexedMesh(part, PHY_INTEGER); + + if (_isConvex) + bt_collision_shape = new btConvexTriangleMeshShape(meshInterface, true); + else + bt_collision_shape = new btBvhTriangleMeshShape(meshInterface, true); + + bindModel(); + + +} + +IMesh::~IMesh() +{ + unbindModel(); +} + +//void IMesh::useModelMat(const mat4& _model, Shader* _shader) const +//{ +// // Model::useModelMat(_model, _shader); +// // Model::useModelMat(_model * modelMat, _shader); +// int tmp = _shader->getUniformLocation("uModel"); +// if (tmp >= 0) +// glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model* modelMat)); +//} + + +void IMesh::drawBBox(const mat4& _modelMat, const vec4& _color) const +{ + Model::drawBBox(_modelMat, _color); +} + + +string IMesh::type2str() const +{ + return "IMesh"; +} diff --git a/Weave/Graphix/Model/IMesh.h b/Weave/Graphix/Model/IMesh.h index a837bb9..e3c4401 100644 --- a/Weave/Graphix/Model/IMesh.h +++ b/Weave/Graphix/Model/IMesh.h @@ -1,36 +1,33 @@ -#pragma once - -#include -#include -#include "../../GLM.h" -#include "../../Overlap.h" - -#include "Model.h" - -class Shader; -class Texture; - -class IMesh : public Model -{ -public: -// class Node; - -// IMesh(const std::string& modelpath, uint index=0); - IMesh(const aiMesh* mesh, const vec3& scale = vec3(1.f), bool isConvex=true); - - virtual ~IMesh(); - - //void useModelMat(const mat4& model, Shader* shader) const override; - - void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override; - - operator std::string() const override; - -protected: - - std::string modelpath; - - float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; - uint *index = nullptr; - +#pragma once + +#include +#include +#include "../../GLM.h" +#include "../../Overlap.h" + +#include "Model.h" + +class Shader; +class Texture; + +class IMesh : public Model +{ +public: +// class Node; + +// IMesh(const std::string& modelpath, uint index=0); + IMesh(const aiMesh* mesh, const vec3& scale = vec3(1.f), bool isConvex=true); + + virtual ~IMesh(); + + //void useModelMat(const mat4& model, Shader* shader) const override; + + void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override; + + std::string type2str() const override; + +protected: + + std::string modelpath; + }; \ No newline at end of file diff --git a/Weave/Graphix/Model/IMetaMesh.cpp b/Weave/Graphix/Model/IMetaMesh.cpp index 41bfeb8..062e9f5 100644 --- a/Weave/Graphix/Model/IMetaMesh.cpp +++ b/Weave/Graphix/Model/IMetaMesh.cpp @@ -1,186 +1,211 @@ -#include "IMetaMesh.h" - -#include -#include -#include - -#include "../../GLM.h" - -#include "IMesh.h" -#include "IAnimMesh.h" -#include "../Shader.h" -#include "../../Message.h" - - -using std::string; - -IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale, bool _isConvex) : modelpath(_modelpath) -{ - Assimp::Importer importer; - - const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); - if (!scene) - { - Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); - return; - } - - const aiNode* root = scene->mRootNode; - - - if (scene->HasMeshes())// && scene->mNumMeshes > mindex) - { - aiMatrix4x4* aimat; - mat4 tmpModelMat, tmpModelMatClean; - btTransform tmpModelMatBT; - //vec3 BBmin, BBmax, tmpMin, tmpMax; - - btCompoundShape* tmp_shape = new btCompoundShape(); - - aimat = &(root->mChildren[0]->mTransformation); - - tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); - tmpModelMatClean = removeScale(tmpModelMat); - tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); - - - if (!scene->HasAnimations()) - { - - IMesh* tmpIMesh; - tmpIMesh = new IMesh(scene->mMeshes[0], _scale* getScale(tmpModelMat), _isConvex); - models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); - tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); - - for (uint i = 1; i < scene->mNumMeshes; i++) - { - aimat = &(root->mChildren[i]->mTransformation); - - tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); - tmpModelMatClean = removeScale(tmpModelMat); - tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); - tmpIMesh = new IMesh(scene->mMeshes[i], _scale* getScale(tmpModelMat), _isConvex); - models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); - - tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); - } - - bt_collision_shape = tmp_shape; - - } - else - { - IAnimMesh* tmpIMesh; - tmpIMesh = new IAnimMesh(scene->mMeshes[0], _scale* getScale(tmpModelMat), _isConvex); - - for (uint l = 0; l < scene->mNumAnimations; l++) - { - aiAnimation* tmpanimation = scene->mAnimations[l]; - for (uint j = 0; j < tmpanimation->mNumChannels; j++) - { - if (tmpanimation->mChannels[j]->mNodeName == root->mChildren[0]->mName) - { - tmpIMesh->addanimation(tmpanimation->mChannels[j]); - } - } - } - - models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); - tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); - - - - for (uint i = 1; i < scene->mNumMeshes; i++) - { - aimat = &(root->mChildren[i]->mTransformation); - - tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); - tmpModelMatClean = removeScale(tmpModelMat); - tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); - tmpIMesh = new IAnimMesh(scene->mMeshes[i], _scale* getScale(tmpModelMat), _isConvex); - - for (uint l = 0; l < scene->mNumAnimations; l++) - { - aiAnimation* tmpanimation = scene->mAnimations[l]; - for (uint j = 0; j < tmpanimation->mNumChannels; j++) - { - if (tmpanimation->mChannels[j]->mNodeName == root->mChildren[i]->mName) - { - tmpIMesh->addanimation(tmpanimation->mChannels[j]); - } - } - } - - models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); - tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); - } - - bt_collision_shape = tmp_shape; - } - } - else - { - Message::error("The file " + _modelpath + " doesn't contain any nodes."); - return; - } -} - -IMetaMesh::~IMetaMesh() -{ - for (auto i = models.begin(); i != models.end(); ++i) - { - delete i->first; - } -} - -void IMetaMesh::bindShader(Shader* _shader) -{ - for (auto i = models.begin(); i != models.end(); ++i) - { - i->first->bindShader(_shader); - } -} - -void IMetaMesh::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const -{ - for (auto i = models.begin(); i != models.end(); ++i) - { - i->first->drawModel(_shader, _texture, _modelMat* i->second); - } -} - - -void IMetaMesh::drawBBox(const mat4& _modelMat, const vec4& _color) const -{ - // Model::drawBBox(_modelMat, vec4(0.f,.3f,.9f,1.f)); - if (models.size() == 1) - { - auto i = models.front(); - i.first->drawBBox(_modelMat* i.second, _color); - } - else - { - Model::drawBBox(_modelMat, _color); - if (models.size() > 1) - { - for (auto i = models.begin(); i != models.end(); ++i) - { - i->first->drawBBox(_modelMat* i->second, _color*0.8f); - } - } - } -} - - -IMetaMesh::operator string() const -{ - return modelpath; -} - -void IMetaMesh::setMargin(btScalar _margin) -{ - for (auto i = models.begin(); i != models.end(); ++i) - { - i->first->setMargin(_margin); - } +#include "IMetaMesh.h" + +#include +#include +#include + +#include "../../GLM.h" + +#include "IMesh.h" +#include "IAnimMesh.h" +#include "../Shader.h" +#include "../../Message.h" + + +using std::string; + +IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale, bool _isConvex) : modelpath(_modelpath) +{ + Assimp::Importer importer; + + const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); + if (!scene) + { + Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); + return; + } + + const aiNode* root = scene->mRootNode; + + + if (scene->HasMeshes())// && scene->mNumMeshes > mindex) + { + aiMatrix4x4* aimat; + mat4 tmpModelMat, tmpModelMatClean; + btTransform tmpModelMatBT; + //vec3 BBmin, BBmax, tmpMin, tmpMax; + + btCompoundShape* tmp_shape = new btCompoundShape(); + + aimat = &(root->mChildren[0]->mTransformation); + + tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); + tmpModelMatClean = removeScale(tmpModelMat); + tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); + + + //if (!scene->HasAnimations()) + { + + IMesh* tmpIMesh; + tmpIMesh = new IMesh(scene->mMeshes[0], _scale* getScale(tmpModelMat), _isConvex); + models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); + tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); + + for (uint i = 1; i < scene->mNumMeshes; i++) + { + aimat = &(root->mChildren[i]->mTransformation); + + tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); + tmpModelMatClean = removeScale(tmpModelMat); + tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); + tmpIMesh = new IMesh(scene->mMeshes[i], _scale* getScale(tmpModelMat), _isConvex); + models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); + + tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); + } + + bt_collision_shape = tmp_shape; + + } + /* + else + { + IAnimMesh* tmpIMesh; + tmpIMesh = new IAnimMesh(scene->mMeshes[0], _scale* getScale(tmpModelMat), _isConvex); + + for (uint l = 0; l < scene->mNumAnimations; l++) + { + aiAnimation* tmpanimation = scene->mAnimations[l]; + for (uint j = 0; j < tmpanimation->mNumChannels; j++) + { + if (tmpanimation->mChannels[j]->mNodeName == root->mChildren[0]->mName) + { + tmpIMesh->addanimation(tmpanimation->mChannels[j]); + } + } + } + + models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); + tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); + + + + for (uint i = 1; i < scene->mNumMeshes; i++) + { + aimat = &(root->mChildren[i]->mTransformation); + + tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4); + tmpModelMatClean = removeScale(tmpModelMat); + tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); + tmpIMesh = new IAnimMesh(scene->mMeshes[i], _scale* getScale(tmpModelMat), _isConvex); + + for (uint l = 0; l < scene->mNumAnimations; l++) + { + aiAnimation* tmpanimation = scene->mAnimations[l]; + for (uint j = 0; j < tmpanimation->mNumChannels; j++) + { + if (tmpanimation->mChannels[j]->mNodeName == root->mChildren[i]->mName) + { + tmpIMesh->addanimation(tmpanimation->mChannels[j]); + } + } + } + + models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); + tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); + } + + bt_collision_shape = tmp_shape; + }*/ + } + else + { + Message::error("The file " + _modelpath + " doesn't contain any nodes."); + return; + } +} + +IMetaMesh::~IMetaMesh() +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + delete i->first; + } +} + +void IMetaMesh::bindModel() +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->bindModel(); + } +} + +void IMetaMesh::unbindModel() +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->unbindModel(); + } +} + +void IMetaMesh::bindShader(Shader* _shader) +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->bindShader(_shader); + } +} + +void IMetaMesh::unbindShader(Shader* _shader) +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->unbindShader(_shader); + } +} + +void IMetaMesh::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->drawModel(_shader, _texture, _modelMat* i->second); + } +} + + +void IMetaMesh::drawBBox(const mat4& _modelMat, const vec4& _color) const +{ + // Model::drawBBox(_modelMat, vec4(0.f,.3f,.9f,1.f)); + if (models.size() == 1) + { + auto i = models.front(); + i.first->drawBBox(_modelMat* i.second, _color); + } + else + { + Model::drawBBox(_modelMat, _color); + if (models.size() > 1) + { + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->drawBBox(_modelMat* i->second, _color*0.8f); + } + } + } +} + + +string IMetaMesh::type2str() const +{ + return "IMetaMesh"; +} + +void IMetaMesh::setMargin(btScalar _margin) +{ + for (auto i = models.begin(); i != models.end(); ++i) + { + i->first->setMargin(_margin); + } } \ No newline at end of file diff --git a/Weave/Graphix/Model/IMetaMesh.h b/Weave/Graphix/Model/IMetaMesh.h index b7363e9..c5e79ca 100644 --- a/Weave/Graphix/Model/IMetaMesh.h +++ b/Weave/Graphix/Model/IMetaMesh.h @@ -1,36 +1,41 @@ -#pragma once - -#include "Model.h" - -#include -#include -#include "../../GLM.h" -#include "../../Overlap.h" - -class IMesh; -class Shader; -class Texture; - -class IMetaMesh : public Model -{ -public: - IMetaMesh(const std::string& modelpath, const vec3& scale = vec3(1.f), bool isConvex = true); - ~IMetaMesh(); - - void bindShader(Shader* shader) override; - - void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const override; - - void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override; - - operator std::string() const override; - - void setMargin(btScalar margin) override; - -protected: - - std::string modelpath; - //std::list models; - std::list> models; -}; - +#pragma once + +#include "Model.h" + +#include +#include +#include "../../GLM.h" +#include "../../Overlap.h" + +class IMesh; +class Shader; +class Texture; + +class IMetaMesh : public Model +{ +public: + IMetaMesh(const std::string& modelpath, const vec3& scale = vec3(1.f), bool isConvex = true); + ~IMetaMesh(); + + void bindShader(Shader* shader) override; + + void bindModel() override; + + void unbindModel() override; + void unbindShader(Shader* shader) override; + + void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const override; + + void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const override; + + std::string type2str() const override; + + void setMargin(btScalar margin) override; + +protected: + + std::string modelpath; + //std::list models; + std::list> models; +}; + diff --git a/Weave/Graphix/Model/Model.cpp b/Weave/Graphix/Model/Model.cpp index 5068375..b9bb475 100644 --- a/Weave/Graphix/Model/Model.cpp +++ b/Weave/Graphix/Model/Model.cpp @@ -1,391 +1,418 @@ -#include "Model.h" - -#include -#include "../../Message.h" - -#include "../Shader.h" -#include "../Texture.h" - -#include "../Graphix.h" - -#include -#include -#include - -#include "BBox.h" -#include "SkyBox.h" -#include "IMetaMesh.h" - -#include "../../Events.h" - -Model::Model() : -numfaces(0), -numvertices(0), -vertexBuffer(-1), -normalBuffer(-1), -uvBuffer(-1), -indexBuffer(-1), -bt_collision_shape(nullptr) -{ -} - -Model::~Model() -{ - if (bt_collision_shape!=nullptr) - delete bt_collision_shape; - for (auto i = shader_map.begin(); i != shader_map.end(); ++i){ - glDeleteVertexArrays(1, &(i->second)); - } -} - - -void Model::bindShader(Shader* _shader) -{ - //Message::info("bindShader"); - //Graphix::getGlError(); - //Message::info("Do Stuff"); - - uint vao; - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - - //Message::info("bindVAO"); - //Graphix::getGlError(); - if (vertexBuffer != (uint)-1) - bindBuffer(vertexBuffer, _shader->getAttribLocation("aPosition")); - //Message::info("aPosition"); - //Graphix::getGlError(); - if (uvBuffer != (uint)-1) - bindBuffer(uvBuffer, _shader->getAttribLocation("aUV"), 2); - //Message::info("aUV"); - //Graphix::getGlError(); - if (normalBuffer != (uint)-1) - bindBuffer(normalBuffer, _shader->getAttribLocation("aNormal")); - //Message::info("aNormal"); - //Graphix::getGlError(); - - if (indexBuffer != (uint)-1) - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); - //Message::info("bindIndexBuffer"); - //Graphix::getGlError(); - - glBindVertexArray(0); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - shader_map[*_shader] = vao; - - //Message::info("cleanUp"); - //Graphix::getGlError(); - //Message::info("Done"); -} - -void Model::drawModel() const -{ - if (Events::isKToggleActive(SDLK_F3)) - glDrawElements(GL_LINE_LOOP, numfaces * 3, GL_UNSIGNED_INT, 0); - else - 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?"); - //Graphix::getGlError(); - useModel(_shader); - //Message::info("IMesh loading Coordinates"); - //Graphix::getGlError(); - useTexture(_texture, _shader); - //Message::info("IMesh loading Texture"); - //Graphix::getGlError(); - useModelMat(_modelMat, _shader); - //Message::info("IMesh loading MMatrix"); - //Graphix::getGlError(); - drawModel(); - //Message::info("IMesh drawing Elements"); - //Graphix::getGlError(); - //system("pause"); -} - -void Model::drawBBox(const mat4& _modelMat, const vec4& _color) const -{ - Graphix::getGlError(); - Graphix::shader_BBox->useShader(); - int tmp = Graphix::shader_BBox->getUniformLocation("uFragmentColor"); - if (tmp >= 0) - glUniform4fv(tmp, 1, value_ptr(_color)); - Graphix::getGlError(); - - btVector3 minB, maxB; - btTransform trans; - trans.setIdentity(); - bt_collision_shape->getAabb(trans, minB, maxB); - - vec3 min = vec3(minB.getX(), minB.getY(), minB.getZ()); - vec3 max = vec3(maxB.getX(), maxB.getY(), maxB.getZ()); - - vec3 size = (max - min); - vec3 center = (max + min) * .5f; - - getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(center)*glm::scale(size)); // -} - -void Model::getBBcs(vec3& _center, vec3& _size) const -{ - btVector3 minB, maxB; - btTransform trans; - trans.setIdentity(); - bt_collision_shape->getAabb(trans, minB, maxB); - - vec3 min = vec3(minB.getX(), minB.getY(), minB.getZ()); - vec3 max = vec3(maxB.getX(), maxB.getY(), maxB.getZ()); - - _size = (max - min) * .5f; - _center = (max + min) * .5f; -} - -void Model::genBuffer(uint &buffer, uint size, void* value) -{ - glGenBuffers(1, &buffer); - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, size, value, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - -void Model::bindBuffer(const uint &buffer, const uint index, const uint dim) -{ - //Falls index nicht gefunden werden konnte - if (index == (uint)-1) - { - Message::info("Model: BindBuffer wird ausgelassen da index fehlerhaft ist."); - return; - } - - glBindBuffer(GL_ARRAY_BUFFER, buffer); - glEnableVertexAttribArray(index); - glVertexAttribPointer(index, dim, GL_FLOAT, GL_FALSE, 0, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - - -void Model::useModel(Shader* _shader) const -{ - _shader->useShader(); - uint vao = -1; - auto i = shader_map.find(*_shader); - if (i == shader_map.end()) - Message::error("The Shader wasn't bind to the Model.\n"); - else - vao = i->second; - - glBindVertexArray(vao); - -} - -void Model::useTexture(Texture* _texture, Shader* _shader) const -{ - if (_texture != nullptr) - { - auto tmp = _shader->getUniformLocation("uColorTexture"); - if (tmp < 0){ - return; - } - int unit = 0; - _texture->bind(unit); - glUniform1i(tmp, unit); - - int tmp2 = _shader->getUniformLocation("material"); - if (tmp2 >= 0) - glUniform4fv(tmp2, 1, value_ptr(_texture->material)); - } -} - -void Model::useModelMat(const mat4& _model, Shader* _shader) const -{ - int tmp = _shader->getUniformLocation("uModel"); - if (tmp >= 0) - glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model)); -} - -Model::operator btCollisionShape*() const -{ - return bt_collision_shape; -} - -vec3 Model::rotateSize(const vec3& _size, const mat4& _modelMat) -{ - vec3 newSize(0.f); - mat3 tmpModelMat(_modelMat); - for (auto i = 0; i < 3; ++i) - newSize += abs(tmpModelMat[i]) * _size[i]; - return newSize; -} - -float Model::directSize(const vec3& _size, const vec3& _direction) -{ - float ret(0.f); - for (auto i = 0; i < 3; ++i) - { - ret += abs(_size[i]*_direction[i]); - } - return ret; -} - -Model* Model::getBBoxModel() -{ - if (BoundingBox == nullptr) - { - BoundingBox = new BBox(); - BoundingBox->bindShader(Graphix::shader_BBox); - } - return BoundingBox; -} - -Model* Model::getSkyBoxModel() -{ - if (SkyBoxModel == nullptr) - { - SkyBoxModel = new SkyBox(); - //SkyBoxModel->bindShader(Graphix::shader_); - } - return SkyBoxModel; -} - -Model* Model::newIMetaModel(const string& _modelpath, bool _isConvex) -{ - Model*& ptr = IMetaModel[_modelpath]; - if (ptr == nullptr) - { - ptr = new IMetaMesh(_modelpath,vec3(1.f),_isConvex); - //ptr->bindShader(Graphix::shader_BBox); - } - ++IMetaModel_count[_modelpath]; - return ptr; -} - -void Model::deleteBBoxModel() -{ - delete BoundingBox; - BoundingBox = nullptr; -} - -void Model::deleteSkyBoxModel() -{ - delete SkyBoxModel; - SkyBoxModel = nullptr; -} - -void Model::deleteIMetaModel(const string& _modelpath) -{ - if (_modelpath == "SkyBox" || _modelpath == "BBox" || _modelpath == "IMesh") - { - Message::warning("deleteIMetaModel: dont use deleteIMetaModel with " + _modelpath); - return; - } - - uint& count = IMetaModel_count[_modelpath]; - --count; - - if (!count) - { - Model*& ptr = IMetaModel[_modelpath]; - delete ptr; - ptr = nullptr; - } - - -} - - -float Model::getPDistHit(const vec3& _P, const vec3& _direction) const -{ - - vec3 posA, sizeA; - getBBcs(posA, sizeA); - - //vec3 posAR = (vec3)(modelAR*vec4(posA, 1.f)); - //vec3 posBR = (vec3)(modelBR*vec4(posB, 1.f)); - - - return 1; -} - - -bool Model::import(const string& _modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint _mindex) -{ - Assimp::Importer importer; - - const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); //aiProcess_PreTransformVertices - if (!scene) - { - Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); - return false; - } - - if (!scene->HasMeshes() || scene->mNumMeshes <= _mindex) - { - Message::error("The file " + _modelpath + " doesn't contain any nodes."); - return false; - } - - return import(scene->mMeshes[_mindex], numvertices, numfaces, vertex, uvs, normals, index); -} - -bool Model::import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, const vec3& _scale) -{ - - numvertices = mesh->mNumVertices; - numfaces = mesh->mNumFaces; - vertex = new float[numvertices * 3]; - uvs = new float[numvertices * 2]; - index = new uint[numfaces * 3]; - normals = new float[numvertices * 3]; - //aiFace* faces = mesh->mFaces; - - - //load vertices from Mesh - for (uint i = 0; i < numvertices; i++) - { - vertex[3 * i] = _scale.x * mesh->mVertices[i].x; - vertex[3 * i + 1] = _scale.y * mesh->mVertices[i].y; - vertex[3 * i + 2] = _scale.z * mesh->mVertices[i].z; - } - - //load UVs from Mesh - for (uint i = 0; i < numvertices; i++) - { - uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x; - uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y; - } - - //load indices from Mesh - for (uint i = 0; i < numfaces; i++) - { - index[3 * i] = mesh->mFaces[i].mIndices[0]; - index[3 * i + 1] = mesh->mFaces[i].mIndices[1]; - index[3 * i + 2] = mesh->mFaces[i].mIndices[2]; - } - - //load normals from Mesh - for (uint i = 0; i < numvertices; i++) - { - normals[3 * i] = mesh->mNormals[i].x;// / _scale.x; - normals[3 * i + 1] = mesh->mNormals[i].y;// / _scale.y; - normals[3 * i + 2] = mesh->mNormals[i].z;// / _scale.z; - } - - return true; -} - -void Model::setMargin(btScalar _margin) -{ - bt_collision_shape->setMargin(_margin); -} - - -Model* Model::BoundingBox = nullptr; -Model* Model::SkyBoxModel = nullptr; -std::unordered_map Model::IMetaModel; -std::unordered_map Model::IMetaModel_count; +#include "Model.h" + +#include +#include "../../Message.h" + +#include "../Shader.h" +#include "../Texture.h" + +#include "../Graphix.h" + +#include +#include +#include + +#include "BBox.h" +#include "SkyBox.h" +#include "IMetaMesh.h" + +#include "../../Events.h" + +using namespace std; + +Model::Model() : +numfaces(0), +numvertices(0), +vertexBuffer(-1), +normalBuffer(-1), +uvBuffer(-1), +indexBuffer(-1), +bt_collision_shape(nullptr) +{ +} + +Model::~Model() +{ + if (bt_collision_shape!=nullptr) + delete bt_collision_shape; + for (auto i = shader_map.begin(); i != shader_map.end(); ++i) { + glDeleteVertexArrays(1, &(i->second)); + } +} + + +Model::operator std::string() const +{ + return name; +} + +void Model::bindModel() +{ + if(vertex!=nullptr) + genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); + if (normals != nullptr) + genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); + if (uvs != nullptr) + genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); + if (index != nullptr) + genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); +} + +void Model::unbindModel() +{ + if(vertexBuffer!= (uint)-1) + glDeleteBuffers(1, &vertexBuffer); + if (indexBuffer != (uint)-1) + glDeleteBuffers(1, &indexBuffer); + if (normalBuffer != (uint)-1) + glDeleteBuffers(1, &normalBuffer); + if (uvBuffer != (uint)-1) + glDeleteBuffers(1, &uvBuffer); +} + + +void Model::bindShader(Shader* _shader) +{ + + uint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + + if (vertexBuffer != (uint)-1) + bindBuffer(vertexBuffer, _shader->getAttribLocation("aPosition")); + + if (uvBuffer != (uint)-1) + bindBuffer(uvBuffer, _shader->getAttribLocation("aUV"), 2); + + if (normalBuffer != (uint)-1) + bindBuffer(normalBuffer, _shader->getAttribLocation("aNormal")); + + if (indexBuffer != (uint)-1) + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); + + shader_map[*_shader] = vao; + + glBindVertexArray(0); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + +} + +void Model::unbindShader(Shader* _shader) +{ + glDeleteVertexArrays(1, &(shader_map[*_shader])); + shader_map.erase(*_shader); + +} + +void Model::drawModel() const +{ + if (Events::isKToggleActive(SDLK_F3)) + glDrawElements(GL_LINE_LOOP, numfaces * 3, GL_UNSIGNED_INT, 0); + else + 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?"); + //Graphix::getGlError(); + useModel(_shader); + //Message::info("IMesh loading Coordinates"); + //Graphix::getGlError(); + useTexture(_texture, _shader); + //Message::info("IMesh loading Texture"); + //Graphix::getGlError(); + useModelMat(_modelMat, _shader); + //Message::info("IMesh loading MMatrix"); + //Graphix::getGlError(); + drawModel(); + //Message::info("IMesh drawing Elements"); + //Graphix::getGlError(); + //system("pause"); +} + +void Model::drawBBox(const mat4& _modelMat, const vec4& _color) const +{ + Graphix::getGlError(); + Graphix::shader_BBox->useShader(); + int tmp = Graphix::shader_BBox->getUniformLocation("uFragmentColor"); + if (tmp >= 0) + glUniform4fv(tmp, 1, value_ptr(_color)); + Graphix::getGlError(); + + btVector3 minB, maxB; + btTransform trans; + trans.setIdentity(); + bt_collision_shape->getAabb(trans, minB, maxB); + + vec3 min = vec3(minB.getX(), minB.getY(), minB.getZ()); + vec3 max = vec3(maxB.getX(), maxB.getY(), maxB.getZ()); + + vec3 size = (max - min); + vec3 center = (max + min) * .5f; + + getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(center)*glm::scale(size)); // +} + +void Model::getBBcs(vec3& _center, vec3& _size) const +{ + btVector3 minB, maxB; + btTransform trans; + trans.setIdentity(); + bt_collision_shape->getAabb(trans, minB, maxB); + + vec3 min = vec3(minB.getX(), minB.getY(), minB.getZ()); + vec3 max = vec3(maxB.getX(), maxB.getY(), maxB.getZ()); + + _size = (max - min) * .5f; + _center = (max + min) * .5f; +} + +void Model::genBuffer(uint &buffer, uint size, void* value) +{ + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, size, value, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +void Model::bindBuffer(const uint &buffer, const uint index, const uint dim) +{ + //Falls index nicht gefunden werden konnte + if (index == (uint)-1) + { + Message::info("Model: BindBuffer wird ausgelassen da index fehlerhaft ist."); + return; + } + + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glEnableVertexAttribArray(index); + glVertexAttribPointer(index, dim, GL_FLOAT, GL_FALSE, 0, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + + +void Model::useModel(Shader* _shader) const +{ + _shader->useShader(); + uint vao = -1; + auto i = shader_map.find(*_shader); + if (i == shader_map.end()) + Message::error("Model: Shader wurde nicht an das Model gebunden."); + else + vao = i->second; + + glBindVertexArray(vao); + +} + +void Model::useTexture(Texture* _texture, Shader* _shader) const +{ + if (_texture != nullptr) + { + auto tmp = _shader->getUniformLocation("uColorTexture"); + if (tmp < 0){ + return; + } + int unit = 0; + _texture->bind(unit); + glUniform1i(tmp, unit); + + int tmp2 = _shader->getUniformLocation("material"); + if (tmp2 >= 0) + glUniform4fv(tmp2, 1, value_ptr(_texture->material)); + } +} + +void Model::useModelMat(const mat4& _model, Shader* _shader) const +{ + int tmp = _shader->getUniformLocation("uModel"); + if (tmp >= 0) + glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model)); +} + +Model::operator btCollisionShape*() const +{ + return bt_collision_shape; +} + +vec3 Model::rotateSize(const vec3& _size, const mat4& _modelMat) +{ + vec3 newSize(0.f); + mat3 tmpModelMat(_modelMat); + for (auto i = 0; i < 3; ++i) + newSize += abs(tmpModelMat[i]) * _size[i]; + return newSize; +} + +float Model::directSize(const vec3& _size, const vec3& _direction) +{ + float ret(0.f); + for (auto i = 0; i < 3; ++i) + { + ret += abs(_size[i]*_direction[i]); + } + return ret; +} + +Model* Model::getBBoxModel() +{ + if (BoundingBox == nullptr) + { + BoundingBox = new BBox(); + BoundingBox->bindShader(Graphix::shader_BBox); + } + return BoundingBox; +} + +Model* Model::getSkyBoxModel() +{ + if (SkyBoxModel == nullptr) + { + SkyBoxModel = new SkyBox(); + //SkyBoxModel->bindShader(Graphix::shader_); + } + return SkyBoxModel; +} + +Model* Model::newIMetaModel(const string& _modelpath, bool _isConvex) +{ + Model*& ptr = IMetaModel[_modelpath]; + if (ptr == nullptr) + { + ptr = new IMetaMesh(_modelpath,vec3(1.f),_isConvex); + //ptr->bindShader(Graphix::shader_BBox); + } + ++IMetaModel_count[_modelpath]; + return ptr; +} + +void Model::deleteBBoxModel() +{ + delete BoundingBox; + BoundingBox = nullptr; +} + +void Model::deleteSkyBoxModel() +{ + delete SkyBoxModel; + SkyBoxModel = nullptr; +} + +void Model::deleteIMetaModel(const string& _modelpath) +{ + if (_modelpath == "SkyBox" || _modelpath == "BBox" || _modelpath == "IMesh") + { + Message::warning("deleteIMetaModel: dont use deleteIMetaModel with " + _modelpath); + return; + } + + uint& count = IMetaModel_count[_modelpath]; + --count; + + if (!count) + { + Model*& ptr = IMetaModel[_modelpath]; + delete ptr; + ptr = nullptr; + } + + +} + + +float Model::getPDistHit(const vec3& _P, const vec3& _direction) const +{ + + vec3 posA, sizeA; + getBBcs(posA, sizeA); + + //vec3 posAR = (vec3)(modelAR*vec4(posA, 1.f)); + //vec3 posBR = (vec3)(modelBR*vec4(posB, 1.f)); + + + return 1; +} + + +bool Model::loadMesh(const string& _modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, string& name, uint _mindex) +{ + Assimp::Importer importer; + + const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); //aiProcess_PreTransformVertices + if (!scene) + { + Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); + return false; + } + + if (!scene->HasMeshes() || scene->mNumMeshes <= _mindex) + { + Message::error("The file " + _modelpath + " doesn't contain any nodes."); + return false; + } + + return loadMesh(scene->mMeshes[_mindex], numvertices, numfaces, vertex, uvs, normals, index, name); +} + +bool Model::loadMesh(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, string& name, const vec3& _scale) +{ + + name = std::string((char*) (mesh->mName.data),(uint) (mesh->mName.length)); + numvertices = mesh->mNumVertices; + numfaces = mesh->mNumFaces; + vertex = new float[numvertices * 3]; + uvs = new float[numvertices * 2]; + index = new uint[numfaces * 3]; + normals = new float[numvertices * 3]; + //aiFace* faces = mesh->mFaces; + + + //load vertices from Mesh + for (uint i = 0; i < numvertices; i++) + { + vertex[3 * i] = _scale.x * mesh->mVertices[i].x; + vertex[3 * i + 1] = _scale.y * mesh->mVertices[i].y; + vertex[3 * i + 2] = _scale.z * mesh->mVertices[i].z; + } + + //load UVs from Mesh + for (uint i = 0; i < numvertices; i++) + { + uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x; + uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y; + } + + //load indices from Mesh + for (uint i = 0; i < numfaces; i++) + { + index[3 * i] = mesh->mFaces[i].mIndices[0]; + index[3 * i + 1] = mesh->mFaces[i].mIndices[1]; + index[3 * i + 2] = mesh->mFaces[i].mIndices[2]; + } + + //load normals from Mesh + for (uint i = 0; i < numvertices; i++) + { + normals[3 * i] = mesh->mNormals[i].x;// / _scale.x; + normals[3 * i + 1] = mesh->mNormals[i].y;// / _scale.y; + normals[3 * i + 2] = mesh->mNormals[i].z;// / _scale.z; + } + + return true; +} + +void Model::setMargin(btScalar _margin) +{ + bt_collision_shape->setMargin(_margin); +} + + +Model* Model::BoundingBox = nullptr; +Model* Model::SkyBoxModel = nullptr; +std::unordered_map Model::IMetaModel; +std::unordered_map Model::IMetaModel_count; diff --git a/Weave/Graphix/Model/Model.h b/Weave/Graphix/Model/Model.h index ff7a4cb..7002089 100644 --- a/Weave/Graphix/Model/Model.h +++ b/Weave/Graphix/Model/Model.h @@ -1,86 +1,98 @@ -#pragma once - -#include "../../GLM.h" -#include -#include - -#include "../../Overlap.h" - -#include - -class Shader; -class Texture; -class Overlap; -struct aiMesh; - -typedef unsigned int uint; - -class Model -{ -public: - - /* 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 mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const; - - /* Get min&max from BBox */ -// virtual void getBBmm(vec3& min, vec3& max) const; - /* Get size&position from BBox */ - void getBBcs(vec3& center, vec3& size) const; - - virtual void setMargin(btScalar margin); - - static Model* getBBoxModel(); - static Model* getSkyBoxModel(); - static Model* newIMetaModel(const std::string& modelpath,bool isConvex=true); - - static void deleteBBoxModel(); - static void deleteSkyBoxModel(); - static void deleteIMetaModel(const std::string& modelpath); - - virtual float getPDistHit(const vec3& P, const vec3& direction) const; - - virtual operator std::string() const = 0; - - virtual operator btCollisionShape*() const; - - // Mesh Speichern? - static bool import(const std::string& modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint mindex = 0); - static bool import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, const vec3& scale = vec3(1.f)); - -protected: - Model(); - virtual ~Model(); - - uint numvertices, numfaces; - uint vertexBuffer, indexBuffer, normalBuffer, uvBuffer; - - std::unordered_map shader_map; - - 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; - - static Model* BoundingBox; - static Model* SkyBoxModel; - static std::unordered_map IMetaModel; - static std::unordered_map IMetaModel_count; - - static vec3 rotateSize(const vec3& size, const mat4& modelMat); - static float directSize(const vec3& size, const vec3& direction); - - //Bullet - btCollisionShape* bt_collision_shape; - -private: - +#pragma once + +#include "../../GLM.h" +#include +#include + +#include "../../Overlap.h" + +#include + +class Shader; +class Texture; +class Overlap; +struct aiMesh; + +typedef unsigned int uint; + +class Model +{ +public: + + /* Binds Model to GL*/ + virtual void bindModel(); + + /* Binds Model to the Shader*/ + virtual void bindShader(Shader* shader); + + virtual void unbindModel(); + virtual void unbindShader(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 mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const; + + /* Get min&max from BBox */ +// virtual void getBBmm(vec3& min, vec3& max) const; + /* Get size&position from BBox */ + void getBBcs(vec3& center, vec3& size) const; + + virtual void setMargin(btScalar margin); + + static Model* getBBoxModel(); + static Model* getSkyBoxModel(); + static Model* newIMetaModel(const std::string& modelpath,bool isConvex=true); + + static void deleteBBoxModel(); + static void deleteSkyBoxModel(); + static void deleteIMetaModel(const std::string& modelpath); + + virtual float getPDistHit(const vec3& P, const vec3& direction) const; + + virtual operator std::string() const; + virtual std::string type2str() const = 0; + + virtual operator btCollisionShape*() const; + + // Mesh Speichern? + static bool loadMesh(const std::string& modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, std::string& name, uint mindex = 0); + static bool loadMesh(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, std::string& name, const vec3& scale = vec3(1.f)); + +protected: + Model(); + virtual ~Model(); + + std::string name=""; + + uint numvertices=0, numfaces=0; + uint vertexBuffer=-1, indexBuffer=-1, normalBuffer=-1, uvBuffer=-1; + + float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; + uint *index = nullptr; + + std::unordered_map shader_map; + + 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; + + static Model* BoundingBox; + static Model* SkyBoxModel; + static std::unordered_map IMetaModel; + static std::unordered_map IMetaModel_count; + + static vec3 rotateSize(const vec3& size, const mat4& modelMat); + static float directSize(const vec3& size, const vec3& direction); + + //Bullet + btCollisionShape* bt_collision_shape; + +private: + }; \ No newline at end of file diff --git a/Weave/Graphix/Model/SkyBox.cpp b/Weave/Graphix/Model/SkyBox.cpp index bfb62eb..4fdda6e 100644 --- a/Weave/Graphix/Model/SkyBox.cpp +++ b/Weave/Graphix/Model/SkyBox.cpp @@ -1,61 +1,58 @@ -#include "SkyBox.h" - -#include "GL/glew.h" -#include "../Graphix.h" -#include "../../GLM.h" -#include "../Shader.h" - - -SkyBox::SkyBox() -{ - - float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; - uint *index = nullptr; - - import("SkyBox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0); - - genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); - //genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); - genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); - genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); - - delete vertex, index, normals, uvs; -} - - -SkyBox::~SkyBox() -{ -} - -void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const -{ - //_shader->useShader(); - //GLint OldCullFaceMode; - //glGetIntegerv(GL_CULL_FACE_MODE, &OldCullFaceMode); - GLint OldDepthFuncMode; - glGetIntegerv(GL_DEPTH_FUNC, &OldDepthFuncMode); - //glCullFace(GL_FRONT); - glDepthFunc(GL_LEQUAL); - //glDisable(GL_DEPTH_TEST); - Model::drawModel(_shader, _texture, _modelMat); - //glEnable(GL_DEPTH_TEST); - //glCullFace(OldCullFaceMode); - glDepthFunc(OldDepthFuncMode); -} - -//void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const -//{ -//} - -//void SkyBox::useTexture(Texture* _texture, Shader* _shader) const -//{ -//} - -void SkyBox::drawBBox(const mat4& _modelMat, const vec4& _color) const -{ -} - -SkyBox::operator std::string() const -{ - return "SkyBox"; +#include "SkyBox.h" + +#include "GL/glew.h" +#include "../Graphix.h" +#include "../../GLM.h" +#include "../Shader.h" + + +SkyBox::SkyBox() +{ + + loadMesh("SkyBox.dae", numvertices, numfaces, vertex, uvs, normals, index, name, 0); + + name = "SkyBox"; + + delete normals; + + bindModel(); + +} + + +SkyBox::~SkyBox() +{ +} + +void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const +{ + //_shader->useShader(); + //GLint OldCullFaceMode; + //glGetIntegerv(GL_CULL_FACE_MODE, &OldCullFaceMode); + GLint OldDepthFuncMode; + glGetIntegerv(GL_DEPTH_FUNC, &OldDepthFuncMode); + //glCullFace(GL_FRONT); + glDepthFunc(GL_LEQUAL); + //glDisable(GL_DEPTH_TEST); + Model::drawModel(_shader, _texture, _modelMat); + //glEnable(GL_DEPTH_TEST); + //glCullFace(OldCullFaceMode); + glDepthFunc(OldDepthFuncMode); +} + +//void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const +//{ +//} + +//void SkyBox::useTexture(Texture* _texture, Shader* _shader) const +//{ +//} + +void SkyBox::drawBBox(const mat4& _modelMat, const vec4& _color) const +{ +} + +std::string SkyBox::type2str() const +{ + return "SkyBox"; } \ No newline at end of file diff --git a/Weave/Graphix/Model/SkyBox.h b/Weave/Graphix/Model/SkyBox.h index 7faa03e..099226d 100644 --- a/Weave/Graphix/Model/SkyBox.h +++ b/Weave/Graphix/Model/SkyBox.h @@ -1,23 +1,23 @@ -#pragma once - -#include "Model.h" -#include "../../GLM.h" - -class SkyBox : - public Model -{ -public: - SkyBox(); - ~SkyBox(); - - void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const override; - - //uncommend following lines to use default Loaders - //void useModelMat(const mat4& model, Shader* shader) const override; - //void useTexture(Texture* texture, Shader* shader) const override; - - void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.f)) const override; - - operator std::string() const override; - -}; +#pragma once + +#include "Model.h" +#include "../../GLM.h" + +class SkyBox : + public Model +{ +public: + SkyBox(); + ~SkyBox(); + + void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const override; + + //uncommend following lines to use default Loaders + //void useModelMat(const mat4& model, Shader* shader) const override; + //void useTexture(Texture* texture, Shader* shader) const override; + + void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.f)) const override; + + std::string type2str() const override; + +}; diff --git a/res/bulletMAKE/lib/Debug/BulletCollision_Debug.lib b/res/bulletMAKE/lib/Debug/BulletCollision_Debug.lib index ec1b9df..c40d829 100644 Binary files a/res/bulletMAKE/lib/Debug/BulletCollision_Debug.lib and b/res/bulletMAKE/lib/Debug/BulletCollision_Debug.lib differ diff --git a/res/bulletMAKE/lib/Debug/BulletDynamics_Debug.lib b/res/bulletMAKE/lib/Debug/BulletDynamics_Debug.lib index f35c1d7..f465fe5 100644 Binary files a/res/bulletMAKE/lib/Debug/BulletDynamics_Debug.lib and b/res/bulletMAKE/lib/Debug/BulletDynamics_Debug.lib differ diff --git a/res/bulletMAKE/lib/Debug/LinearMath_Debug.lib b/res/bulletMAKE/lib/Debug/LinearMath_Debug.lib index a1210d1..9472536 100644 Binary files a/res/bulletMAKE/lib/Debug/LinearMath_Debug.lib and b/res/bulletMAKE/lib/Debug/LinearMath_Debug.lib differ diff --git a/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.log b/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.log index 414df7f..063e1f8 100644 --- a/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.log +++ b/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.log @@ -1,108 +1,2 @@ - Building Custom Rule C:/Daten/Visual Studio 2015/Projects/CGUE2015_Weave/res/bullet3/src/BulletCollision/CMakeLists.txt - CMake does not need to re-run because C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\src\BulletCollision\CMakeFiles\generate.stamp is up-to-date. - btAxisSweep3.cpp - btBroadphaseProxy.cpp - btCollisionAlgorithm.cpp - btDbvt.cpp - btDbvtBroadphase.cpp - btDispatcher.cpp - btMultiSapBroadphase.cpp - btOverlappingPairCache.cpp - btQuantizedBvh.cpp - btSimpleBroadphase.cpp - btActivatingCollisionAlgorithm.cpp - btBoxBoxCollisionAlgorithm.cpp - btBox2dBox2dCollisionAlgorithm.cpp - btBoxBoxDetector.cpp - btCollisionDispatcher.cpp - btCollisionObject.cpp - btCollisionWorld.cpp - btCollisionWorldImporter.cpp - btCompoundCollisionAlgorithm.cpp - btCompoundCompoundCollisionAlgorithm.cpp - Generating Code... - Compiling... - btConvexConcaveCollisionAlgorithm.cpp - btConvexConvexAlgorithm.cpp - btConvexPlaneCollisionAlgorithm.cpp - btConvex2dConvex2dAlgorithm.cpp - btDefaultCollisionConfiguration.cpp - btEmptyCollisionAlgorithm.cpp - btGhostObject.cpp - btHashedSimplePairCache.cpp - btInternalEdgeUtility.cpp - btManifoldResult.cpp - btSimulationIslandManager.cpp - btSphereBoxCollisionAlgorithm.cpp - btSphereSphereCollisionAlgorithm.cpp - btSphereTriangleCollisionAlgorithm.cpp - btUnionFind.cpp - SphereTriangleDetector.cpp - btBoxShape.cpp - btBox2dShape.cpp - btBvhTriangleMeshShape.cpp - btCapsuleShape.cpp - Generating Code... - Compiling... - btCollisionShape.cpp - btCompoundShape.cpp - btConcaveShape.cpp - btConeShape.cpp - btConvexHullShape.cpp - btConvexInternalShape.cpp - btConvexPointCloudShape.cpp - btConvexPolyhedron.cpp - btConvexShape.cpp - btConvex2dShape.cpp - btConvexTriangleMeshShape.cpp - btCylinderShape.cpp - btEmptyShape.cpp - btHeightfieldTerrainShape.cpp - btMinkowskiSumShape.cpp - btMultimaterialTriangleMeshShape.cpp - btMultiSphereShape.cpp - btOptimizedBvh.cpp - btPolyhedralConvexShape.cpp - btScaledBvhTriangleMeshShape.cpp - Generating Code... - Compiling... - btShapeHull.cpp - btSphereShape.cpp - btStaticPlaneShape.cpp - btStridingMeshInterface.cpp - btTetrahedronShape.cpp - btTriangleBuffer.cpp - btTriangleCallback.cpp - btTriangleIndexVertexArray.cpp - btTriangleIndexVertexMaterialArray.cpp - btTriangleMesh.cpp - btTriangleMeshShape.cpp - btUniformScalingShape.cpp - btContactProcessing.cpp - btGenericPoolAllocator.cpp - btGImpactBvh.cpp - btGImpactCollisionAlgorithm.cpp - btGImpactQuantizedBvh.cpp - btGImpactShape.cpp - btTriangleShapeEx.cpp - gim_box_set.cpp - Generating Code... - Compiling... - gim_contact.cpp - gim_memory.cpp - gim_tri_collision.cpp - btContinuousConvexCollision.cpp - btConvexCast.cpp - btGjkConvexCast.cpp - btGjkEpa2.cpp - btGjkEpaPenetrationDepthSolver.cpp - btGjkPairDetector.cpp - btMinkowskiPenetrationDepthSolver.cpp - btPersistentManifold.cpp - btRaycastCallback.cpp - btSubSimplexConvexCast.cpp - btVoronoiSimplexSolver.cpp - btPolyhedralContactClipping.cpp - Generating Code... -btBroadphaseProxy.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library - BulletCollision.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\BulletCollision_Debug.lib +btBroadphaseProxy.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library + BulletCollision.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\BulletCollision_Debug.lib diff --git a/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.tlog/BulletCollision.lastbuildstate b/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.tlog/BulletCollision.lastbuildstate index ec0a265..3c9f8b1 100644 --- a/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.tlog/BulletCollision.lastbuildstate +++ b/res/bulletMAKE/src/BulletCollision/BulletCollision.dir/Debug/BulletCollision.tlog/BulletCollision.lastbuildstate @@ -1,2 +1,2 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 -Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\| +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 +Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\| diff --git a/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.log b/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.log index 5baa04d..fcde51d 100644 --- a/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.log +++ b/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.log @@ -1,50 +1 @@ - Building Custom Rule C:/Daten/Visual Studio 2015/Projects/CGUE2015_Weave/res/bullet3/src/BulletDynamics/CMakeLists.txt - CMake does not need to re-run because C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\src\BulletDynamics\CMakeFiles\generate.stamp is up-to-date. - btKinematicCharacterController.cpp - btConeTwistConstraint.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\ConstraintSolver\btConeTwistConstraint.cpp(868): warning C4244: '=': conversion from 'double' to 'btScalar', possible loss of data -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\ConstraintSolver\btConeTwistConstraint.cpp(913): warning C4244: '=': conversion from 'double' to 'float', possible loss of data -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\ConstraintSolver\btConeTwistConstraint.cpp(973): warning C4244: '=': conversion from 'double' to 'btScalar', possible loss of data -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\ConstraintSolver\btConeTwistConstraint.cpp(975): warning C4244: '=': conversion from 'double' to 'btScalar', possible loss of data - btContactConstraint.cpp -c:\daten\visual studio 2015\projects\cgue2015_weave\res\bullet3\src\bulletdynamics\constraintsolver\btContactConstraint.h(25): warning C4359: 'btContactConstraint': Alignment specifier is less than actual alignment (128), and will be ignored. - btFixedConstraint.cpp - btGearConstraint.cpp - btGeneric6DofConstraint.cpp - btGeneric6DofSpringConstraint.cpp - btGeneric6DofSpring2Constraint.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\ConstraintSolver\btGeneric6DofSpring2Constraint.cpp(786): warning C4244: 'initializing': conversion from 'double' to 'btScalar', possible loss of data - btHinge2Constraint.cpp - btHingeConstraint.cpp - btPoint2PointConstraint.cpp - btSequentialImpulseConstraintSolver.cpp - btNNCGConstraintSolver.cpp - btSliderConstraint.cpp - btSolve2LinearConstraint.cpp - btTypedConstraint.cpp - btUniversalConstraint.cpp - btDiscreteDynamicsWorld.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics/ConstraintSolver/btContactConstraint.h(25): warning C4359: 'btContactConstraint': Alignment specifier is less than actual alignment (128), and will be ignored. - btRigidBody.cpp - btSimpleDynamicsWorld.cpp - Generating Code... - Compiling... - btRaycastVehicle.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics/ConstraintSolver/btContactConstraint.h(25): warning C4359: 'btContactConstraint': Alignment specifier is less than actual alignment (128), and will be ignored. - btWheelInfo.cpp - btMultiBody.cpp - btMultiBodyConstraintSolver.cpp - btMultiBodyDynamicsWorld.cpp - btMultiBodyJointLimitConstraint.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\Featherstone\btMultiBodyJointLimitConstraint.cpp(114): warning C4244: 'initializing': conversion from 'int' to 'btScalar', possible loss of data - btMultiBodyConstraint.cpp - btMultiBodyPoint2Point.cpp - btMultiBodyJointMotor.cpp - btDantzigLCP.cpp -C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\MLCPSolvers\btDantzigLCP.cpp(1568): warning C4473: 'printf' : not enough arguments passed for format string - C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\MLCPSolvers\btDantzigLCP.cpp(1568): note: placeholders and their parameters expect 2 variadic arguments, but 1 were provided - C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bullet3\src\BulletDynamics\MLCPSolvers\btDantzigLCP.cpp(1568): note: the missing variadic argument 2 is required by format string '% s' - btMLCPSolver.cpp - btLemkeAlgorithm.cpp - Generating Code... - BulletDynamics.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\BulletDynamics_Debug.lib + BulletDynamics.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\BulletDynamics_Debug.lib diff --git a/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.tlog/BulletDynamics.lastbuildstate b/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.tlog/BulletDynamics.lastbuildstate index ec0a265..3c9f8b1 100644 --- a/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.tlog/BulletDynamics.lastbuildstate +++ b/res/bulletMAKE/src/BulletDynamics/BulletDynamics.dir/Debug/BulletDynamics.tlog/BulletDynamics.lastbuildstate @@ -1,2 +1,2 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 -Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\| +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 +Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\| diff --git a/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.log b/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.log index ed2e0fe..dd98d9f 100644 --- a/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.log +++ b/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.log @@ -1,12 +1 @@ - Building Custom Rule C:/Daten/Visual Studio 2015/Projects/CGUE2015_Weave/res/bullet3/src/LinearMath/CMakeLists.txt - CMake does not need to re-run because C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\src\LinearMath\CMakeFiles\generate.stamp is up-to-date. - btAlignedAllocator.cpp - btConvexHull.cpp - btConvexHullComputer.cpp - btGeometryUtil.cpp - btPolarDecomposition.cpp - btQuickprof.cpp - btSerializer.cpp - btVector3.cpp - Generating Code... - LinearMath.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\LinearMath_Debug.lib + LinearMath.vcxproj -> C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\res\bulletMAKE\lib\Debug\LinearMath_Debug.lib diff --git a/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.tlog/LinearMath.lastbuildstate b/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.tlog/LinearMath.lastbuildstate index ec0a265..3c9f8b1 100644 --- a/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.tlog/LinearMath.lastbuildstate +++ b/res/bulletMAKE/src/LinearMath/LinearMath.dir/Debug/LinearMath.tlog/LinearMath.lastbuildstate @@ -1,2 +1,2 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 -Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\| +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 +Debug|Win32|C:\Daten\Visual Studio 2015\Projects\CGUE2015_Weave\|