[Orxonox-commit 1477] r6195 - in code/branches/presentation2/src/orxonox: controllers graphics

wirthmi at orxonox.net wirthmi at orxonox.net
Wed Dec 2 14:40:22 CET 2009


Author: wirthmi
Date: 2009-12-02 14:40:22 +0100 (Wed, 02 Dec 2009)
New Revision: 6195

Modified:
   code/branches/presentation2/src/orxonox/controllers/Controller.h
   code/branches/presentation2/src/orxonox/controllers/HumanController.cc
   code/branches/presentation2/src/orxonox/controllers/HumanController.h
   code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
   code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
   code/branches/presentation2/src/orxonox/graphics/Camera.cc
Log:
More camera easing, new center overlay and pauseControl/resumeControl


Modified: code/branches/presentation2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/controllers/Controller.h	2009-12-02 13:40:22 UTC (rev 6195)
@@ -39,7 +39,7 @@
         // set friend classes to access setControllableEntity
         friend class PlayerInfo;
         friend class ControllableEntity;
-        
+
         public:
             Controller(BaseObject* creator);
             virtual ~Controller();

Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.cc	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.cc	2009-12-02 13:40:22 UTC (rev 6195)
@@ -68,6 +68,8 @@
     {
         RegisterObject(HumanController);
 
+        controlPaused_ = false;
+
         HumanController::localController_s = this;
     }
 
@@ -249,4 +251,16 @@
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
             HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus();
     }
+
+    void HumanController::pauseControl()
+    {
+        if (HumanController::localController_s)
+            HumanController::localController_s->doPauseControl();
+    }
+
+    void HumanController::resumeControl()
+    {
+        if (HumanController::localController_s)
+            HumanController::localController_s->doResumeControl();
+    }
 }

Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.h	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.h	2009-12-02 13:40:22 UTC (rev 6195)
@@ -74,6 +74,11 @@
             static void addBots(unsigned int amount);
             static void killBots(unsigned int amount = 0);
 
+            static void pauseControl();
+            static void resumeControl();
+            virtual void doPauseControl() {};
+            virtual void doResumeControl() {};
+
             static inline HumanController* getLocalControllerSingleton()
                 { return HumanController::localController_s; }
             static Pawn* getLocalControllerEntityAsPawn();
@@ -82,6 +87,7 @@
 
         protected:
             static HumanController* localController_s;
+            bool controlPaused_;
     };
 }
 

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc	2009-12-02 13:40:22 UTC (rev 6195)
@@ -56,6 +56,7 @@
     NewHumanController::NewHumanController(BaseObject* creator)
         : HumanController(creator)
         , crossHairOverlay_(NULL)
+        , centerOverlay_(NULL)
     {
         RegisterObject(NewHumanController);
 
@@ -71,7 +72,13 @@
             crossHairOverlay_ = new OrxonoxOverlay(this);
             crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
             crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
-            crossHairOverlay_->show();
+            crossHairOverlay_->hide();
+
+            centerOverlay_ = new OrxonoxOverlay(this);
+            centerOverlay_->setBackgroundMaterial("Orxonox/CenterOverlay");
+            centerOverlay_->setSize(Vector2(overlaySize_ * 2.5, overlaySize_ * 2.5));
+            centerOverlay_->setPosition(Vector2(0.5 - overlaySize_*2.5/2.0, 0.5 - overlaySize_*2.5/2.0));\
+            centerOverlay_->hide();
         }
 
         // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
@@ -80,6 +87,8 @@
         this->targetMask_.exclude(ClassByString("Projectile"));
 
         NewHumanController::localController_s = this;
+
+//HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
     }
 
     NewHumanController::~NewHumanController()
@@ -98,12 +107,16 @@
             if( this->controllableEntity_ && !this->controllableEntity_->isInMouseLook() )
             {
                 this->updateTarget();
-                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();
+                if ( !controlPaused_ ) {
+                    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();
+                    this->centerOverlay_->show();
+                }
             }
-            else
+            else {
                 this->crossHairOverlay_->hide();
-            // TODO: update aimPosition of Pawn
+                this->centerOverlay_->hide();
+            }
 
             if ( this->acceleration_ > 0 )
             {
@@ -228,7 +241,7 @@
                     pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance );
                 }
 
-                itr->movable->getParentSceneNode()->showBoundingBox(true);
+                //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;
@@ -307,4 +320,16 @@
             NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.1f, 0.0f, 1.0f);
         }
     }
+
+    void NewHumanController::doResumeControl() {
+        this->controlPaused_ = false;
+        this->crossHairOverlay_->show();
+        this->centerOverlay_->show();
+    }
+
+    void NewHumanController::doPauseControl() {
+        this->controlPaused_ = true;
+        this->crossHairOverlay_->hide();
+        this->centerOverlay_->hide();
+    }
 }

Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.h	2009-12-02 13:40:22 UTC (rev 6195)
@@ -58,6 +58,8 @@
             static void changeMode();
 
             virtual void changedControllableEntity();
+            virtual void doPauseControl();
+            virtual void doResumeControl();
 
         protected:
             void updateTarget();
@@ -68,6 +70,7 @@
             float                       currentYaw_;
             float                       currentPitch_;
             OrxonoxOverlay*             crossHairOverlay_;
+            OrxonoxOverlay*             centerOverlay_;
             float                       overlaySize_;
             bool                        accelerating_;
             float                       acceleration_;

Modified: code/branches/presentation2/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/presentation2/src/orxonox/graphics/Camera.cc	2009-12-02 12:34:55 UTC (rev 6194)
+++ code/branches/presentation2/src/orxonox/graphics/Camera.cc	2009-12-02 13:40:22 UTC (rev 6195)
@@ -113,23 +113,34 @@
         if (this->bDrag_)
         {
             // this stuff here may need some adjustments
-            float coeff = 15.0f * dt / this->getTimeFactor();
+            float poscoeff = 15.0f * dt / this->getTimeFactor();
+            float anglecoeff = 7.0f * dt / this->getTimeFactor();
             // Only clamp if fps rate is actually falling. Occasional high dts should
             // not be clamped to reducing lagging effects.
-            if (coeff > 1.0f)
+            if (poscoeff > 1.0f)
             {
                 if (this->lastDtLagged_)
-                    coeff = 1.0f;
+                    poscoeff = 1.0f;
                 else
                     this->lastDtLagged_ = true;
             }
             else
                 this->lastDtLagged_ = false;
 
+            if (anglecoeff > 1.0f)
+            {
+                if (this->lastDtLagged_)
+                    anglecoeff = 1.0f;
+                else
+                    this->lastDtLagged_ = true;
+            }
+            else
+                this->lastDtLagged_ = false;
+
             Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
-            this->cameraNode_->translate(coeff * offset);
+            this->cameraNode_->translate(poscoeff * offset);
 
-            this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
+            this->cameraNode_->setOrientation(Quaternion::Slerp(anglecoeff, this->cameraNode_->_getDerivedOrientation(), this->getWorldOrientation(), true));
         }
 
         // Update sound listener transformation




More information about the Orxonox-commit mailing list