]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
Springen auf Schwein tötet es
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 28 Jun 2016 02:20:21 +0000 (04:20 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 28 Jun 2016 02:20:21 +0000 (04:20 +0200)
Weave/Graphix/Textures/Texture.h
Weave/Graphix/Textures/tImage.h
Weave/Scene/Boar.cpp
Weave/Scene/Boar.h
Weave/Scene/SceneObject.cpp

index a3fc7351ea9e206cd0cafdd0b94649985891ce11..f603aca969bb90a3cde4dd7c4a18f004467c4f01 100644 (file)
@@ -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);
 
index 2eade550672ebd2c6f0599163d379d1e56604245..4d6a14b20045745c7d36c549b7d27b565a78fab4 100644 (file)
@@ -23,6 +23,7 @@ public:
 protected:
        void loadImage(const std::string& path);
 
+       //(ambient, point, directional, glossyness)
        vec4 material;
 
        std::string path;
index 01e557a7d1cd3604f426a1f2c956c6a276359236..79a091d3ac87e6d710a16cbd5aba146823a8f27e 100644 (file)
@@ -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));
index 413bb3f593b1780b886de9648db67f674eb6202e..5708c8130376a13ea7a5a0fe7e79eb39a2044f77 100644 (file)
@@ -17,5 +17,7 @@ public:
 protected:
        bool activated = false;
        bool nextFrame = true;
+
+       bool alive = true;
 };
 
index 656c828a3c109b6e9086d921c07cb2e0ccea707d..7347d7edcaa25bf7dc6c123aa572697c60203c7d 100644 (file)
@@ -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),