From: Peter Schaefer Date: Tue, 14 Apr 2015 07:42:26 +0000 (+0200) Subject: created link for TODO.FILE X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=5a86434f7a7e41a8a21fa8b2e72a4de089966e1c;p=cgue_weave.git created link for TODO.FILE updated model,Scene for multiDAE access --- diff --git a/Weave - Todo.url b/Weave - Todo.url new file mode 100644 index 0000000..7243ab0 --- /dev/null +++ b/Weave - Todo.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://docs.google.com/document/d/1IToA-KICWkIglNEMleaZterh_N8ba_tgm9U4LT10-sE/edit diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 6f6bc1e..625d768 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -46,7 +46,7 @@ Game::Game() : playing(true) Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); //Player - SceneObject* tmp_playerObject = new SceneObject(shader1, glm::mat4(1.0f), "duck.dae", "model_duck.png"); + SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "cow/cow.dae", "model_cow.jpg"); //tmp_playerObject->setIntelligenz(new PlayerI(tmp_playerObject)); tmp_Scene->addObject(tmp_playerObject); @@ -82,10 +82,15 @@ Game::Game() : playing(true) // //cout << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << endl; //} //ein Gegner - tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "cow/cow.dae", "model_cow.jpg")); +// tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "duck.dae", "model_duck.png")); //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(-1.f, 2.f, -2.f)), "../models/box/box.dae", "../Textures/sky_withstars.png")); //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(1.f, 3.f, -2.f)), "../models/cow/cow.dae", "../models/cow/texture.jpg")); + + // load LVL + tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "level_test.dae", "model_duck.png")); + //import("level_test.dae", tmp_Scene, shader1); + } @@ -173,7 +178,7 @@ void Game::draw() const } -bool Game::import(const string& path, Scene* scene, Shader* shader) +bool import(const string& path, Scene* scene, Shader* shader) { Assimp::Importer importer; @@ -234,7 +239,8 @@ bool Game::import(const string& path, Scene* scene, Shader* shader) delete vertex, normals, uvs, index; //TODO enable different textures - scene->addObject(new SceneObject(shader, translate(vec3(1.f, 0.f, 1.f)), model, "model_cow.jpg")); //file->mRootNode->mChildren[n]->mTransformation.a1 ... d4 + scene->addObject(new SceneObject(shader, translate(vec3(1.f, 0.f, 1.f)), model, "model_cow.jpg")); + //file->mRootNode->mChildren[n]->mTransformation.a1 ... d4 } } else diff --git a/Weave/Game.h b/Weave/Game.h index b024fc6..732ad76 100644 --- a/Weave/Game.h +++ b/Weave/Game.h @@ -36,7 +36,7 @@ private: void update(float); void draw() const; - bool import(const string &path, Scene *scene, Shader* shader); + //bool import(const string &path, Scene *scene, Shader* shader); }; diff --git a/Weave/Graphix/GLM.h b/Weave/Graphix/GLM.h index 1bbaacf..94e6895 100644 --- a/Weave/Graphix/GLM.h +++ b/Weave/Graphix/GLM.h @@ -2,7 +2,7 @@ #include "glm\glm.hpp" #include "glm\gtx\transform.hpp" -#include "glm\gtc\type_ptr.hpp"" +#include "glm\gtc\type_ptr.hpp" #include "glm\gtx\rotate_vector.hpp" using glm::vec3; diff --git a/Weave/Graphix/Model.cpp b/Weave/Graphix/Model.cpp index 4df9478..6110fba 100644 --- a/Weave/Graphix/Model.cpp +++ b/Weave/Graphix/Model.cpp @@ -11,7 +11,7 @@ typedef unsigned int uint; -Model::Model(const string& _modelpath) : +Model::Model(const string& _modelpath, unsigned int _mindex) : numfaces(-1), numvertices(-1), vertexBuffer(-1), @@ -23,7 +23,7 @@ Model::Model(const string& _modelpath) : float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; uint *index = nullptr; - import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index); + import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex); genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); @@ -145,7 +145,7 @@ void Model::bindBuffer(const uint &buffer,const uint index,const uint dim) -bool Model::import(const string& path,uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index) +bool Model::import(const string& path,uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint mindex) { Assimp::Importer importer; @@ -156,9 +156,9 @@ bool Model::import(const string& path,uint& numvertices, uint& numfaces, float*& return false; } - if (scene->HasMeshes()) + if (scene->HasMeshes() && scene->mNumMeshes > mindex) { - aiMesh* mesh = scene->mMeshes[0]; + aiMesh* mesh = scene->mMeshes[mindex]; numvertices = mesh->mNumVertices; numfaces = mesh->mNumFaces; vertex = new float[numvertices * 3]; diff --git a/Weave/Graphix/Model.h b/Weave/Graphix/Model.h index bc6f188..7786709 100644 --- a/Weave/Graphix/Model.h +++ b/Weave/Graphix/Model.h @@ -14,7 +14,7 @@ class Shader; class Model { public: - Model(const string& modelpath); + Model(const string& modelpath, unsigned int index=0); Model(unsigned int numvertices, unsigned int numfaces, float *vertex, float *uvs, float *normals, unsigned int *index); virtual ~Model(); @@ -30,7 +30,7 @@ private: int2int_map shader_map; - bool import(const string& path, unsigned int& numvertices, unsigned int& numfaces, float*& vertex, float*& uvs, float*& normals, unsigned int*& index); + bool import(const string& path, unsigned int& numvertices, unsigned int& numfaces, float*& vertex, float*& uvs, float*& normals, unsigned int*& index, unsigned int mindex=0); void genBuffer(unsigned int &buffer, unsigned int size, void* value); void bindBuffer(const unsigned int &buffer, const unsigned int index,const unsigned int dim = 3); diff --git a/Weave/Graphix/SceneObject.cpp b/Weave/Graphix/SceneObject.cpp index eb13c78..d8526c8 100644 --- a/Weave/Graphix/SceneObject.cpp +++ b/Weave/Graphix/SceneObject.cpp @@ -21,8 +21,8 @@ using std::string; using std::cout; using std::endl; -SceneObject::SceneObject(Shader* _shader, mat4& _model, string _modelpath, string texturepath) : -Model(_modelpath), +SceneObject::SceneObject(Shader* _shader, mat4& _model, string _modelpath, string texturepath, unsigned int _model_index) : +Model(_modelpath, _model_index), model(_model), shader(_shader), mainScene(NULL), diff --git a/Weave/Graphix/SceneObject.h b/Weave/Graphix/SceneObject.h index 5a93c49..ea431f3 100644 --- a/Weave/Graphix/SceneObject.h +++ b/Weave/Graphix/SceneObject.h @@ -22,7 +22,7 @@ class SceneObject : public: //SceneObject(Shader* _shader, mat4& model); - SceneObject(Shader* _shader, mat4& model, string modelpath, string texturepath); + SceneObject(Shader* _shader, mat4& model, string modelpath, string texturepath, unsigned int model_index=0); SceneObject(Shader* _shader, mat4& model, Model* model_obj, string texturepath); virtual ~SceneObject();