]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
created link for TODO.FILE
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 14 Apr 2015 07:42:26 +0000 (09:42 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 14 Apr 2015 07:42:26 +0000 (09:42 +0200)
updated model,Scene for multiDAE access

Weave - Todo.url [new file with mode: 0644]
Weave/Game.cpp
Weave/Game.h
Weave/Graphix/GLM.h
Weave/Graphix/Model.cpp
Weave/Graphix/Model.h
Weave/Graphix/SceneObject.cpp
Weave/Graphix/SceneObject.h

diff --git a/Weave - Todo.url b/Weave - Todo.url
new file mode 100644 (file)
index 0000000..7243ab0
--- /dev/null
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://docs.google.com/document/d/1IToA-KICWkIglNEMleaZterh_N8ba_tgm9U4LT10-sE/edit
index 6f6bc1e3a27f7b211576b8fc509fe40248785c42..625d768ba544885ef563c23c25e0d65e9ff5b74f 100644 (file)
@@ -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
index b024fc6a53f2166a3c6c0332b2e328ee2e4b5210..732ad768409c523eb503eac4a9ee64d87580866b 100644 (file)
@@ -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);
 
 };
 
index 1bbaacfb9f0f848cb1315be42308b8690fce6e65..94e6895135a16283f9460552c472af224b13f7b5 100644 (file)
@@ -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;
index 4df9478e3ff092e5e3c15f0187c1395ede769787..6110fbaeffeec7b734e21ec19b0a7ae066151613 100644 (file)
@@ -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];
index bc6f188c57749ad75c84862fff6229a189bf43f0..778670919107111e299bc6de327c58294e7b3553 100644 (file)
@@ -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);
        
index eb13c789ec3aaafc3ddb1aaafa8f44376e5e5801..d8526c8c2e5f843e684cd0af14eff65a3e699e87 100644 (file)
@@ -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),
index 5a93c4935856edeed8d1022272b7c0aa1b763f99..ea431f3d6c5e24eb2677bff2e14837c228d70621 100644 (file)
@@ -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();