[Orxonox-commit 5358] r10021 - in code/branches/turretFS14: data/levels/templates src/modules/objects
muemart at orxonox.net
muemart at orxonox.net
Thu Apr 3 16:04:32 CEST 2014
Author: muemart
Date: 2014-04-03 16:04:32 +0200 (Thu, 03 Apr 2014)
New Revision: 10021
Modified:
code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
code/branches/turretFS14/src/modules/objects/Turret.cc
code/branches/turretFS14/src/modules/objects/Turret.h
Log:
Turret: Move the turret up in the hierarchy, edit the template accordingly
Modified: code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt
===================================================================
--- code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt 2014-04-03 13:59:48 UTC (rev 10020)
+++ code/branches/turretFS14/data/levels/templates/spaceshipTurretTest.oxt 2014-04-03 14:04:32 UTC (rev 10021)
@@ -1,52 +1,15 @@
<Template name=spaceshipturrettest>
- <SpaceShip
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipturretcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
-
- health = 100
- maxhealth = 200
- initialhealth = 100
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8
- reloadrate = 1
- reloadwaittime = 1
-
- primaryThrust = 100
- auxilaryThrust = 30
- rotationThrust = 50
-
- lift = 1;
- stallSpeed = 220;
-
- boostPower = 15
- boostPowerRate = 1
- boostRate = 5
- boostCooldownDuration = 10
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
- >
+ <Turret position="0,0,0" collisionType="dynamic" angularDamping=0.999999 mass=100>
<attached>
<Model position="0,0,0" pitch="90" roll="0" mesh="turretHead.mesh" scale3D="10,10,10"/>
</attached>
<collisionShapes>
<SphereCollisionShape radius="10" position = "0,0,0"/>
</collisionShapes>
+ </Turret>
<?lua
include("../includes/weaponSettingsTurretTest.oxi")
?>
- </SpaceShip>
</Template>
<Template name=spaceshipturretcameras defaults=0>
Modified: code/branches/turretFS14/src/modules/objects/Turret.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.cc 2014-04-03 13:59:48 UTC (rev 10020)
+++ code/branches/turretFS14/src/modules/objects/Turret.cc 2014-04-03 14:04:32 UTC (rev 10021)
@@ -28,9 +28,8 @@
#include "Turret.h"
#include "core/CoreIncludes.h"
-#include "OgreQuaternion.h"
#include "core/XMLPort.h"
-#include "controllers/WaypointPatrolController.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
namespace orxonox
{
@@ -41,13 +40,16 @@
/**
* @brief Constructor
*/
- Turret::Turret(Context* context) : SpaceShip(context)
+ Turret::Turret(Context* context) : Pawn(context)
{
RegisterObject(Turret);
this->startOrientInv_ = Quaternion::IDENTITY;
this->maxPitch_ = 0;
this->maxYaw_ = 0;
this->gotOrient_ = false;
+ this->rotationThrust_ = 50;
+
+ this->localAngularAcceleration_.setValue(0, 0, 0);
}
/**
@@ -67,8 +69,8 @@
}
if (this->maxPitch_ >= 180) //no need to check, if the limit too big
{
- SpaceShip::rotatePitch(value);
- return;
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
+ return;
}
Quaternion drot = startOrientInv_ * this->getOrientation();
@@ -91,7 +93,7 @@
}
if ((val >= lowerBound || value.x > 0) && (val <= upperBound || value.x < 0))
{
- SpaceShip::rotatePitch(value);
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
}
return;
}
@@ -104,8 +106,8 @@
}
if (this->maxPitch_ >= 180) //no need to check, if the limit too big
{
- SpaceShip::rotateYaw(value);
- return;
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
+ return;
}
Quaternion drot = startOrientInv_ * this->getOrientation();
@@ -128,7 +130,7 @@
}
if ((val >= lowerBound || value.x > 0) && (val <= upperBound || value.x < 0))
{
- SpaceShip::rotateYaw(value);
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
}
return;
}
@@ -147,6 +149,8 @@
void Turret::tick(float dt)
{
+ SUPER(Turret, tick, dt);
+
if(!gotOrient_)
{
startOrientInv_ = this->getOrientation().Inverse();
@@ -154,7 +158,10 @@
}
Quaternion drot = startOrientInv_ * this->getOrientation();
orxout() << "Pitch: " << drot.getPitch(false).valueDegrees() << "\tYaw: " << drot.getYaw(false).valueDegrees() << "\tRoll: " << drot.getRoll(false).valueDegrees() << endl;
- SUPER(Turret, tick, dt);
+
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
}
Modified: code/branches/turretFS14/src/modules/objects/Turret.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.h 2014-04-03 13:59:48 UTC (rev 10020)
+++ code/branches/turretFS14/src/modules/objects/Turret.h 2014-04-03 14:04:32 UTC (rev 10021)
@@ -39,11 +39,10 @@
#include "OgreQuaternion.h"
#include "worldentities/pawns/SpaceShip.h"
-#include "controllers/TurretController.h"
namespace orxonox
{
- class _ObjectsExport Turret : public SpaceShip
+ class _ObjectsExport Turret : public Pawn
{
public:
Turret(Context* context);
@@ -73,7 +72,10 @@
Ogre::Real maxPitch_;
Ogre::Real maxYaw_;
Quaternion startOrientInv_;
+ float rotationThrust_;
+ btVector3 localAngularAcceleration_;
+
Ogre::Real boundBetween(float val, float lowerBound, float upperBound);
};
}
More information about the Orxonox-commit
mailing list