From: Peter Schaefer Date: Tue, 28 Jun 2016 02:20:21 +0000 (+0200) Subject: Springen auf Schwein tötet es X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=897d83f41a54766bf2d2f592b7dda55c72c0577a;p=cgue_weave.git Springen auf Schwein tötet es --- diff --git a/Weave/Graphix/Textures/Texture.h b/Weave/Graphix/Textures/Texture.h index a3fc735..f603aca 100644 --- a/Weave/Graphix/Textures/Texture.h +++ b/Weave/Graphix/Textures/Texture.h @@ -44,6 +44,7 @@ enum mmTarget { class Texture { public: + //Material: (ambient, point, directional, glossyness) static Texture* newTImage(const std::string& path, const vec4& material); static void deleteTImage(const unsigned int handle); diff --git a/Weave/Graphix/Textures/tImage.h b/Weave/Graphix/Textures/tImage.h index 2eade55..4d6a14b 100644 --- a/Weave/Graphix/Textures/tImage.h +++ b/Weave/Graphix/Textures/tImage.h @@ -23,6 +23,7 @@ public: protected: void loadImage(const std::string& path); + //(ambient, point, directional, glossyness) vec4 material; std::string path; diff --git a/Weave/Scene/Boar.cpp b/Weave/Scene/Boar.cpp index 01e557a..79a091d 100644 --- a/Weave/Scene/Boar.cpp +++ b/Weave/Scene/Boar.cpp @@ -42,7 +42,7 @@ void Boar::collides(SceneObject * _other, btPersistentManifold * _contactManifol int numContacts = _contactManifold->getNumContacts(); //For each contact point in that manifold - double pdist = (_contactManifold->getContactPoint(0).getDistance()); + float pdist = (_contactManifold->getContactPoint(0).getDistance()); btVector3 ptN = (_contactManifold->getContactPoint(0).m_normalWorldOnB);; for (int j = 0; j < numContacts; j++) { //Get the contact information @@ -53,18 +53,29 @@ void Boar::collides(SceneObject * _other, btPersistentManifold * _contactManifol pdist = pt.getDistance(); ptN = pt.m_normalWorldOnB; } - + } - if (ptN.getY() >= .4f) + vec3 normal = vec3(ptN.getX(), ptN.getY(), ptN.getZ()); + + if (normal[1] >= .4f && pdist > -1) { _other->ySpeed = 5; //BOAR DIE!!! - return; + alive = false; + + _other->move(-pdist * (float).5 * vec3(0.f, normal[1], 0.f)); + } + + + if (normal[1] <= .3f && pdist<0 && pdist > -1) + { + _other->move(-pdist * (float).5 * vec3(normal[0], 0.f, normal[2])); + _other->move_delta = 0; } - if (pdist >= .0f) + if (pdist >= .0f || !alive) return; Message::info("Spiel Verloren!->" + std::to_string(pdist)); diff --git a/Weave/Scene/Boar.h b/Weave/Scene/Boar.h index 413bb3f..5708c81 100644 --- a/Weave/Scene/Boar.h +++ b/Weave/Scene/Boar.h @@ -17,5 +17,7 @@ public: protected: bool activated = false; bool nextFrame = true; + + bool alive = true; }; diff --git a/Weave/Scene/SceneObject.cpp b/Weave/Scene/SceneObject.cpp index 656c828..7347d7e 100644 --- a/Weave/Scene/SceneObject.cpp +++ b/Weave/Scene/SceneObject.cpp @@ -27,7 +27,7 @@ static inline bool file_exist(const std::string& name) { return (stat(name.c_str(), &buffer) == 0); } - +//Material: (ambient, point, directional, glossyness) SceneObject::SceneObject(const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath) : model(nullptr), collision(nullptr),