[Orxonox-commit 2151] r6867 - in code/branches/fps: data/levels data/levels/includes data/levels/templates data/overlays src/orxonox/worldentities/pawns
freicy at orxonox.net
freicy at orxonox.net
Mon May 10 12:58:17 CEST 2010
Author: freicy
Date: 2010-05-10 12:58:17 +0200 (Mon, 10 May 2010)
New Revision: 6867
Added:
code/branches/fps/data/levels/fps_test.oxw
code/branches/fps/data/levels/includes/weaponsettings_fps.oxi
code/branches/fps/data/levels/templates/fps.oxt
code/branches/fps/data/overlays/hudtamplates_fps.oxo
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h
Log:
commit by cyrill
Added: code/branches/fps/data/levels/fps_test.oxw
===================================================================
--- code/branches/fps/data/levels/fps_test.oxw (rev 0)
+++ code/branches/fps/data/levels/fps_test.oxw 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,150 @@
+<?lua
+ include("hudtemplates3.oxo")
+ include("stats.oxo")
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_H2.oxt")
+ include("templates/fps.oxt")
+?>
+
+<Level
+ name = "fps"
+ description = "tests"
+>
+ <Scene
+ ambientlight = "0.1, 0.1, 0.1"
+ skybox = "Orxonox/skypanoramagen1"
+ gravity = "0,-1000,0"
+ negativeWorldRange = "(-100000, -100000, -100000)"
+ positiveWorldRange = "( 100000, 100000, 100000)"
+ hasPhysics = true
+ >
+ <Light type=directional position="0,-100000,0" direction="0.02, -1, 0.05" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+
+ <StaticEntity position="0,-10000,0" direction="0,-1,0" collisionType=static mass=100000 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="10000,10000,1000" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10000,10000,1000" />
+ </collisionShapes>
+ </StaticEntity>
+
+<?lua
+for i = 1, 10, 1
+do ?>
+ <SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,100,<?lua print(math.random() * 1000 - 500) ?>" direction="-1, 0, 0" lookat="0,0,0" spawnclass=FpsPlayer pawndesign=fps />
+<?lua
+end
+?>
+
+
+<?lua
+for i = 1, 200, 1
+do
+j = math.random()
+?>
+
+ <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 100) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>" >
+ <attached>
+ <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="<?lua print(j * 100) ?>" />
+ </collisionShapes>
+ </MovableEntity>
+<?lua
+end
+?>
+
+ </Scene>
+</Level>
+<!--
+<Level
+ name = "fps test"
+ description = "level to test fps navigation"
+>
+ <Scene
+ ambientlight = "0.5, 0.5, 0.5"
+ skybox = "Orxonox/skypanoramagen1"
+ >
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+
+
+<?lua
+for i = 1, 10, 1
+do ?>
+ <SpawnPoint position="<?lua print(math.random() * 1000 - 500) ?>,0,<?lua print(math.random() * 1000 - 500) ?>" lookat="0,0,0" spawnclass=FpsPlayer pawndesign=fps />
+<?lua
+end
+?>
+
+ <GlobalShader compositor="Bloom" visible=false>
+ <events>
+ <visibility>
+ <DistanceTrigger position="0,0,0" distance=30 target="Spectator" switch=true />
+ </visibility>
+ </events>
+ </GlobalShader>
+
+
+<?lua
+for i = 1, 100, 1
+do
+j = math.random()
+?>
+
+ <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
+ </attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="<?lua print(j * 70) ?>" />
+ </collisionShapes>
+ </MovableEntity>
+<?lua
+end
+?>
+
+<!--
+<?lua
+for i = 1, 70, 1
+do ?>
+ <MovableEntity position="<?lua print(math.random() * 6000 - 3000)?>, <?lua print(math.random() * 6000 - 3000) ?>, <?lua print(math.random() * 1000 + 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+ <MovableEntity position="<?lua print(math.random() * 6000 - 3000)?>, <?lua print(math.random() * 6000 - 3000) ?>, <?lua print(math.random() * -1000 - 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+
+ <MovableEntity position="<?lua print(math.random() * 6000 - 3000)?>, <?lua print(math.random() * 1000 + 3000) ?>, <?lua print(math.random() * 6000 - 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+ <MovableEntity position="<?lua print(math.random() * 6000 - 3000)?>, <?lua print(math.random() * -1000 - 3000) ?>, <?lua print(math.random() * 6000 - 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+
+ <MovableEntity position="<?lua print(math.random() * 1000 + 3000)?>, <?lua print(math.random() * 6000 - 3000) ?>, <?lua print(math.random() * 6000 - 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+ <MovableEntity position="<?lua print(math.random() * -1000 - 3000)?>, <?lua print(math.random() * 6000 - 3000) ?>, <?lua print(math.random() * 6000 - 3000) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 30 + 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
+ </attached>
+ </MovableEntity>
+<?lua
+end
+?>
+
+ </Scene>
+</Level>
+-->
\ No newline at end of file
Added: code/branches/fps/data/levels/includes/weaponsettings_fps.oxi
===================================================================
--- code/branches/fps/data/levels/includes/weaponsettings_fps.oxi (rev 0)
+++ code/branches/fps/data/levels/includes/weaponsettings_fps.oxi 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,55 @@
+ <weaponslots>
+ <WeaponSlot position="0,-6,0.5" yaw=0 pitch=0 roll=0 />
+ <!-- <WeaponSlot position="15,-1.5,-25" yaw=0 pitch=0 roll=0 />
+ <WeaponSlot position="0,0,-45" yaw=0 pitch=0 roll=0 /> -->
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ <WeaponSet firemode=1 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack firemode=0>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+ <DefaultWeaponmodeLink firemode=2 weaponmode=2 />
+ </links>
+ <Weapon>
+ <attached>
+ <Model mesh="LightningGun.mesh" pitch="78" roll="90" yaw="90" position="0,-1.3,0" />
+ <Model mesh="LightningGun-s.mesh" pitch="78" roll="90" yaw="90" position="0.2,-1.3,0" />
+ <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
+ <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
+ </attached>
+ <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
+ </Weapon>
+ <LaserGun
+ position="0,0,0"
+ munitionType="LaserGunMunition"
+ bulletLoadingTime="0.2"
+ magazineLoadingTime="5.0"
+ speed="1250"
+ unlimitedMunition=true
+ />
+ <!-- <LaserGun
+ position="0,0,0"
+ munitionType="LaserGunMunition"
+ bulletLoadingTime="0.2"
+ magazineLoadingTime="5.0"
+ speed="1250"
+ unlimitedMunition=true
+ />
+ </WeaponPack>
+ <WeaponPack firemode=1>
+ <Fusion
+ position="0,0,0"
+ munitionType="FusionMunition"
+ bulletLoadingTime="0.3"
+ magazineLoadingTime="3"
+ speed="600"
+ unlimitedMunition=true
+ /> -->
+ </WeaponPack>
+ </weapons>
Added: code/branches/fps/data/levels/templates/fps.oxt
===================================================================
--- code/branches/fps/data/levels/templates/fps.oxt (rev 0)
+++ code/branches/fps/data/levels/templates/fps.oxt 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,60 @@
+<Template name=fps>
+ <FpsPlayer
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = fpscamera
+
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 100
+ maxhealth = 200
+ initialhealth = 100
+
+ primaryThrust = 100;
+ auxilaryThrust = 30;
+ rotationThrust = 25;
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <!-- <attached>
+ <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
+ <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 />
+ <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
+ </attached>
+-->
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="100,10,100" />
+ <!--
+ <SphereCollisionShape radius="10" />
+
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ -->
+ </collisionShapes>
+
+<?lua
+ include("includes/weaponsettings_fps.oxi")
+?>
+ </FpsPlayer>
+</Template>
+
+<Template name=fpscamera defaults=0>
+ <FpsPlayer>
+ <camerapositions>
+ <CameraPosition position="0,0,0" drag=false mouselook=true />
+ <!--CameraPosition position="0,150,-25" pitch=-90 drag=true />
+ <CameraPosition position="0,0,-40" yaw=180 drag=true />
+ <CameraPosition position="0,3,-14" yaw=0 />
+ <CameraPosition position="-50,5,-8" yaw=-90 drag=true />
+ <CameraPosition position="50,5,-8" yaw=90 drag=true /-->
+ </camerapositions>
+ </FpsPlayer>
+</Template>
\ No newline at end of file
Added: code/branches/fps/data/overlays/hudtamplates_fps.oxo
===================================================================
--- code/branches/fps/data/overlays/hudtamplates_fps.oxo (rev 0)
+++ code/branches/fps/data/overlays/hudtamplates_fps.oxo 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,82 @@
+<Template name="spectatorhud">
+ <OverlayGroup name = "spectatorhud" scale = "1, 1">
+ </OverlayGroup>
+</Template>
+
+<Template name="spaceshiphud">
+ <OverlayGroup name = "spaceshiphud" scale = "1, 1">
+ <Map />
+
+ <HUDHealthBar
+ name = "HealthBar1"
+ background = "Orxonox/HealthBarBackground"
+ size = "0.35, 0.0875"
+ position = "0.0 , 0.95 "
+ pickpoint = "0, 1"
+ bartexture = "healthbar_bar.tga"
+ textfont = "VeraMono"
+ textusebarcolour = true
+ textsize = 0.039
+ textoffset = "0.315, 0.05"
+ textpickpoint = "0, 0"
+ textalign = "right"
+ correctaspect = false
+ textcorrectaspect = false
+ >
+ <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
+ <BarColour position = 0.5 colour = "0.7,0.7,0.2" />
+ <BarColour position = 1.0 colour = "0.2,0.7,0.2" />
+ </HUDHealthBar>
+
+ <!-- <HUDSpeedBar
+ name = "SpeedBar1"
+ background = "Orxonox/BarBackground"
+ size = "0.35, 0.05"
+ position = "0.0 , 1.0 "
+ pickpoint = "0, 1"
+ correctaspect = false
+ >
+ <BarColour position = 0.0 colour = "0.7,0.5,0.2" />
+ <BarColour position = 0.5 colour = "0.2,0.7,0.2" />
+ <BarColour position = 1.0 colour = "0.7,0.2,0.2" />
+ </HUDSpeedBar>
+-->
+ <HUDNavigation
+ name = "Navigation"
+ correctaspect = true
+ font = "Monofur"
+ textsize = 0.05
+ navMarkerSize = 0.03
+ aimMarkerSize = 0.04
+ />
+
+ <HUDRadar
+ name = "Radar"
+ background = "Orxonox/Radar"
+ correctaspect = true
+ size = "0.17, 0.17"
+ position = "1.0, 1.0"
+ pickpoint = "1.0, 1.0"
+ rotation = 0
+ sensitivity = 1.0
+ halfDotSizeDistance = 3000
+ maximumDotSize = 0.1
+ />
+
+ <HUDTimer
+ name = "Timer"
+ position = "0.5, 0.85"
+ font = "VeraMono"
+ textsize = 0.1
+ colour = "1.0, 1.0, 0.0, 0.8"
+ align = "center"
+ />
+
+ <GUIOverlay
+ name = "QuestGUI"
+ guiname = "QuestGUI"
+ visible = "false"
+ />
+
+ </OverlayGroup>
+</Template>
Added: code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc (rev 0)
+++ code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,228 @@
+/*
+ * 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:
+ * Cyrill Frei
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "FpsPlayer.h"
+
+#include <OgreSceneNode.h>
+#include <BulletDynamics/Dynamics/btRigidBody.h>
+#include <LinearMath/btVector3.h>
+#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
+
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "items/Engine.h"
+
+#include <cmath>
+
+namespace orxonox
+{
+ const float orientationGain = 100;
+ const float jumpvalue = 300;
+ CreateFactory(FpsPlayer);
+
+ FpsPlayer::FpsPlayer(BaseObject* creator) : Pawn(creator)
+ {
+ RegisterObject(FpsPlayer);
+ this->speed_ = 200;
+ this->localVelocity_ = Vector3::ZERO;
+/*
+ * this->primaryThrust_ = 100;
+ * this->auxilaryThrust_ = 30;
+ * this->rotationThrust_ = 10;
+ *
+ * this->localLinearAcceleration_.setValue(0, 0, 0);
+ * this->localAngularAcceleration_.setValue(0, 0, 0);
+ * this->bBoost_ = false;
+ * this->bPermanentBoost_ = false;
+ * this->steering_ = Vector3::ZERO;
+*/
+
+
+ this->bInvertYAxis_ = false;
+
+ this->setDestroyWhenPlayerLeft(true);
+
+ // FpsPlayer is always a physical object per default
+ // Be aware of this call: The collision type legality check will not reach derived classes!
+ this->setCollisionType(WorldEntity::Dynamic);
+ // Get notification about collisions
+ this->enableCollisionCallback();
+
+ this->setConfigValues();
+ this->registerVariables();
+ }
+
+ FpsPlayer::~FpsPlayer()
+ {
+ }
+
+ void FpsPlayer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(FpsPlayer, XMLPort, xmlelement, mode);
+
+ XMLPortParamVariable(FpsPlayer, "primaryThrust", primaryThrust_, xmlelement, mode);
+ XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
+ XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode);
+ }
+
+ void FpsPlayer::registerVariables()
+ {
+ registerVariable(this->primaryThrust_, VariableDirection::ToClient);
+ registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
+ registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+ }
+
+ void FpsPlayer::setConfigValues()
+ {
+ SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = targetting down).");
+ }
+
+ bool FpsPlayer::isCollisionTypeLegal(WorldEntity::CollisionType type) const
+ {
+ if (type != WorldEntity::Dynamic)
+ {
+ CCOUT(1) << "Error: Cannot tell a FpsPlayer not to be dynamic! Ignoring." << std::endl;
+ assert(false); // Only in debug mode
+ return false;
+ }
+ else
+ return true;
+ }
+
+ void FpsPlayer::tick(float dt)
+ {
+ if (this->hasLocalController())
+ {
+
+ thistickboost=false;
+
+ float localSpeedSquared = this->localVelocity_.squaredLength();
+ float localSpeed;
+ if (localSpeedSquared > 1.0)
+ localSpeed = this->speed_ / sqrtf(localSpeedSquared);
+ else
+ localSpeed = this->speed_;
+
+ this->localVelocity_.x *= localSpeed;
+ this->localVelocity_.z *= localSpeed;
+ Vector3 temp = this->getOrientation() * this->localVelocity_;
+ if(localVelocity_.y==jumpvalue) this->setVelocity(Vector3(temp.x, temp.y + this->getVelocity().y, temp.z));
+ else this->setVelocity(Vector3(temp.x, this->getVelocity().y, temp.z));
+ this->localVelocity_.x = 0;
+ this->localVelocity_.y = 0;
+ this->localVelocity_.z = 0;
+
+ if (!this->isInMouseLook())
+ {
+ this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()),WorldEntity::Parent);
+ //this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ // this->roll(Radian(this->roll_ * this->getMouseLookSpeed()));
+ }
+
+ this->yaw_ = this->pitch_ = this->roll_ = 0;
+ }
+
+ SUPER(FpsPlayer, tick, dt);
+ }
+
+ void FpsPlayer::setPlayer(PlayerInfo* player)
+ {
+ ControllableEntity::setPlayer(player);
+
+// this->setSyncMode(ObjectDirection::ToClient);
+ }
+
+ void FpsPlayer::startLocalHumanControl()
+ {
+ ControllableEntity::startLocalHumanControl();
+ }
+
+ void FpsPlayer::moveFrontBack(const Vector2& value)
+ {
+ this->localVelocity_.z -= value.x;
+ }
+
+
+ void FpsPlayer::moveRightLeft(const Vector2& value)
+ {
+ this->localVelocity_.x += value.x;
+ }
+
+ void FpsPlayer::moveUpDown(const Vector2& value)
+ {
+ //this->localVelocity_.y += value.x;
+ }
+
+ void FpsPlayer::rotateYaw(const Vector2& value)
+ {
+ this->yaw_ += value.y;
+
+ ControllableEntity::rotateYaw(value);
+ }
+
+ void FpsPlayer::rotatePitch(const Vector2& value)
+ {
+ this->pitch_ += value.y;
+
+ ControllableEntity::rotatePitch(value);
+ }
+
+ void FpsPlayer::rotateRoll(const Vector2& value)
+ {
+ this->roll_ += value.y;
+
+ ControllableEntity::rotateRoll(value);
+ }
+
+ void FpsPlayer::fire()
+ {
+ }
+
+ void FpsPlayer::boost() //acctually jump
+ {
+ if(isfloor) {
+ if(!thistickboost) this->localVelocity_.y = jumpvalue;
+ //this->physicalBody_->applyCentralImpulse(btVector3(0, jumpvalue, 0));
+ thistickboost=true;
+ isfloor=false;
+ }
+ }
+
+ bool FpsPlayer::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ if(contactPoint.m_normalWorldOnB.y() > 0.6) isfloor=true;
+ else isfloor=false;
+
+ return false;
+ }
+
+}
Added: code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h (rev 0)
+++ code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h 2010-05-10 10:58:17 UTC (rev 6867)
@@ -0,0 +1,93 @@
+/*
+ * 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:
+ * Cyrill Frei
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _FpsPlayer_H__
+#define _FpsPlayer_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <LinearMath/btVector3.h>
+#include "util/Math.h"
+#include "Pawn.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport FpsPlayer : public Pawn
+ {
+ public:
+ FpsPlayer(BaseObject* creator);
+ virtual ~FpsPlayer();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+ void registerVariables();
+ void setConfigValues();
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+ virtual void moveUpDown(const Vector2& value);
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+ void boost(); //acctually jump
+
+ virtual void fire();
+
+ bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+ protected:
+ virtual void setPlayer(PlayerInfo* player);
+ virtual void startLocalHumanControl();
+ bool bInvertYAxis_;
+
+ bool bBoost_;
+ bool bPermanentBoost_;
+ Vector3 steering_;
+ float primaryThrust_;
+ float auxilaryThrust_;
+ float rotationThrust_;
+ btVector3 localLinearAcceleration_;
+ btVector3 localAngularAcceleration_;
+
+ private:
+ virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
+ float speed_;
+
+ float yaw_;
+ float pitch_;
+ float roll_;
+ Vector3 localVelocity_;
+ bool isfloor;
+ bool thistickboost;
+ };
+}
+
+#endif /* _FpsPlayer_H__ */
More information about the Orxonox-commit
mailing list