[Orxonox-commit 1390] r6108 - in code/branches/presentation2: . data/defaultConfig src/libraries/core/input src/modules/weapons/weaponmodes src/orxonox/controllers src/orxonox/graphics src/orxonox/infos src/orxonox/overlays src/orxonox/weaponsystem src/orxonox/worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Fri Nov 20 20:15:25 CET 2009
Author: scheusso
Date: 2009-11-20 20:15:25 +0100 (Fri, 20 Nov 2009)
New Revision: 6108
Added:
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
Modified:
code/branches/presentation2/
code/branches/presentation2/data/defaultConfig/keybindings.ini
code/branches/presentation2/src/libraries/core/input/InputManager.cc
code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
code/branches/presentation2/src/orxonox/controllers/CMakeLists.txt
code/branches/presentation2/src/orxonox/controllers/Controller.cc
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/graphics/Camera.cc
code/branches/presentation2/src/orxonox/graphics/Camera.h
code/branches/presentation2/src/orxonox/infos/HumanPlayer.cc
code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc
code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.h
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc
code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h
code/branches/presentation2/src/orxonox/worldentities/WorldEntity.cc
code/branches/presentation2/src/orxonox/worldentities/WorldEntity.h
Log:
merged steering branch to presentation2 branch
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/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
/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/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/presentation2/data/defaultConfig/keybindings.ini 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/data/defaultConfig/keybindings.ini 2009-11-20 19:15:25 UTC (rev 6108)
@@ -121,9 +121,9 @@
KeySpace=boost
KeyStop=
KeySystemRequest=
-KeyT=
-KeyTab="cycleNavigationFocus"
-KeyU=
+KeyT=""
+KeyTab="NewHumanController changeMode"
+KeyU=""
KeyUP="scale 1 moveFrontBack"
KeyUnassigned="openConsole"
KeyUnderline=
Modified: code/branches/presentation2/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/InputManager.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/libraries/core/input/InputManager.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -630,11 +630,16 @@
if (stateDestroyRequests_.find(it->second) == stateDestroyRequests_.end())
{
// not scheduled for destruction
- // prevents a state being added multiple times
+ // prevents a state from being added multiple times
stateEnterRequests_.insert(it->second);
return true;
}
}
+ else if (this->stateLeaveRequests_.find(it->second) != this->stateLeaveRequests_.end())
+ {
+ // State already scheduled for leaving --> cancel
+ this->stateLeaveRequests_.erase(this->stateLeaveRequests_.find(it->second));
+ }
}
return false;
}
@@ -657,6 +662,11 @@
stateLeaveRequests_.insert(it->second);
return true;
}
+ else if (this->stateEnterRequests_.find(it->second) != this->stateEnterRequests_.end())
+ {
+ // State already scheduled for entering --> cancel
+ this->stateEnterRequests_.erase(this->stateEnterRequests_.find(it->second));
+ }
}
return false;
}
Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -38,6 +38,7 @@
#include "weaponsystem/Weapon.h"
#include "weaponsystem/WeaponPack.h"
#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
namespace orxonox
{
@@ -109,6 +110,7 @@
projectile->attach(model);
model->setScale(5);
+ this->computeMuzzleParameters();
projectile->setOrientation(this->getMuzzleOrientation());
projectile->setPosition(this->getMuzzlePosition());
projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
Modified: code/branches/presentation2/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/CMakeLists.txt 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/controllers/CMakeLists.txt 2009-11-20 19:15:25 UTC (rev 6108)
@@ -1,6 +1,7 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
Controller.cc
HumanController.cc
+ NewHumanController.cc
ArtificialController.cc
AIController.cc
ScriptController.cc
Modified: code/branches/presentation2/src/orxonox/controllers/Controller.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/Controller.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/controllers/Controller.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -28,6 +28,7 @@
#include "Controller.h"
#include "core/CoreIncludes.h"
+#include "worldentities/ControllableEntity.h"
namespace orxonox
{
Modified: code/branches/presentation2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/Controller.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/controllers/Controller.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -53,6 +53,11 @@
{ 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)
@@ -64,6 +69,7 @@
}
}
+ protected:
PlayerInfo* player_;
ControllableEntity* controllableEntity_;
};
Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -112,7 +112,7 @@
HumanController::localController_s->controllableEntity_->moveUpDown(value);
}
- void HumanController::rotateYaw(const Vector2& value)
+ void HumanController::yaw(const Vector2& value)
{
//Hack to enable mouselook in map
if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
@@ -124,7 +124,7 @@
HumanController::localController_s->controllableEntity_->rotateYaw(value);
}
- void HumanController::rotatePitch(const Vector2& value)
+ void HumanController::pitch(const Vector2& value)
{
//Hack to enable mouselook in map
if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
@@ -142,7 +142,7 @@
HumanController::localController_s->controllableEntity_->rotateRoll(value);
}
- void HumanController::fire(unsigned int firemode)
+ void HumanController::doFire(unsigned int firemode)
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->fire(firemode);
Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -48,11 +48,15 @@
static void moveRightLeft(const Vector2& value);
static void moveUpDown(const Vector2& value);
- static void rotateYaw(const Vector2& value);
- static void rotatePitch(const Vector2& value);
+ static void rotateYaw(const Vector2& value){ HumanController::localController_s->yaw(value); }
+ static void rotatePitch(const Vector2& value){ HumanController::localController_s->pitch(value); }
static void rotateRoll(const Vector2& value);
+
+ virtual void yaw(const Vector2& value);
+ virtual void pitch(const Vector2& value);
- static void fire(unsigned int firemode);
+ static void fire(unsigned int firemode) { HumanController::localController_s->doFire(firemode); }
+ virtual void doFire(unsigned int firemode);
static void reload();
static void boost();
@@ -75,7 +79,7 @@
//friend class, for mouselook
friend class Map;
- private:
+ protected:
static HumanController* localController_s;
};
}
Copied: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc (from rev 6091, code/branches/steering/src/orxonox/controllers/NewHumanController.cc)
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc (rev 0)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -0,0 +1,196 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Michael Wirth
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "NewHumanController.h"
+
+#include <OgreRay.h>
+#include <OgreSceneQuery.h>
+#include <OgreCamera.h>
+#include <OgreSceneManager.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "worldentities/ControllableEntity.h"
+#include "infos/PlayerInfo.h"
+#include "overlays/OrxonoxOverlay.h"
+#include "graphics/Camera.h"
+#include "sound/SoundManager.h"
+#include "Scene.h"
+
+namespace orxonox
+{
+ SetConsoleCommand(NewHumanController, changeMode, false).keybindMode(KeybindMode::OnPress);
+
+ CreateUnloadableFactory(NewHumanController);
+
+ NewHumanController* NewHumanController::localController_s = 0;
+
+ NewHumanController::NewHumanController(BaseObject* creator) : HumanController(creator)
+ {
+ RegisterObject(NewHumanController);
+
+ overlaySize_ = 0.08;
+ controlMode_ = 0;
+
+ crossHairOverlay_ = new OrxonoxOverlay(this);
+ crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
+ crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
+ crossHairOverlay_->show();
+
+ // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
+ this->targetMask_.exclude(ClassByString("BaseObject"));
+ this->targetMask_.include(ClassByString("WorldEntity"));
+ this->targetMask_.exclude(ClassByString("Projectile"));
+
+ NewHumanController::localController_s = this;
+ }
+
+ NewHumanController::~NewHumanController()
+ {
+ if (this->isInitialized())
+ {
+ }
+ }
+
+ 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));
+
+ HumanController::tick(dt);
+ }
+
+ /*void NewHumanController::tick(float dt)
+ {
+ if (GameMode::playsSound() && NewHumanController::localController_s && NewHumanController::localController_s->controllableEntity_)
+ {
+ // Update sound listener
+ Camera* camera = NewHumanController::localController_s->controllableEntity_->getCamera();
+ if (camera)
+ {
+ SoundManager::getInstance().setListenerPosition(camera->getWorldPosition());
+ SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation());
+ }
+ else
+ COUT(3) << "NewHumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
+ }
+ }*/
+
+ void NewHumanController::doFire(unsigned int firemode)
+ {
+ //if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) {
+
+/*
+ // Get results, create a node/entity on the position
+ for ( itr = result.begin(); itr != result.end(); itr++ )
+ {
+ if (itr->movable && itr->movable->getName() == "Head")
+ {
+ soundMgr->StopSound( &jaguarSoundChannel );
+ soundMgr->PlaySound( jaguarSound, headNode, &jaguarSoundChannel );
+ break;
+ } // if
+ }
+*/
+
+ HumanController::localController_s->getControllableEntity()->fire(firemode);
+ }
+
+ Vector3 NewHumanController::getTarget()
+ {
+ Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
+
+ Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->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)
+ {
+ if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
+ {
+ // Try to cast the user pointer
+ WorldEntity* wePtr = dynamic_cast<WorldEntity*>(itr->movable->getUserObject());
+ if (wePtr)
+ {
+ BaseObject* creator = wePtr->getCreator();
+ if (this->targetMask_.isExcluded(creator->getIdentifier()))
+ continue;
+ }
+
+ 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() * 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);
+ }
+
+ void NewHumanController::yaw(const Vector2& value)
+ {
+// SUPER(NewHumanController, yaw, value);
+ if (this->controlMode_ == 0)
+ HumanController::yaw(value);
+
+ this->currentYaw_ = value.x;
+ //std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl;
+ }
+
+ void NewHumanController::pitch(const Vector2& value)
+ {
+// SUPER(NewHumanController, pitch, value);
+ if (this->controlMode_ == 0)
+ HumanController::pitch(value);
+
+ this->currentPitch_ = value.x;
+ //std::cout << "Y: " << static_cast<float>(this->currentPitch_) << " X: " << static_cast<float>(this->currentYaw_) << endl;
+ }
+
+ void NewHumanController::changeMode() {
+ if (NewHumanController::localController_s->controlMode_ == 0)
+ NewHumanController::localController_s->controlMode_ = 1;
+ else
+ NewHumanController::localController_s->controlMode_ = 0;
+ }
+}
Copied: code/branches/presentation2/src/orxonox/controllers/NewHumanController.h (from rev 6091, code/branches/steering/src/orxonox/controllers/NewHumanController.h)
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.h (rev 0)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -0,0 +1,69 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Michael Wirth
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _NewNewHumanController_H__
+#define _NewNewHumanController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/ClassTreeMask.h"
+#include "HumanController.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport NewHumanController : public HumanController
+ {
+ public:
+ NewHumanController(BaseObject* creator);
+ 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);
+
+ static void changeMode();
+
+ virtual bool canFindTarget() { return true; }
+ virtual Vector3 getTarget();
+
+ protected:
+ unsigned int controlMode_;
+ static NewHumanController* localController_s;
+ private:
+ float currentYaw_;
+ float currentPitch_;
+ OrxonoxOverlay* crossHairOverlay_;
+ float overlaySize_;
+ ClassTreeMask targetMask_;
+ };
+}
+
+#endif /* _NewHumanController_H__ */
Modified: code/branches/presentation2/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/presentation2/src/orxonox/graphics/Camera.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/graphics/Camera.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -60,6 +60,7 @@
ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given.");
this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
+ this->camera_->setUserObject(this);
this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
this->attachNode(this->cameraNode_);
this->cameraNode_->attachObject(this->camera_);
Modified: code/branches/presentation2/src/orxonox/graphics/Camera.h
===================================================================
--- code/branches/presentation2/src/orxonox/graphics/Camera.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/graphics/Camera.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -51,6 +51,9 @@
void requestFocus();
void releaseFocus();
+ inline Ogre::Camera* getOgreCamera()
+ { return this->camera_; }
+
inline bool hasFocus()
{ return this->bHasFocus_; }
Modified: code/branches/presentation2/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/branches/presentation2/src/orxonox/infos/HumanPlayer.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/infos/HumanPlayer.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -34,6 +34,7 @@
#include "network/ClientInformation.h"
#include "network/Host.h"
#include "controllers/HumanController.h"
+#include "controllers/NewHumanController.h"
#include "gametypes/Gametype.h"
#include "overlays/OverlayGroup.h"
@@ -49,7 +50,7 @@
this->client_initialized_ = false;
this->bHumanPlayer_ = true;
- this->defaultController_ = Class(HumanController);
+ this->defaultController_ = Class(NewHumanController);
this->humanHud_ = 0;
this->gametypeHud_ = 0;
Modified: code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -138,7 +138,10 @@
assert(this->controller_);
this->controller_->setPlayer(this);
if (this->controllableEntity_)
+ {
this->controller_->setControllableEntity(this->controllableEntity_);
+ this->controllableEntity_->setController(this->controller_);
+ }
this->changedController();
}
@@ -160,7 +163,10 @@
this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
if (this->controller_)
+ {
this->controller_->setControllableEntity(entity);
+ this->controllableEntity_->setController(this->controller_);
+ }
this->changedControllableEntity();
}
@@ -194,6 +200,7 @@
if (!entity)
return;
+ this->controllableEntity_->setController(0);
this->controllableEntity_ = 0;
this->controllableEntityID_ = OBJECTID_UNKNOWN;
Modified: code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/overlays/OrxonoxOverlay.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -154,6 +154,9 @@
//! ConsoleCommand: Accesses the overlay by its name and rotates it.
static void rotateOverlay(const std::string& name, const Degree& angle);
+ void setBackgroundMaterial(const std::string& material);
+ const std::string& getBackgroundMaterial() const;
+
virtual void changedVisibility();
inline void setOwner(BaseObject* owner)
@@ -180,9 +183,6 @@
virtual void sizeChanged();
virtual void positionChanged();
- void setBackgroundMaterial(const std::string& material);
- const std::string& getBackgroundMaterial() const;
-
Ogre::Overlay* overlay_; //!< The overlay the entire class is about.
Ogre::PanelOverlayElement* background_; //!< Background image (blank per default).
Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -31,6 +31,8 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "controllers/Controller.h"
+#include "worldentities/pawns/Pawn.h"
#include "Munition.h"
#include "Weapon.h"
@@ -193,26 +195,32 @@
this->bReloading_ = false;
}
- Vector3 WeaponMode::getMuzzlePosition() const
+ void WeaponMode::computeMuzzleParameters()
{
if (this->weapon_)
- return (this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_);
- else
- return this->muzzleOffset_;
- }
+ {
+ this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_;
- const Quaternion& WeaponMode::getMuzzleOrientation() const
- {
- if (this->weapon_)
- return this->weapon_->getWorldOrientation();
+ Controller* controller = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getController();
+ if (controller->canFindTarget())
+ {
+ Vector3 muzzleDirection(controller->getTarget() - this->muzzlePosition_);
+ this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
+ }
+ else
+ this->muzzleOrientation_ = this->weapon_->getWorldOrientation();
+ }
else
- return Quaternion::IDENTITY;
+ {
+ this->muzzlePosition_ = this->muzzleOffset_;
+ this->muzzleOrientation_ = Quaternion::IDENTITY;
+ }
}
Vector3 WeaponMode::getMuzzleDirection() const
{
if (this->weapon_)
- return (this->weapon_->getWorldOrientation() * WorldEntity::FRONT);
+ return (this->getMuzzleOrientation() * WorldEntity::FRONT);
else
return WorldEntity::FRONT;
}
Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -108,8 +108,11 @@
inline const Vector3& getMuzzleOffset() const
{ return this->muzzleOffset_; }
- Vector3 getMuzzlePosition() const;
- const Quaternion& getMuzzleOrientation() const;
+ void computeMuzzleParameters();
+ const Vector3& getMuzzlePosition() const
+ { return this->muzzlePosition_; }
+ const Quaternion& getMuzzleOrientation() const
+ { return this->muzzleOrientation_; }
Vector3 getMuzzleDirection() const;
@@ -124,6 +127,8 @@
inline unsigned int getMode() const
{ return this->mode_; }
+ Vector3 getTarget();
+
protected:
virtual void fire() = 0;
@@ -151,6 +156,9 @@
Timer reloadTimer_;
bool bReloading_;
+
+ Vector3 muzzlePosition_;
+ Quaternion muzzleOrientation_;
};
}
Modified: code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -64,6 +64,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/presentation2/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/worldentities/ControllableEntity.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -140,6 +140,11 @@
inline Controller* getXMLController() const
{ return this->xmlcontroller_; }
+ inline Controller* getController() const
+ { return this->controller_; }
+ inline void setController(Controller* val)
+ { this->controller_ = val; }
+
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
@@ -201,6 +206,7 @@
std::list<SmartPtr<CameraPosition> > cameraPositions_;
std::string cameraPositionTemplate_;
Controller* xmlcontroller_;
+ Controller* controller_;
CameraPosition* reverseCamera_;
};
}
Modified: code/branches/presentation2/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/WorldEntity.cc 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/worldentities/WorldEntity.cc 2009-11-20 19:15:25 UTC (rev 6108)
@@ -471,27 +471,35 @@
//! Attaches an Ogre::MovableObject to this WorldEntity.
void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
- { this->node_->attachObject(object); }
+ {
+ this->node_->attachObject(object);
+ object->setUserObject(this);
+ }
+
void WorldEntity::attachOgreObject(Ogre::BillboardSet* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::Camera* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::Entity* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::attachOgreObject(Ogre::ParticleSystem* object)
- { this->node_->attachObject(object); }
+ { this->attachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
//! Detaches an Ogre::MovableObject from this WorldEntity.
void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
- { this->node_->detachObject(object); }
+ {
+ object->setUserObject(NULL);
+ this->node_->detachObject(object);
+ }
+
void WorldEntity::detachOgreObject(Ogre::BillboardSet* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::Camera* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::Entity* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
void WorldEntity::detachOgreObject(Ogre::ParticleSystem* object)
- { this->node_->detachObject(object); }
+ { this->detachOgreObject(static_cast<Ogre::MovableObject*>(object)); }
//! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
@@ -645,7 +653,7 @@
/**
@brief
- Makes this WorldEntity look a specific target location.
+ Makes this WorldEntity look at a specific target location.
@param relativeTo
@see WorldEntity::TransformSpace
@param localDirectionVector
@@ -912,7 +920,7 @@
}
}
- //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
+ //! Copies our own parameters for restitution, angular factor, damping and friction to the bullet rigid body.
void WorldEntity::internalSetPhysicsProps()
{
if (this->hasPhysics())
Modified: code/branches/presentation2/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/presentation2/src/orxonox/worldentities/WorldEntity.h 2009-11-20 16:20:11 UTC (rev 6107)
+++ code/branches/presentation2/src/orxonox/worldentities/WorldEntity.h 2009-11-20 19:15:25 UTC (rev 6108)
@@ -32,6 +32,7 @@
#include "OrxonoxPrereqs.h"
+#include <OgreUserDefinedObject.h>
#ifdef ORXONOX_RELEASE
# include <OgreSceneNode.h>
#endif
@@ -54,7 +55,7 @@
as more advanced ones.
The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
- to create an entire hierarchy of derivated objects.
+ to create an entire hierarchy of derived objects.
It is also the basis for the physics interface to the Bullet physics engine.
Every WorldEntity can have a specific collision type: @see CollisionType
This would then imply that every scene object could have any collision type. To limit this, you can always
@@ -62,13 +63,13 @@
for a specific object.
There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
of both objects simply get merged into one larger shape (for static collision type).
- The phyiscal body that is internally stored and administrated has the following supported properties:
- - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
+ The physical body that is internally stored and administrated has the following supported properties:
+ - Restitution, angular factor, linear damping, angular damping, friction, mass and collision shape.
You can get more information at the corresponding set function.
Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
*/
- class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
+ class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState, public Ogre::UserDefinedObject
{
friend class Scene;
@@ -317,7 +318,7 @@
@brief
Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
- Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
+ Normally the angular factor is 1, which means it's physically 'correct'. However if you have a player
character that should not rotate when hit sideways, you can set the angular factor to 0.
*/
inline void setAngularFactor(float angularFactor)
@@ -393,7 +394,7 @@
You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
- in its constructor and override this method. But be careful that a derived classe's virtual functions
+ in its constructor and override this method. But be careful that a derived class's virtual functions
don't yet exist in the constructor if a base class.
*/
virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
More information about the Orxonox-commit
mailing list