[Orxonox-commit 2337] r7052 - in code/branches/fps: data/levels data/levels/includes data/levels/templates src/orxonox/worldentities/pawns
freicy at orxonox.net
freicy at orxonox.net
Mon May 31 15:40:41 CEST 2010
Author: freicy
Date: 2010-05-31 15:40:41 +0200 (Mon, 31 May 2010)
New Revision: 7052
Modified:
code/branches/fps/data/levels/includes/weaponsettings_fps.oxi
code/branches/fps/data/levels/presentation_FS10.oxw
code/branches/fps/data/levels/templates/fps.oxt
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h
code/branches/fps/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/fps/src/orxonox/worldentities/pawns/Pawn.h
Log:
by Cyrill Frei
Modified: code/branches/fps/data/levels/includes/weaponsettings_fps.oxi
===================================================================
--- code/branches/fps/data/levels/includes/weaponsettings_fps.oxi 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/data/levels/includes/weaponsettings_fps.oxi 2010-05-31 13:40:41 UTC (rev 7052)
@@ -1,6 +1,7 @@
<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,0" yaw=0 pitch=0 roll=0 />
+ <!-- <WeaponSlot position="-0.5,0.8,2.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>
@@ -15,15 +16,8 @@
<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" />
+ <HsW01 mode=0 munitionpershot=0 delay=0.0 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5, -4" />
+ <LightningGun mode=1 muzzleoffset="0,0,0" />
</Weapon>
<LaserGun
position="0,0,0"
Modified: code/branches/fps/data/levels/presentation_FS10.oxw
===================================================================
--- code/branches/fps/data/levels/presentation_FS10.oxw 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/data/levels/presentation_FS10.oxw 2010-05-31 13:40:41 UTC (rev 7052)
@@ -22,7 +22,7 @@
<Pawn health=100 position="600,35,0" direction="0,-1,0" collisionType=dynamic mass=100000>
<attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="5,5,5" />
+ <Model position="0,0,0" mesh="fish.mesh" scale3D="5,5,5" />
</attached>
<collisionShapes>
<BoxCollisionShape position="0,0,0" halfExtents="25,25,25" />
@@ -82,6 +82,7 @@
<BoxCollisionShape position="0,0,0" halfExtents="100,100,10" />
</collisionShapes>
</StaticEntity>
+
<?lua
for i = 1, 10, 1
do ?>
@@ -90,24 +91,6 @@
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>
\ No newline at end of file
Modified: code/branches/fps/data/levels/templates/fps.oxt
===================================================================
--- code/branches/fps/data/levels/templates/fps.oxt 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/data/levels/templates/fps.oxt 2010-05-31 13:40:41 UTC (rev 7052)
@@ -1,8 +1,7 @@
<Template name=fps>
<FpsPlayer
hudtemplate = fpshud
- camerapositiontemplate = fpscamera
-
+
spawnparticlesource = "Orxonox/fairytwirl"
spawnparticleduration = 3
explosionchunks = 6
@@ -20,42 +19,37 @@
linearDamping = 0.7
angularDamping = 0.9999999
friction = 0.01
+
+ weapon = "hs-w01.mesh"
>
- <!-- <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="7,7,7" />
- <!--
- <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" />
- -->
+ <BoxCollisionShape position="0,0,0" halfExtents="8,20,8" />
</collisionShapes>
+
+ <camerapositions>
+ <CameraPosition position="-0.5,0.8,2.5" drag=false mouselook=true />
+ </camerapositions>
+
+ <?lua
+ include("includes/weaponsettings_fps.oxi")
+ ?>
-<?lua
- include("includes/weaponsettings_fps.oxi")
-?>
</FpsPlayer>
</Template>
-
+<!--
<Template name=fpscamera defaults=0>
<FpsPlayer>
<camerapositions>
<CameraPosition position="0,0,20" drag=false mouselook=true />
- <!--CameraPosition position="0,150,-25" pitch=-90 drag=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 /-->
+ <CameraPosition position="50,5,-8" yaw=90 drag=true /
+
</camerapositions>
</FpsPlayer>
</Template>
+-->
\ No newline at end of file
Modified: code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.cc 2010-05-31 13:40:41 UTC (rev 7052)
@@ -32,13 +32,19 @@
#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btVector3.h>
#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
-
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/Template.h"
#include "core/XMLPort.h"
#include "items/Engine.h"
+#include "Scene.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/Weapon.h"
#include <cmath>
@@ -79,10 +85,16 @@
this->setConfigValues();
this->registerVariables();
+ this->weaponNode = this->cameraPositionRootNode_;
+ //this->weaponNode = this->getScene()->getRootSceneNode()->createChildSceneNode();
+ //this->weaponNode = this->cameraPositionRootNode_->createChildSceneNode();
+ this->attachNode(this->weaponNode);
}
FpsPlayer::~FpsPlayer()
{
+ if (this->isInitialized() && this->mesh_.getEntity())
+ this->detachOgreObject(this->mesh_.getEntity());
}
void FpsPlayer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -92,6 +104,7 @@
XMLPortParamVariable(FpsPlayer, "primaryThrust", primaryThrust_, xmlelement, mode);
XMLPortParamVariable(FpsPlayer, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
XMLPortParamVariable(FpsPlayer, "rotationThrust", rotationThrust_, xmlelement, mode);
+ XMLPortParam(FpsPlayer, "weapon", setMeshSource, getMeshSource, xmlelement, mode);
}
void FpsPlayer::registerVariables()
@@ -99,7 +112,10 @@
registerVariable(this->primaryThrust_, VariableDirection::ToClient);
registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+ registerVariable(this->weaponmashname);
}
+
+
void FpsPlayer::setConfigValues()
{
@@ -144,22 +160,36 @@
if (!this->isInMouseLook())
{
- this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()),WorldEntity::Parent);
- //this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()), WorldEntity::Parent);
+
Radian pitch=this->cameraPositionRootNode_->getOrientation().getPitch();
- if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ if( pitch<Radian(1.5707) && pitch>Radian(-1.5707) ) {
+ //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ }
else if(pitch<Radian(-1.5707)){
- if(this->pitch_>0.0) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
- else if(pitch<Radian(-1.571)) this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796));
+ if(this->pitch_>0.0) {
+ //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ }
+ else if(pitch<Radian(-1.571)){
+ //this->weaponNode->pitch(-pitch+Radian(-1.570796));
+ this->cameraPositionRootNode_->pitch(-pitch+Radian(-1.570796));
+ }
}
else if(pitch>Radian(1.5707)){
- if(this->pitch_<0.0) this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
- else if(pitch>Radian(1.571)) this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796));
+ if(this->pitch_<0.0) {
+ //this->weaponNode->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ this->cameraPositionRootNode_->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
+ }
+ else if(pitch>Radian(1.571)){
+ //this->weaponNode->pitch(-pitch+Radian(1.570796));
+ this->cameraPositionRootNode_->pitch(-pitch+Radian(1.570796));
+ }
}
-
+ //this->weaponNode->setOrientation(this->cameraPositionRootNode_->getOrientation());
- // this->roll(Radian(this->roll_ * this->getMouseLookSpeed()));
- }
+ }
this->yaw_ = this->pitch_ = this->roll_ = 0;
@@ -171,7 +201,23 @@
SUPER(FpsPlayer, tick, dt);
}
+
+ void FpsPlayer::changedMesh()
+ {
+ if (GameMode::showsGraphics())
+ {
+ if (this->mesh_.getEntity())
+ this->weaponNode->detachObject(this->mesh_.getEntity());
+ this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
+
+ if (this->mesh_.getEntity())
+ {
+ this->weaponNode->attachObject(this->mesh_.getEntity());
+ }
+ }
+ }
+
void FpsPlayer::setPlayer(PlayerInfo* player)
{
ControllableEntity::setPlayer(player);
@@ -243,4 +289,17 @@
return false;
}
+ void FpsPlayer::addedWeaponPack(WeaponPack* wPack)
+ {
+ for (size_t i = 0; i < wPack->getNumWeapons(); ++i)
+ {
+ Weapon* weapon = wPack->getWeapon(i);
+ if (weapon->getWeaponSlot())
+ {
+ weapon->getWeaponSlot()->removeWeapon();
+ weapon->detachFromParent();
+ weapon->attachToNode(this->weaponNode);
+ }
+ }
+ }
}
Modified: code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/src/orxonox/worldentities/pawns/FpsPlayer.h 2010-05-31 13:40:41 UTC (rev 7052)
@@ -34,6 +34,7 @@
#include <string>
#include <LinearMath/btVector3.h>
#include "util/Math.h"
+#include "tools/Mesh.h"
#include "Pawn.h"
namespace orxonox
@@ -57,11 +58,19 @@
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
+
+ inline void setMeshSource(const std::string& meshname)
+ { this->meshSrc_ = meshname; this->changedMesh(); }
+ inline const std::string& getMeshSource() const
+ { return this->meshSrc_; }
+
void boost(); //acctually jump
virtual void fire();
bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
+
+ virtual void addedWeaponPack(WeaponPack* wPack);
protected:
virtual void setPlayer(PlayerInfo* player);
@@ -74,6 +83,7 @@
float primaryThrust_;
float auxilaryThrust_;
float rotationThrust_;
+ std::string weaponmashname;
btVector3 localLinearAcceleration_;
btVector3 localAngularAcceleration_;
@@ -81,6 +91,9 @@
virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
float speed_;
+ void changedMesh();
+ Mesh mesh_;
+ std::string meshSrc_;
float yaw_;
float pitch_;
float roll_;
@@ -88,6 +101,8 @@
bool isfloor;
bool thistickboost;
Quaternion savedOrientation_;
+ Ogre::SceneNode* weaponNode;
+ Ogre::Camera* camera_;
};
}
Modified: code/branches/fps/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/Pawn.cc 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/src/orxonox/worldentities/pawns/Pawn.cc 2010-05-31 13:40:41 UTC (rev 7052)
@@ -330,14 +330,21 @@
void Pawn::addWeaponPack(WeaponPack * wPack)
{
if (this->weaponSystem_)
+ {
this->weaponSystem_->addWeaponPack(wPack);
+ this->addedWeaponPack(wPack);
+ }
}
void Pawn::addWeaponPackXML(WeaponPack * wPack)
{
if (this->weaponSystem_)
+ {
if (!this->weaponSystem_->addWeaponPack(wPack))
wPack->destroy();
+ else
+ this->addedWeaponPack(wPack);
+ }
}
WeaponPack * Pawn::getWeaponPack(unsigned int index) const
Modified: code/branches/fps/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/fps/src/orxonox/worldentities/pawns/Pawn.h 2010-05-31 13:33:14 UTC (rev 7051)
+++ code/branches/fps/src/orxonox/worldentities/pawns/Pawn.h 2010-05-31 13:40:41 UTC (rev 7052)
@@ -89,6 +89,8 @@
void addWeaponPack(WeaponPack * wPack);
void addWeaponPackXML(WeaponPack * wPack);
WeaponPack * getWeaponPack(unsigned int index) const;
+
+ virtual void addedWeaponPack(WeaponPack* wPack) {}
inline const WorldEntity* getWorldEntity() const
{ return const_cast<Pawn*>(this); }
More information about the Orxonox-commit
mailing list