[Orxonox-commit 1393] r6111 - in code/branches/presentation2: . src/orxonox/controllers src/orxonox/weaponsystem src/orxonox/worldentities src/orxonox/worldentities/pawns

scheusso at orxonox.net scheusso at orxonox.net
Sat Nov 21 00:33:37 CET 2009


Author: scheusso
Date: 2009-11-21 00:33:37 +0100 (Sat, 21 Nov 2009)
New Revision: 6111

Modified:
   code/branches/presentation2/
   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/weaponsystem/WeaponMode.cc
   code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
   code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
   code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h
Log:
made some changes in NewHumanController, Pawn, CE, Controller and WeaponMode preparing the synchronisation of clients target and aimPosition



Property changes on: code/branches/presentation2
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/particles2:6050-6106
/code/branches/resource2:3372-5694
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
   + /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/particles2:6050-6106,6109
/code/branches/resource2:3372-5694
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890

Modified: code/branches/presentation2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-11-20 23:33:37 UTC (rev 6111)
@@ -53,11 +53,6 @@
                 { return this->controllableEntity_; }
             virtual void changedControllableEntity() {}
 
-            virtual bool canFindTarget()
-                { return false; }
-            virtual Vector3 getTarget()
-                { return Vector3::ZERO; }
-
         protected:
             // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do)
             inline void setControllableEntity(ControllableEntity* entity)

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-11-20 23:33:37 UTC (rev 6111)
@@ -36,6 +36,7 @@
 #include "core/CoreIncludes.h"
 #include "core/ConsoleCommand.h"
 #include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
 #include "infos/PlayerInfo.h"
 #include "overlays/OrxonoxOverlay.h"
 #include "graphics/Camera.h"
@@ -79,7 +80,14 @@
 
     void NewHumanController::tick(float dt)
     {
-        crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
+        if( !this->controllableEntity_->isInMouseLook() )
+        {
+            this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5-overlaySize_/2));
+            this->crossHairOverlay_->show();
+        }
+        else
+            this->crossHairOverlay_->hide();
+        // TODO: update aimPosition of Pawn
 
         HumanController::tick(dt);
     }
@@ -116,11 +124,13 @@
             } // if
         }
 */
+        if( !NewHumanController::localController_s->getControllableEntity()->isInMouseLook() )
+            this->updateTarget();
 
         HumanController::localController_s->getControllableEntity()->fire(firemode);
     }
 
-    Vector3 NewHumanController::getTarget()
+    void NewHumanController::updateTarget()
     {
         Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
 
@@ -139,6 +149,7 @@
 
 
         Ogre::RaySceneQueryResult& result = rsq->execute();
+        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
 
         Ogre::RaySceneQueryResult::iterator itr;
         for (itr = result.begin(); itr != result.end(); ++itr)
@@ -153,15 +164,29 @@
                     if (this->targetMask_.isExcluded(creator->getIdentifier()))
                         continue;
                 }
+                
+                this->getControllableEntity()->setTarget(wePtr);
 
                 itr->movable->getParentSceneNode()->showBoundingBox(true);
                 //std::cout << itr->movable->getParentSceneNode()->_getDerivedPosition() << endl;
-                return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
+                //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
+                if ( pawn )
+                {
+                    pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance ); // or itr->movable->getParentSceneNode()->_getDerivedPosition()
+                    pawn->setTarget( wePtr );
+                }
+                return;
             }
 
         }
+        if ( pawn )
+        {
+            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
+            pawn->setTarget( 0 );
+        }
 
-	return mouseRay.getOrigin() + mouseRay.getDirection() * 1200;
+    //return mouseRay.getOrigin() + mouseRay.getDirection() * 1200;
+    
 
         //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
         //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
@@ -188,8 +213,11 @@
     }
 
     void NewHumanController::changeMode() {
-        if (NewHumanController::localController_s->controlMode_ == 0)
-            NewHumanController::localController_s->controlMode_ = 1;
+        if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
+        {
+            if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() )
+                NewHumanController::localController_s->controlMode_ = 1;
+        }
         else
             NewHumanController::localController_s->controlMode_ = 0;
     }

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-11-20 23:33:37 UTC (rev 6111)
@@ -51,10 +51,9 @@
 
             static void changeMode();
 
-            virtual bool canFindTarget() { return true; }
-            virtual Vector3 getTarget();
-
         protected:
+            void updateTarget();
+            
             unsigned int                controlMode_;
             static NewHumanController* localController_s;
         private:

Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-11-20 23:33:37 UTC (rev 6111)
@@ -201,14 +201,17 @@
         {
             this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_;
 
-            Controller* controller = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController();
-            if (controller->canFindTarget())
+            Pawn* pawn = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
+            Vector3 muzzleDirection;
+            if ( pawn->getTarget() )
             {
-                Vector3 muzzleDirection(controller->getTarget() - this->muzzlePosition_);
-                this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
+                muzzleDirection = pawn->getTarget()->getWorldPosition() - this->muzzlePosition_;
             }
             else
-                this->muzzleOrientation_ = this->weapon_->getWorldOrientation();
+                muzzleDirection = pawn->getAimPosition() - this->muzzlePosition_;
+//             COUT(0) << "muzzleDirection " << muzzleDirection << endl;
+                //this->muzzleOrientation_ = this->weapon_->getWorldOrientation();
+            this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
         }
         else
         {

Modified: code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h	2009-11-20 23:33:37 UTC (rev 6111)
@@ -144,6 +144,11 @@
                 { return this->controller_; }
             inline void setController(Controller* val)
                 { this->controller_ = val; }
+            
+            virtual void setTarget( WorldEntity* target )
+                { this->target_ = target; }
+            virtual WorldEntity* getTarget()
+                { return this->target_.get(); }
 
         protected:
             virtual void setPlayer(PlayerInfo* player); // don't call this directly, use friend class PlayerInfo instead
@@ -208,6 +213,7 @@
             Controller* xmlcontroller_;
             Controller* controller_;
             CameraPosition* reverseCamera_;
+            WeakPtr<WorldEntity> target_;
     };
 }
 

Modified: code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc	2009-11-20 23:33:37 UTC (rev 6111)
@@ -66,6 +66,8 @@
         this->lastHitOriginator_ = 0;
 
         this->spawnparticleduration_ = 3.0f;
+        
+        this->aimPosition_ = Vector3::ZERO;
 
         this->getPickups().setOwner(this);
 

Modified: code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h	2009-11-20 20:31:54 UTC (rev 6110)
+++ code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h	2009-11-20 23:33:37 UTC (rev 6111)
@@ -115,6 +115,11 @@
                 { this->pickups_.useItem(); }
 
             virtual void startLocalHumanControl();
+            
+            void setAimPosition( Vector3 position )
+                { this->aimPosition_ = position; }
+            Vector3 getAimPosition()
+                { return this->aimPosition_; }
 
         protected:
             virtual void setPlayer(PlayerInfo* player);
@@ -145,6 +150,8 @@
         private:
             inline void setWeaponSystem(WeaponSystem* weaponsystem)
                 { this->weaponSystem_ = weaponsystem; }
+            
+            Vector3 aimPosition_;
     };
 }
 




More information about the Orxonox-commit mailing list