Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2014, 12:49:15 PM (10 years ago)
Author:
maxima
Message:

Geaenderte Turret Klassen hinzugefuegt. Neues Template towerturret. Dort wurde an den TDTower ein Turret attached. So schiesst der Tower nun auf die Enemies.

Location:
code/branches/towerdefenseHS14
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseHS14/data/levels/includes/weaponSettingsTurret.oxi

    r9664 r10144  
    1111        </links>
    1212        <Weapon>
    13           <attached>
    14             <Model mesh="sphere.mesh" position="3,3,-2.2" scale=0.6 />
    15           </attached>
    16           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3, 3,-2.2" />
    17           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 3,-3,-2.2" />
    18           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3, 3,-2.2" />
    19           <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-3,-3,-2.2" />
     13          <!-- <attached>
     14            <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 />
     15          </attached> -->
     16          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" />
     17          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" />
     18          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" />
     19          <HsW01 mode=0 munitionpershot=0 delay=0 damage=1 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" />
    2020        </Weapon>
    2121      </WeaponPack>
  • code/branches/towerdefenseHS14/data/levels/templates/enemytowerdefense.oxt

    r10134 r10144  
    77   explosionchunks        = 6
    88
    9    health            = 100
    10    maxhealth         = 200
    11    initialhealth     = 100
     9   health            = 1
     10   maxhealth         = 2
     11   initialhealth     = 1
    1212
    1313   shieldhealth        = 30
  • code/branches/towerdefenseHS14/data/levels/templates/tower.oxt

    r10142 r10144  
    2626        <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
    2727       
    28         <Turret position="0,0,-100" collisionType="dynamic" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=2000 minAttackRadius=30>
    2928       
    30                 <collisionShapes>
    31                         <SphereCollisionShape radius="10"   position = "0,0,0"/>
    32                 </collisionShapes>
    33                 <controller>
    34                         <TurretController/>
    35                 </controller>
    36                 <?lua
    37                         include("../includes/weaponSettingsTurret.oxi")
    38                 ?>
    39         </Turret>
    4029    </attached>
    4130
     
    5039</Template>
    5140
     41
     42
     43<Template name=towerturret>
     44  <TowerDefenseTower
     45
     46
     47   explosionchunks        = 6
     48
     49   reloadrate          = 3
     50   reloadwaittime      = 1
     51
     52   collisionType     = "dynamic"
     53   team = 1
     54
     55
     56  >
     57  <attached>
     58
     59    <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
     60    <Turret collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
     61
     62      <controller>
     63        <TurretController/>
     64      </controller>
     65      <?lua
     66        include("../includes/weaponSettingsTurret.oxi")
     67      ?>
     68    </Turret>
     69  </attached>
     70   
     71
     72
     73
     74    <!--collisionShapes>
     75
     76    </collisionShapes-->
     77
     78<?lua
     79  include("../includes/towerWeaponSettings.oxi")
     80?>
     81  </TowerDefenseTower>
     82</Template>
  • code/branches/towerdefenseHS14/data/levels/towerDefense.oxw

    r10141 r10144  
    2222  include("templates/tower.oxt")
    2323  include("templates/enemytowerdefense.oxt")
     24  include("templates/standardTurret.oxt")
    2425?>
    2526
    2627<!-- Specify the position of the camera -->
    2728<Template name=centerpointmarkcamera defaults=0>
    28   <Pawn>
     29  <Pawn team=1>
    2930    <camerapositions>
    3031      <CameraPosition position="0,0,1500"/>
     
    3536<!-- Loads a mesh to mark the center-->
    3637<Template name=centerpointmark>
    37   <Pawn camerapositiontemplate=centerpointmarkcamera>
     38  <Pawn team=1 camerapositiontemplate=centerpointmarkcamera>
    3839    <attached>
    3940      <Model position="0,0,0" mesh="cylinder.mesh" scale3D="1,1,1" /> <!-- the camera is attached to this -->
     
    7172
    7273    <!-- Spawns the camera, attached to a crate -->
    73     <SpawnPoint team=0 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
     74    <SpawnPoint team=1 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
    7475    <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    7576
     
    8182
    8283    <!--invisible entity to attach towers to, since playfield is static and towers are dynamic-->
    83     <StaticEntity position=0,0,0>
     84    <StaticEntity team =1 position=0,0,0>
    8485
    8586        <attached>
     
    118119    collisionType=dynamic
    119120    mass=100000
     121    team=1
    120122    />
    121123
  • code/branches/towerdefenseHS14/data/levels/turretTest.oxw

    r9939 r10144  
    33<LevelInfo
    44 name = "turret Test"
    5  description = "A level with a turret in it."
     5 description = "A level to test turrets with."
    66 tags = "test"
    77 screenshot = "emptylevel.png"
     
    1616<?lua
    1717  include("templates/spaceshipAssff.oxt")
    18   include("templates/spaceshipPirate.oxt")
    19   include("templates/spaceshipTurret.oxt")
     18  include("templates/standardTurret.oxt")
    2019?>
    2120
     
    3332    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    3433
     34<SpaceShip position = "0,0,800" collisionType="dynamic" team=10>
     35  <controller>
     36    <TeamTargetProxy team=10/>
     37  </controller>
     38  <attached>
     39    <Model position="0,0,0" mesh="plane.mesh" scale3D="20,20,20" pitch=-90/>
    3540
    36 <StaticEntity position="0,0,0" yaw=0 pitch=0>
    37     <attached>
    38         <Model position="0,0,0" mesh="turretSocketFront.mesh" scale3D="10,10,10" />
    39         <Model position="0,0,0" mesh="turretSocketIn.mesh" scale3D="10,10,10" />
    40         <Model position="0,0,0" mesh="turretSocketTop.mesh" scale3D="10,10,10" />
    41         <Model position="0,0,0" mesh="turretSocketLeft.mesh" scale3D="10,10,10" />
    42         <Model position="0,0,0" mesh="turretSocketRight.mesh" scale3D="10,10,10" />
    43     </attached>
    44 </StaticEntity>
     41    <?lua for i = 1, 10, 1 do ?>
     42      <Turret position="<?lua print(150-i*30) ?>,<?lua print(150-i*30) ?>,0" pitch="0" yaw="0" roll="0">
     43        <templates>
     44          <Template link=standardturret />
     45        </templates>
     46      </Turret>
     47    <?lua end ?>
    4548
    46 
    47 
    48 <Turret position="0,10,0" pitch="90" yaw="0" roll="0">
    49     <templates>
    50         <Template link=spaceshipturret />
    51     </templates>
    52     <controller>
    53         <WaypointPatrolController alertnessradius=100 team=10>
    54         </WaypointPatrolController>
    55      </controller>
    56 </Turret>
    57 
    58 
    59 
     49  </attached>
     50  <collisionShapes>
     51    <BoxCollisionShape radius="10"   position="0,0,0" halfExtents="200, 200, 0"/>
     52  </collisionShapes>
     53</SpaceShip>
    6054   
    6155  </Scene>
  • code/branches/towerdefenseHS14/src/libraries/core/input/InputManager.cc

    r9667 r10144  
    175175
    176176        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    177         {
     177        {   // HACK MARTIN for debugging, changed values here to true
    178178            if (CommandLineParser::getValue("keyboard_no_grab").get<bool>())
    179179                paramList.insert(StringPair("x11_keyboard_grab", "false"));
    180180            else
    181                 paramList.insert(StringPair("x11_keyboard_grab", "true"));
    182             paramList.insert(StringPair("x11_mouse_grab",  "true"));
    183             paramList.insert(StringPair("x11_mouse_hide", "true"));
     181                paramList.insert(StringPair("x11_keyboard_grab", "false"));
     182            paramList.insert(StringPair("x11_mouse_grab",  "false"));
     183            paramList.insert(StringPair("x11_mouse_hide", "false"));
    184184        }
    185185        else
  • code/branches/towerdefenseHS14/src/modules/objects/CMakeLists.txt

    r9526 r10144  
    1111ADD_SUBDIRECTORY(eventsystem)
    1212ADD_SUBDIRECTORY(triggers)
     13ADD_SUBDIRECTORY(controllers)
    1314
    1415ORXONOX_ADD_LIBRARY(objects
  • code/branches/towerdefenseHS14/src/modules/objects/Turret.cc

    r9945 r10144  
    2121 *
    2222 *   Author:
    23  *      Marian Runo
     23 *      Marian Runo, Martin Mueller
    2424 *   Co-authors:
    2525 *      ...
     
    2929#include "Turret.h"
    3030#include "core/CoreIncludes.h"
    31 #include "OgreQuaternion.h"
    3231#include "core/XMLPort.h"
    33 #include "controllers/WaypointPatrolController.h"
     32#include "Scene.h"
     33#include <OgreSceneManager.h>
     34
    3435
    3536namespace orxonox
     
    3738    RegisterClass(Turret);
    3839
    39     /**
    40      * @brief Constructor
     40
     41
     42    /**
     43        @brief
     44        Sets default values for all variables. Also hides the turret from the radar.
     45
     46        @param context
     47        The context
    4148     */
    42     Turret::Turret(Context* context) : SpaceShip(context)
     49    Turret::Turret(Context* context) : Pawn(context)
    4350    {
    4451        RegisterObject(Turret);
    45         this->controller_ = new WaypointPatrolController(this->getContext());
    46     }
    47 
    48     /**
    49      * @brief Destructor
     52        this->rotationThrust_ = 50;
     53        this->startDir_ = Vector3::ZERO;
     54        this->localZ_ = Vector3::UNIT_Z;
     55        this->localY_ = Vector3::UNIT_Y;
     56        this->localX_ = Vector3::UNIT_X;
     57        this->maxAttackRadius_ = 200;
     58        this->minAttackRadius_ = 0;
     59        this->maxPitch_ = 90;
     60        this->maxYaw_ = 90;
     61        this->once_ = false;
     62        this->rotation_ = Quaternion::IDENTITY;
     63
     64        this->setRadarVisibility(false);
     65
     66        //this->rayTest_ = this->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
     67    }
     68
     69    /**
     70        @brief
     71        Destructor. Destroys the rayTest_ element (if it was used)  .
    5072     */
    5173    Turret::~Turret()
    5274    {
    53 
    54     }
    55 
    56 
     75        //this->getScene()->getSceneManager()->destroyQuery(this->rayTest_);
     76    }
     77
     78    /**
     79        @brief
     80        Checks, if a WorldEntity is inside the turret's range.
     81
     82        This function is safe to use on turrets that are attached, rotated, etc.
     83        The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius.
     84
     85        @param target
     86        The WorldEntity to check
     87
     88        @return
     89        The squared distance to the position. -1, if it's ouside of range
     90    */
     91    float Turret::isInRange(const WorldEntity* target )
     92    {
     93        //Check distance
     94        Vector3 distance = target->getWorldPosition() - this->getWorldPosition();
     95        float distanceVal = distance.squaredLength();
     96        if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_))
     97        {
     98            return -1.f;
     99        }
     100
     101        //Check pitch
     102        Vector3 dir = getTransformedVector(distance, this->localX_, this->localY_, this->localZ_);
     103        Vector3 dirProjected = dir;
     104        dirProjected.x = 0;
     105        Vector3 startDirProjected = this->startDir_;
     106        startDirProjected.x = 0;
     107        Ogre::Real angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
     108        if(angle > this->maxPitch_)
     109        {
     110            return -1.f;
     111        }
     112
     113        //Check yaw
     114        dirProjected = dir;
     115        dirProjected.y = 0;
     116        startDirProjected = this->startDir_;
     117        startDirProjected.y = 0;
     118        angle = startDirProjected.angleBetween(dirProjected).valueDegrees();
     119        if(angle > this->maxYaw_)
     120        {
     121            return -1.f;
     122        }
     123
     124        //TODO: Finish this. Find a way to convert objects from Ogre to Orxonox
     125        /*Ogre::Ray ray = Ogre::Ray(this->getWorldPosition(), distance);
     126        this->rayTest_->setRay(ray);
     127        Ogre::RaySceneQueryResult result = this->rayTest_->execute();*/
     128
     129
     130        return distanceVal;
     131    }
     132
     133    /**
     134        @brief
     135        Rotates the turret to make it aim at a certain position.
     136
     137        @note
     138        There are no checks, if the position is valid (i.e. if the turret is allowed to aim there).
     139        This function must be called again for every tick, or the turret will stop rotating.
     140
     141        @param position
     142        The position to aim at
     143    */
     144    void Turret::aimAtPosition(const Vector3& position)
     145    {
     146        Vector3 currDir = this->getWorldOrientation() * WorldEntity::FRONT;
     147        Vector3 targetDir = position - this->getWorldPosition();
     148
     149        this->rotation_ = currDir.getRotationTo(targetDir);
     150    }
     151
     152    /**
     153        @brief
     154        Does currently nothing.
     155
     156        Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation.
     157    */
    57158    void Turret::rotatePitch(const Vector2& value)
    58     {
    59         orxout()<< "Turret rotate Pitch"<< endl;
    60 
    61         const Quaternion& orient = this->getOrientation();
    62         Radian pitch = orient.getPitch();
    63 
    64         if((value.x > 0 && pitch < Radian(180)) || (value.x < 0 && pitch > Radian(0)))
    65             SpaceShip::rotatePitch(value);
    66     }
    67 
    68 
    69     void Turret::setAlertnessRadius(float value)
    70     {
    71         this->controller_->setAlertnessRadius(value);
    72     }
    73     float Turret::getAlertnessRadius()
    74     {
    75         return this->controller_->getAlertnessRadius();
    76     }
    77 
     159    {   
     160        //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
     161        /*
     162        Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     163        Vector3 currentDirProjected = currentDir;
     164        currentDirProjected.x = 0;
     165        Vector3 startDirProjected = this->startDir_;
     166        startDirProjected.x = 0;     
     167        Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
     168        //orxout() << "Pitch: " << angle << endl;   
     169        //if(angle < this->maxPitch_ || (currentDirProjected.y <= 0 && value.x > 0) || (currentDirProjected.y > 0 && value.x < 0) )
     170        {
     171            this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
     172        }
     173        */
     174    }
     175
     176    /**
     177        @brief
     178        Does currently nothing.
     179
     180        Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation.
     181    */
     182    void Turret::rotateYaw(const Vector2& value)
     183    {
     184        //This is a failed attempt at limiting the turret's rotation. It's handled in the controller (for now?)
     185        /*
     186        Vector3 currentDir = getTransformedVector(this->getOrientation() * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     187        Vector3 currentDirProjected = currentDir;
     188        currentDirProjected.y = 0;
     189        Vector3 startDirProjected = this->startDir_;
     190        startDirProjected.y = 0;
     191        Ogre::Real angle = startDirProjected.angleBetween(currentDirProjected).valueDegrees();
     192        orxout() << "Yaw: " << angle << endl;
     193        if(angle < this->maxYaw_ || (currentDirProjected.x <= 0 && value.x < 0) || (currentDirProjected.x > 0 && value.x > 0))
     194        {
     195            this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x*0.8f);
     196        }
     197        */
     198    }
     199
     200    /**
     201        @brief
     202        Does currently nothing.
     203
     204        May be used to limit turret's rotation in the future.
     205    */
     206    void Turret::rotateRoll(const Vector2& value)
     207    {
     208    }
     209
     210    /**
     211        @brief
     212        Loads parameters from xml
     213
     214        Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch
     215    */
    78216    void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    79217    {
    80218        SUPER(Turret, XMLPort, xmlelement, mode);
    81         XMLPortParam(Turret, "alertnessRadius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues("400");
    82     }
    83 
    84 
     219       
     220        XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode);
     221        XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode);
     222        XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode);
     223        XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
     224        XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
     225    }
     226
     227    /**
     228        @brief
     229        The turret's actions are done here.
     230
     231        Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation.
     232   
     233        @param dt
     234        Duration of the tick
     235    */
     236    void Turret::tick(float dt)
     237    {
     238        SUPER(Turret, tick, dt);
     239
     240        //Stuff isn't properly initialized in the c'tor, so we have to do it like this
     241        if(!this->once_)
     242        {
     243            //Account for rotations done in xml
     244            Quaternion startOrient = this->getOrientation();
     245            this->localXStart_ = startOrient * this->localX_;
     246            this->localXStart_.normalise();
     247            this->localX_ = this->localXStart_;
     248            this->localYStart_ = startOrient * this->localY_;
     249            this->localYStart_.normalise();
     250            this->localY_ = this->localYStart_;
     251            this->localZStart_ = startOrient * this->localZ_;
     252            this->localZStart_.normalise();
     253            this->localZ_ = this->localZStart_;
     254
     255            //startDir should always be (0,0,-1)
     256            this->startDir_ = getTransformedVector(startOrient * WorldEntity::FRONT, this->localX_, this->localY_, this->localZ_);
     257
     258            this->once_ = true;
     259
     260        }
     261
     262        //Adjust local axes to parent's rotation
     263        WorldEntity* parent = this->getParent();
     264        if(parent)
     265        {
     266            Quaternion parentrot = parent->getWorldOrientation();
     267            this->localX_ = parentrot * this->localXStart_;
     268            this->localY_ = parentrot * this->localYStart_;
     269            this->localZ_ = parentrot * this->localZStart_;
     270        }
     271
     272        //rotate
     273        if(this->rotation_ != Quaternion::IDENTITY)
     274        {
     275            //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great...
     276            //TODO: make the rotation better (constant velocity etc.). At the moment, the turret rotates
     277            //slower the closer it is to the destination
     278            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
     279            this->rotate(drot, WorldEntity::World);
     280            this->rotation_ = Quaternion::IDENTITY;
     281        }
     282
     283    }
    85284}
  • code/branches/towerdefenseHS14/src/modules/objects/Turret.h

    r9667 r10144  
    2121 *
    2222 *   Author:
    23  *      Marian Runo
     23 *      Marian Runo, Martin Mueller
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file Turret.h
    3130    @brief Definition of the Turret class.
    3231    @ingroup Objects
     
    3736
    3837#include "objects/ObjectsPrereqs.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
     38#include "worldentities/pawns/Pawn.h"
     39#include <OgreSceneQuery.h>
    4140
    4241namespace orxonox
    4342{
    44     class _ObjectsExport Turret : public SpaceShip
     43    /**
     44    @brief
     45        Creates a turret with limited rotation. The point of this class is to be able to attach
     46        a turret to a spaceship or a spacestation which is more or less completely autonomous in
     47        it's behaviour.
     48
     49        This class also contains a custom local coordinate system, which gets initially rotated through xml, and
     50        afterwards is updated with the parent's rotation (if there is one). This allows for almost trivialal calculation
     51        of pitch, yaw and roll through coordinate transformation. (TODO: Ogre should do something like this already, investigate...)
     52       
     53
     54    @note
     55        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
     56    */
     57    class _ObjectsExport Turret : public Pawn
    4558    {
    4659        public:
     
    4861            virtual ~Turret();
    4962
    50             //virtual void tick(float dt);
    51 
    5263            virtual void rotatePitch(const Vector2& value);
    53 
    54             void setAlertnessRadius(float value);
    55             float getAlertnessRadius();
     64            virtual void rotateYaw(const Vector2& value);
     65            virtual void rotateRoll(const Vector2& value);
     66            virtual float isInRange(const WorldEntity* target);
     67            virtual void aimAtPosition(const Vector3 &position);
    5668
    5769            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     70            virtual void tick(float dt);
    5871
     72            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
     73            inline void setMaxAttackRadius(float radius)
     74                { this->maxAttackRadius_ = radius; }
     75
     76            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
     77            inline void setMinAttackRadius(float radius)
     78                { this->minAttackRadius_ = radius; }
     79
     80            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
     81            inline void setMaxPitch(float pitch)
     82                { this->maxPitch_ = pitch; }
     83
     84            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
     85            inline void setMaxYaw(float yaw)
     86                { this->maxYaw_ = yaw; }
     87
     88            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
     89            inline float getMaxAttackRadius() const
     90                { return this->maxAttackRadius_; }               
     91
     92            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
     93            inline float getMinAttackRadius() const
     94                { return this->minAttackRadius_; }   
     95
     96            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
     97            inline float getMaxPitch() const
     98                { return this->maxPitch_; }
     99
     100            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
     101            inline float getMaxYaw() const
     102                { return this->maxYaw_; }
    59103
    60104        protected:
    61             WaypointPatrolController* controller_;
     105            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
     106            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
     107            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
     108            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.     
     109            Quaternion rotation_; //!< The rotation to be done by the turret.
     110
    62111        private:
     112            bool once_; //!< Flag for executing code in the tick function only once.
     113
     114            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
     115            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
     116            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
     117            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
     118            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
     119            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
     120            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
     121            float rotationThrust_;  //!< The velocity the turret rotates with.
     122            Ogre::RaySceneQuery* rayTest_; //!< Used to perform a raytest, currently unused @see isInRange
    63123
    64124    };
     
    66126
    67127#endif
    68 
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc

    r10142 r10144  
    158158        for (int i = 0; i < kInitialTowerCount; i++)
    159159        {
    160             addTower(i+4,(i+5));
     160            addTower(i+4,i+5);
    161161        }
    162162
     
    277277  //    Create tower
    278278        TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext());
    279         towernew->addTemplate("tower");
     279        towernew->addTemplate("towerturret");
    280280        towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
    281281        towernew->setGame(this);
  • code/branches/towerdefenseHS14/src/orxonox/controllers/ArtificialController.cc

    r9667 r10144  
    9494        static const float hardcoded_projectile_speed = 1250;
    9595
    96         this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
     96        this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(), hardcoded_projectile_speed, this->target_->getWorldPosition(), this->target_->getVelocity());
    9797        this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
    9898
  • code/branches/towerdefenseHS14/src/orxonox/worldentities/WorldEntity.cc

    r9667 r10144  
    414414            else if (this->isDynamic())
    415415            {
    416                 orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
    417                 return false;
     416                //***HACKY HACK (to allow turrets to be attached)***
     417                //orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
     418                //return false;
    418419            }
    419420            else if (this->isKinematic() && newParent->isDynamic())
Note: See TracChangeset for help on using the changeset viewer.