[Orxonox-commit 1327] r6045 - in code/branches/steering/src: modules/weapons/weaponmodes orxonox/controllers orxonox/infos orxonox/weaponsystem orxonox/worldentities

wirthmi at orxonox.net wirthmi at orxonox.net
Wed Nov 11 17:39:54 CET 2009


Author: wirthmi
Date: 2009-11-11 17:39:53 +0100 (Wed, 11 Nov 2009)
New Revision: 6045

Modified:
   code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc
   code/branches/steering/src/orxonox/controllers/Controller.cc
   code/branches/steering/src/orxonox/controllers/Controller.h
   code/branches/steering/src/orxonox/controllers/NewHumanController.cc
   code/branches/steering/src/orxonox/controllers/NewHumanController.h
   code/branches/steering/src/orxonox/infos/PlayerInfo.cc
   code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h
   code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc
   code/branches/steering/src/orxonox/worldentities/ControllableEntity.h
Log:
First implementation of direction shooting.


Modified: code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/modules/weapons/weaponmodes/HsW01.cc	2009-11-11 16:39:53 UTC (rev 6045)
@@ -38,6 +38,7 @@
 #include "weaponsystem/Weapon.h"
 #include "weaponsystem/WeaponPack.h"
 #include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
 
 namespace orxonox
 {
@@ -109,9 +110,11 @@
         projectile->attach(model);
         model->setScale(5);
 
-        projectile->setOrientation(this->getMuzzleOrientation());
+        //projectile->setOrientation(this->getMuzzleOrientation());
+        projectile->lookAt(this->getTarget(), WorldEntity::World);
         projectile->setPosition(this->getMuzzlePosition());
-        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+        projectile->setVelocity((projectile->getOrientation() * Vector3::UNIT_Z) * this->speed_); //getWorldOrientation??
+        //projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
 
         projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
         projectile->setDamage(this->getDamage());

Modified: code/branches/steering/src/orxonox/controllers/Controller.cc
===================================================================
--- code/branches/steering/src/orxonox/controllers/Controller.cc	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/controllers/Controller.cc	2009-11-11 16:39:53 UTC (rev 6045)
@@ -28,6 +28,7 @@
 
 #include "Controller.h"
 #include "core/CoreIncludes.h"
+#include "worldentities/ControllableEntity.h"
 
 namespace orxonox
 {
@@ -44,4 +45,8 @@
     Controller::~Controller()
     {
     }
+
+    Vector3 Controller::getTarget() {
+        return this->controllableEntity_->getPosition() + (this->controllableEntity_->getOrientation() * Vector3::UNIT_Z);
+    }
 }

Modified: code/branches/steering/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/steering/src/orxonox/controllers/Controller.h	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/controllers/Controller.h	2009-11-11 16:39:53 UTC (rev 6045)
@@ -57,6 +57,8 @@
                 { return this->controllableEntity_; }
             virtual void changedControllableEntity() {}
 
+            virtual Vector3 getTarget();
+
         protected:
             PlayerInfo* player_;
             ControllableEntity* controllableEntity_;

Modified: code/branches/steering/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/steering/src/orxonox/controllers/NewHumanController.cc	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/controllers/NewHumanController.cc	2009-11-11 16:39:53 UTC (rev 6045)
@@ -56,6 +56,8 @@
 
         overlaySize = 0.08;
 
+        controlMode = 0;
+
         CrossHairOverlay = new OrxonoxOverlay(this);
         CrossHairOverlay->setBackgroundMaterial("Orxonox/Crosshair3");
         CrossHairOverlay->setSize(Vector2(overlaySize,overlaySize));
@@ -109,44 +111,58 @@
  }
 */
 
+            HumanController::localController_s->getControllableEntity()->fire(firemode);
+        //}
+//}
+    }
+
+    Vector3 NewHumanController::getTarget() {
             Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
 
-std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << "  Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl;
+//std::cout << "X: " << static_cast<float>(this->currentYaw_)/2*-1+.5 << "  Y: " << static_cast<float>(this->currentPitch_)/2*-1+.5 << endl;
 
             Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5, static_cast<float>(this->currentPitch_)/2*-1+.5);
 
             rsq->setRay(mouseRay);
             rsq->setSortByDistance(true);
 
+/*
+Distance of objects:
+ignore everything under 200 maybe even take 1000 as min distance to shoot at
 
+shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
+they vanish only after a distance of 10'000
+*/
+
+
             Ogre::RaySceneQueryResult &result = rsq->execute();
 
             Ogre::RaySceneQueryResult::iterator itr;
-for ( itr = result.begin(); itr != result.end(); itr++ )
- {
-     std::cout << "distance: " << itr->distance << "  name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType() << endl;
-if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity") {
-std::cout << " in scene" << endl;
-	itr->movable->getParentSceneNode()->showBoundingBox(true);
-}
- }
+            for ( itr = result.begin(); itr != result.end(); itr++ )
+            {
+                //std::cout << "distance: " << itr->distance << "  name: " << itr->movable->getName() << " type: " << itr->movable->getMovableType();
+                if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500) {
+                    //std::cout << "  TAGGED";
+                    itr->movable->getParentSceneNode()->showBoundingBox(true);
+std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;
+return itr->movable->getParentSceneNode()->_getDerivedPosition();
+                }
+                //std::cout << endl;
+            }
 
 //if (result.front().movable->isInScene()) std::cout << "in scene" << endl;
 // && result.front().movable->getParentSceneNode() != NULL) result.front().movable->getParentSceneNode()->showBoundingBox(true);
 //result.front().movable->setVisible(false);
 
-std::cout << endl;
+            //std::cout << endl;
 /*
             if (!result.empty()) {
             	Ogre::RaySceneQueryResultEntry obj = result.front();
             	std::cout << "distance: " << obj.distance << "  name: " << obj.movable->getName() << endl;
             }
 */
-
-
-            HumanController::localController_s->getControllableEntity()->fire(firemode);
-        //}
-//}
+        return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z);
+//return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
     }
 
     void NewHumanController::yaw(const Vector2& value)

Modified: code/branches/steering/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/steering/src/orxonox/controllers/NewHumanController.h	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/controllers/NewHumanController.h	2009-11-11 16:39:53 UTC (rev 6045)
@@ -44,17 +44,22 @@
             virtual ~NewHumanController();
 
             virtual void tick(float dt);
-            
+
             virtual void yaw(const Vector2& value);
             virtual void pitch(const Vector2& value);
 
             virtual void doFire(unsigned int firemode);
 
+            void changeMode(unsigned int controleMode);
+
+            virtual Vector3 getTarget();
+
         private:
             float                       currentYaw_;
             float                       currentPitch_;
             OrxonoxOverlay              *CrossHairOverlay;
             float			overlaySize;
+            unsigned int                controlMode;
     };
 }
 

Modified: code/branches/steering/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/steering/src/orxonox/infos/PlayerInfo.cc	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/infos/PlayerInfo.cc	2009-11-11 16:39:53 UTC (rev 6045)
@@ -137,8 +137,10 @@
         this->controller_ = this->defaultController_.fabricate(this);
         assert(this->controller_);
         this->controller_->setPlayer(this);
-        if (this->controllableEntity_)
+        if (this->controllableEntity_) {
             this->controller_->setControllableEntity(this->controllableEntity_);
+            this->controllableEntity_->setController(this->controller_);
+        }
         this->changedController();
     }
 
@@ -157,8 +159,10 @@
 
         this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
 
-        if (this->controller_)
+        if (this->controller_) {
             this->controller_->setControllableEntity(entity);
+            this->controllableEntity_->setController(this->controller_);
+        }
 
         this->changedControllableEntity();
     }
@@ -170,6 +174,7 @@
         if (!entity)
             return;
 
+        this->controllableEntity_->setController(0);
         this->controllableEntity_ = 0;
         this->controllableEntityID_ = OBJECTID_UNKNOWN;
 

Modified: code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/weaponsystem/WeaponMode.h	2009-11-11 16:39:53 UTC (rev 6045)
@@ -38,6 +38,12 @@
 #include "core/SubclassIdentifier.h"
 #include "tools/Timer.h"
 
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+#include "controllers/Controller.h"
+
 namespace orxonox
 {
     class _OrxonoxExport WeaponMode : public BaseObject
@@ -124,6 +130,9 @@
             inline unsigned int getMode() const
                 { return this->mode_; }
 
+            inline Vector3 getTarget()
+                { return this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController()->getTarget(); }
+
         protected:
             virtual void fire() = 0;
 

Modified: code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/worldentities/ControllableEntity.cc	2009-11-11 16:39:53 UTC (rev 6045)
@@ -61,6 +61,7 @@
         this->hud_ = 0;
         this->camera_ = 0;
         this->xmlcontroller_ = 0;
+        this->controller_ = 0;
         this->reverseCamera_ = 0;
         this->bDestroyWhenPlayerLeft_ = false;
         this->cameraPositionRootNode_ = this->node_->createChildSceneNode();

Modified: code/branches/steering/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/steering/src/orxonox/worldentities/ControllableEntity.h	2009-11-11 11:33:54 UTC (rev 6044)
+++ code/branches/steering/src/orxonox/worldentities/ControllableEntity.h	2009-11-11 16:39:53 UTC (rev 6045)
@@ -139,6 +139,11 @@
             inline Controller* getXMLController() const
                 { return this->xmlcontroller_; }
 
+            inline Controller* getController() const
+                { return this->controller_; }
+            inline void setController(Controller* c)
+                { this->controller_ = c; }
+
         protected:
             virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead
             virtual void removePlayer();                // don't call this directly, use friend class PlayerInfo instead
@@ -200,6 +205,7 @@
             std::list<SmartPtr<CameraPosition> > cameraPositions_;
             std::string cameraPositionTemplate_;
             Controller* xmlcontroller_;
+            Controller* controller_;
             CameraPosition* reverseCamera_;
     };
 }




More information about the Orxonox-commit mailing list