[Orxonox-commit 1577] r6295 - in code/branches/presentation2/src: modules/weapons/projectiles orxonox/controllers orxonox/worldentities orxonox/worldentities/pawns

wirthmi at orxonox.net wirthmi at orxonox.net
Wed Dec 9 16:54:20 CET 2009


Author: wirthmi
Date: 2009-12-09 16:54:20 +0100 (Wed, 09 Dec 2009)
New Revision: 6295

Modified:
   code/branches/presentation2/src/modules/weapons/projectiles/Projectile.cc
   code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
   code/branches/presentation2/src/orxonox/controllers/Controller.h
   code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
   code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
   code/branches/presentation2/src/orxonox/worldentities/MovableEntity.cc
   code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
   code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h
Log:
Changed a function call when hit from damage() to hit(). Pass through to controller

Modified: code/branches/presentation2/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Projectile.cc	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Projectile.cc	2009-12-09 15:54:20 UTC (rev 6295)
@@ -128,7 +128,7 @@
 
             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
             if (victim)
-                victim->damage(dmg, this->owner_);
+                victim->hit(this->owner_, contactPoint, dmg);
         }
         return false;
     }

Modified: code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc	2009-12-09 15:54:20 UTC (rev 6295)
@@ -202,7 +202,7 @@
 
             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
             if (victim)
-                victim->damage(dmg, this->owner_);
+                victim->hit(this->owner_, contactPoint, dmg);
 //             this->destroy();
         }
         return false;

Modified: code/branches/presentation2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-12-09 15:54:20 UTC (rev 6295)
@@ -49,6 +49,8 @@
             inline PlayerInfo* getPlayer() const
                 { return this->player_; }
 
+            virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
+
             inline ControllableEntity* getControllableEntity() const
                 { return this->controllableEntity_; }
             virtual void changedControllableEntity() {}

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-12-09 15:54:20 UTC (rev 6295)
@@ -43,6 +43,8 @@
 #include "graphics/Camera.h"
 #include "sound/SoundManager.h"
 #include "Scene.h"
+#include "tools/BulletConversions.h"
+#include "bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
 
 namespace orxonox
 {
@@ -247,6 +249,17 @@
 
     }
 
+    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {
+        Vector3 posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
+        //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
+        //posA and posB are almost identical
+
+        Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation() * (posA - this->getControllableEntity()->getPosition());
+
+        COUT(0) << relativeHit << endl;
+        //COUT(0) << "Damage: " << damage << " Point A: " << posA << " Point B: " << posB << endl;
+    }
+
     void NewHumanController::unfire()
     {
         if (NewHumanController::localController_s)

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-12-09 15:54:20 UTC (rev 6295)
@@ -55,6 +55,8 @@
 
             virtual void doFire(unsigned int firemode);
 
+            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
+
             static void unfire();
             virtual void doUnfire();
 

Modified: code/branches/presentation2/src/orxonox/worldentities/MovableEntity.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/MovableEntity.cc	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/worldentities/MovableEntity.cc	2009-12-09 15:54:20 UTC (rev 6295)
@@ -78,7 +78,8 @@
             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
             if (victim)
             {
-                victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
+                float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
+                victim->hit(0, contactPoint, damage);
             }
         }
 

Modified: code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc	2009-12-09 15:54:20 UTC (rev 6295)
@@ -37,6 +37,7 @@
 
 #include "PawnManager.h"
 #include "infos/PlayerInfo.h"
+#include "controllers/Controller.h"
 #include "gametypes/Gametype.h"
 #include "graphics/ParticleSpawner.h"
 #include "worldentities/ExplosionChunk.h"
@@ -175,6 +176,19 @@
         }
     }
 
+    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
+    {
+        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
+        {
+            this->damage(damage, originator);
+
+            if ( this->getController() )
+                this->getController()->hit(originator, contactpoint, damage);
+
+            // play hit effect
+        }
+    }
+
     void Pawn::kill()
     {
         this->damage(this->health_);

Modified: code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h	2009-12-09 15:32:43 UTC (rev 6294)
+++ code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h	2009-12-09 15:54:20 UTC (rev 6295)
@@ -74,8 +74,8 @@
             inline ControllableEntity* getLastHitOriginator() const
                 { return this->lastHitOriginator_; }
 
-            virtual void damage(float damage, Pawn* originator = 0);
             virtual void hit(Pawn* originator, const Vector3& force, float damage);
+            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
             virtual void kill();
 
             virtual void fired(unsigned int firemode);
@@ -130,6 +130,8 @@
             virtual void deatheffect();
             virtual void spawneffect();
 
+            virtual void damage(float damage, Pawn* originator = 0);
+
             bool bAlive_;
 
             PickupCollection pickups_;




More information about the Orxonox-commit mailing list