From: Peter Schaefer Date: Thu, 23 Apr 2015 20:23:36 +0000 (+0200) Subject: jumping Activated (fun Version) X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=7b2ad070937ef7aeeed869ae13b42ce5b7f8e134;p=cgue_weave.git jumping Activated (fun Version) --- diff --git a/Weave/Game.cpp b/Weave/Game.cpp index ae0a980..f7fd43d 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -60,10 +60,12 @@ Game::Game() : playing(true) // load LVL tmp_Scene->addObject(new SceneObject(shader1, scale(3.f * vec3(1.f,.3f,1.f)), "level_test.dae", "sample_2D.png")); - tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(0.f,2.f,0.f)), new BBox() , "")); + tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(-3.f,1.f,0.f)), new BBox() , "")); //Player - SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "Player.dae", "model_player_2D.png"); + SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 3.f, 1.f))*rotate((float)M_PI_4,vec3(0.f,1.f,0.f)), "Player.dae", "model_player_2D.png"); + + tmp_playerObject->yStatic= false; //tmp_playerObject->setIntelligenz(new PlayerI(tmp_playerObject)); tmp_Scene->addObject(tmp_playerObject); @@ -101,7 +103,7 @@ Game::Game() : playing(true) //ein Gegner //tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "Player.dae", "model_player.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")); + tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f))*scale(vec3(3.f)), "cow/cow.dae", "model_cow.jpg")); //import("level_test.dae", tmp_Scene, shader1); diff --git a/Weave/Graphix/Model/BBox.cpp b/Weave/Graphix/Model/BBox.cpp index 1f44341..27ca798 100644 --- a/Weave/Graphix/Model/BBox.cpp +++ b/Weave/Graphix/Model/BBox.cpp @@ -14,7 +14,7 @@ BBox::BBox() //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); +// genBuffer(indexBuffer, 4 * sizeof(float), (void*)indexL1); } @@ -25,9 +25,9 @@ BBox::~BBox() void BBox::drawModel() const { - 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); + //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); } \ No newline at end of file diff --git a/Weave/Graphix/Scene.cpp b/Weave/Graphix/Scene.cpp index 684301a..16d497f 100644 --- a/Weave/Graphix/Scene.cpp +++ b/Weave/Graphix/Scene.cpp @@ -91,6 +91,10 @@ void Scene::update(float deltaT) // XYAchse um den Player viewPort->rotateView(0.002f*Events::getViewX(), 0.001f*Events::getViewY()); + //Jump + if (Events::getJump()) + lookat->ySpeed = 20; + // MOVE Player if (move_x) lookat->move(SPEED_MOVE_NORMAL *move_x * deltaT * viewPort->rotateDirection(vec3(-1.f, 0.f, 0.f))); diff --git a/Weave/Graphix/SceneObject.cpp b/Weave/Graphix/SceneObject.cpp index 7f153ef..57136de 100644 --- a/Weave/Graphix/SceneObject.cpp +++ b/Weave/Graphix/SceneObject.cpp @@ -23,13 +23,18 @@ using std::string; using std::cout; using std::endl; + +#define YFALL_SPEED 9.f + SceneObject::SceneObject(Shader* _shader, mat4& _modelMat, string _modelpath, string texturepath, unsigned int _model_index) : model(new IMetaMesh(_modelpath)), modelMat(_modelMat), shader(_shader), mainScene(NULL), collision_ignore(false), -texture(nullptr) +texture(nullptr), +ySpeed(0), +yStatic(true) { //Message::info("Error from befor?"); //Graphix::getGlError(); @@ -55,7 +60,9 @@ modelMat(_modelMat), shader(_shader), mainScene(NULL), collision_ignore(false), -texture(nullptr) +texture(nullptr), +ySpeed(0), +yStatic(true) { //Message::info("Error from befor?"); //Graphix::getGlError(); @@ -99,7 +106,17 @@ SceneObject::~SceneObject() void SceneObject::update(float deltaT) { + if (!yStatic) + { + vec3 pos = getPosition(); + if (pos.y > 0 || ySpeed>0) //Aktuelle Bodenhöhe + { + modelMat = translate(vec3(0.f, ySpeed*deltaT, 0.f))*modelMat; + ySpeed -= deltaT*YFALL_SPEED; + } + } + //modelMat = scale(modelMat, vec3(matter)); //modelMat = (deltaT * spin) * modelMat; //TODO drehen scheint nicht zu funktionieren diff --git a/Weave/Graphix/SceneObject.h b/Weave/Graphix/SceneObject.h index e5e635a..97e5ca6 100644 --- a/Weave/Graphix/SceneObject.h +++ b/Weave/Graphix/SceneObject.h @@ -55,11 +55,16 @@ public: __declspec(deprecated) bool isEnemy(); + bool yStatic; + float ySpeed; + protected: void setMatter(float); mat4 modelMat; + + //__declspec(deprecated) //unsigned int modelID; diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index 4598411..d8d1e1e 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -20,7 +20,7 @@ ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsign view_dist(2), view(0.f) { - rotateView(0.f, 0.f); + rotateView(0.f, -.5f); }