--- /dev/null
+[InternetShortcut]
+URL=https://docs.google.com/document/d/1IToA-KICWkIglNEMleaZterh_N8ba_tgm9U4LT10-sE/edit
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);
// //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);
+
}
}
-bool Game::import(const string& path, Scene* scene, Shader* shader)
+bool import(const string& path, Scene* scene, Shader* shader)
{
Assimp::Importer importer;
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
void update(float);
void draw() const;
- bool import(const string &path, Scene *scene, Shader* shader);
+ //bool import(const string &path, Scene *scene, Shader* shader);
};
#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;
typedef unsigned int uint;
-Model::Model(const string& _modelpath) :
+Model::Model(const string& _modelpath, unsigned int _mindex) :
numfaces(-1),
numvertices(-1),
vertexBuffer(-1),
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);
-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;
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];
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();
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);
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),
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();