Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10362 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 25, 2007, 3:05:01 AM (18 years ago)
Author:
patrick
Message:

merged playability. but got strange bug

Location:
branches/playability.new
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • branches/playability.new

    • Property svn:ignore
      •  

        old new  
        1010autom4te.cache
        1111aclocal.m4
         12tags
         13test.bmp
         14config.sub
         15config.guess
         16OrxonoxPlayability.kdevses
         17OrxonoxPlayability.kdevelop.pcs
  • branches/playability.new/ChangeLog

    r9872 r10362  
     12006-12-17 Nicolas Schlumberger <nicolasc@ee.ethz.ch>
     2  Added guiding sysmte for swarm missile
     3  updated drawing function, to draw in the correct direction
     4
     52006-12-16  Marc Schärer <marcscha@ee.ethz.ch>
     6  Addition trail system
     7  Experiment with explosion class on SpaceShip.
     8  Sadly, collision problems still persist. need to be solved until wednesday 2006-12-20
     9
     102006-12-03  Nicolas Schlumberger <nicolasc@ee.ethz.ch>
     11  Added Rotation to hbolt
     12  Did some experimenting with test_entity2 (rotation, texturing)
     13  Added textured versions of bolt, and hbolt
     14
     152006-12-03  Marc Schärer <marcscha@ee.ethz.ch>
     16  Added functionality to show / hide a crosshair to the weapon manager. No default crosshair anymore
     17  Multiple weapons per ship added
     18  Several small tweaks needed to make the above working added
     19  Addition of SwarmMissile and SwarmProjectile
     20
     212006-11-29  Nicolas Schlumbgerger <nicolasc@ee.ethz.ch>
     22  Added bolt projectile for light blaster, copied of laser
     23  Added hbolt projectile for heavy blaster, copied of laser
     24  Added bolt model, currently untextured
     25  Added hbolt model, currently untextured
     26
     272006-11-28      Marc Schärer <marcscha@ee.ethz.ch>
     28        Mapped primary weapon manager back to playable default weapon manager.
     29        Addition of secondary weapon manager for special weapon. Currently uses Cannon to show and test this functionality.
     30        Implementation of weapon energy regeneration. This needed some little modifications to the HUD class as well but now works :)
     31        Addition of the second weapon manager to the HUD manager in util/hud .h .cc for our master of HUD ;-)
     32
    1332006-09-22      Benjamin Grauer <bensch@orxonox.net>
    234        Complete reimplementation of the ResourceManager.
  • branches/playability.new/src/lib/coord/p_node.h

    r9869 r10362  
    9898  inline const Vector& getRelCoor () const { return this->prevRelCoordinate; };
    9999  /** @returns the Relative Coordinate Destination */
    100 inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
     100  inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
    101101  void setAbsCoor (const Vector& absCoord);
    102102  void setAbsCoor (float x, float y, float z);
     
    133133  inline const Quaternion& getRelDir () const { return this->prevRelDirection; };
    134134  /** @returns the Relative Directional Destination */
    135 inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
     135  inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
    136136  /** @returns a Vector pointing into the relative Direction */
    137137  inline Vector getRelDirV() const { return this->prevRelDirection.apply(Vector(0,1,0)); };
  • branches/playability.new/src/lib/graphics/importer/vertex_array_model.cc

    r9869 r10362  
    260260                            ((float)j - (float)resolutionY/2.0)/(float)resolutionY * sizeY);
    261261          this->addNormal(0.0, 1, 0.0);
    262           this->addTexCoor((float)i/(float)resolutionX, (float)j/(float)resolutionY);
     262          this->addTexCoor((float)i/(float)(resolutionY-1), (float)j/(float)(resolutionX-1));
    263263          this->addColor(1.0, 1.0, 1.0);
    264264        }
  • branches/playability.new/src/lib/gui/gl/glgui_bar.cc

    r9869 r10362  
    7171
    7272    this->_value = value;
    73     this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
     73    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
    7474        ,this->getSizeY2D() - borderTop() - borderBottom());
    7575  }
     
    9999
    100100    this->_frontRect.setTopLeft(borderLeft(), borderTop());
    101     this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value -_minimum)/ (_minimum + _maximum)
    102                              ,this->getSizeY2D() - borderTop() - borderBottom());
     101    this->_frontRect.setSize((this->getSizeX2D() - borderLeft() - borderRight()) * (_value - _minimum) / (_maximum -_minimum)
     102        ,this->getSizeY2D() - borderTop() - borderBottom());
    103103
    104104  }
  • branches/playability.new/src/lib/gui/gl/glgui_box.cc

    r9869 r10362  
    1818#include "glgui_box.h"
    1919#include <cassert>
     20#include <iostream>
    2021#include "debug.h"
     22#include "network_log.h"
     23
    2124
    2225namespace OrxGui
     
    177180  void GLGuiBox::resize()
    178181  {
    179     if (orientation() == OrxGui::Vertical)
     182    if (this->orientation() == OrxGui::Vertical)
    180183    {
    181184      float height = borderTop();
     
    186189      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    187190      {
    188         (*widget)->setRelCoor2D(borderLeft(), height);
    189         height += (*widget)->getSizeY2D();
    190         width = fmax(width, (*widget)->getSizeX2D());
     191        //float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
     192        //float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
     193        //float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     194        float realSizeX, realSizeY;
     195        int angleAbs = (int)(*widget)->getAbsDir2D();
     196        int angleRel = (int)(*widget)->getRelDir2D();
     197        //std::cout << "absangle: " << angleAbs << ", relangle: " << angleRel << '\n';
     198        if ((*widget)->getAbsDir2D() == 0 || (*widget)->getAbsDir2D() == 180)
     199        {
     200          realSizeX = (*widget)->getSizeX2D();
     201          realSizeY = (*widget)->getSizeY2D();
     202          //std::cout<<"box vertical, widget 0or180";
     203        }
     204        else if ((*widget)->getAbsDir2D() == 90 || (*widget)->getAbsDir2D() == 270)
     205        {
     206          realSizeX = (*widget)->getSizeY2D();
     207          realSizeY = (*widget)->getSizeX2D();
     208          //std::cout<<"box vertical, widget 90or270";
     209        }
     210
     211        (*widget)->setRelCoor2D(borderLeft(), height + borderTop());
     212        height += realSizeY;
     213        width = fmax(width, realSizeX);
    191214      }
    192215
     
    205228      for (widget = this->_children.begin(); widget != this->_children.end(); ++widget)
    206229      {
     230        //float radDir = (*widget)->getAbsDir2D() * 2 * M_PI / 360;
     231        //std::cout << "size X: " << (*widget)->getSizeX2D() << "size Y: " << (*widget)->getSizeY2D() << '\n';
     232        //float realSizeX = fabsf((*widget)->getSizeX2D() * cosf(radDir)) + fabsf((*widget)->getSizeY2D() * sinf(radDir));
     233        //float realSizeY = fabsf((*widget)->getSizeX2D() * sinf(radDir)) + fabsf((*widget)->getSizeY2D() * cosf(radDir));
     234        float realSizeX, realSizeY;
     235        int angleAbs = (int)(*widget)->getAbsDir2D();
     236        int angleRel = (int)(*widget)->getRelDir2D();
     237        //std::cout << "absangle: " << angleAbs << ", relangle: " << angleRel << '\n';
     238        if ((*widget)->getAbsDir2D() == 0 || (*widget)->getAbsDir2D() == 180)
     239        {
     240          realSizeX = (*widget)->getSizeX2D();
     241          realSizeY = (*widget)->getSizeY2D();
     242          //std::cout<<"box horicontal, widget 0or180";
     243        }
     244        else if ((*widget)->getAbsDir2D() == 90 || (*widget)->getAbsDir2D() == 270)
     245        {
     246          realSizeX = (*widget)->getSizeY2D();
     247          realSizeY = (*widget)->getSizeX2D();
     248          //std::cout<<"box horicontal, widget 90or270";
     249        }
     250
    207251        (*widget)->setRelCoor2D(width, borderTop());
    208         height = fmax(height, (*widget)->getSizeY2D());
    209         width += (*widget)->getSizeX2D();
     252        height = fmax(height, realSizeY);
     253        width += realSizeX;
    210254      }
    211255
  • branches/playability.new/src/lib/gui/gl/glgui_widget.cc

    r10317 r10362  
    915915  }
    916916
     917  void GLGuiWidget::beginDraw() const
     918  {
     919    glPushMatrix();
     920    glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     921    glRotatef(this->getAbsDir2D(), 0, 0, 1);
     922  }
     923
    917924
    918925}
  • branches/playability.new/src/lib/gui/gl/glgui_widget.h

    r9869 r10362  
    244244
    245245    /// RENDERING
    246     inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
     246    void beginDraw() const;
    247247    inline void endDraw() const { glPopMatrix(); };
    248248
  • branches/playability.new/src/lib/math/curve.cc

    r9110 r10362  
    142142    tmpNode = tmpNode->next;
    143143  return tmpNode->position;
     144}
     145
     146/**
     147 * This function returns an approximation of the length of the curve
     148 *
     149*/
     150float Curve::getLength()
     151{
     152      float length = 0;
     153      PathNode* tmpNode = this->firstNode;
     154      for(int i = 1; i < this->nodeCount; i++)
     155      {
     156              length += Vector(tmpNode->next->position - tmpNode->position).len();
     157      }
     158      return length;
    144159}
    145160
     
    273288Vector BezierCurve::calcDir (float t)
    274289{
    275   return this->dirCurve->calcPos(t);
     290  return this->calcPos(t + 0.01) - this->calcPos(t);
     291  //return this->dirCurve->calcPos(t);
    276292}
    277293
  • branches/playability.new/src/lib/math/curve.h

    r6616 r10362  
    4747  /** @returns the directional Curve */
    4848  Curve* getDirCurve() const { return this->dirCurve; };
     49  float getLength();
    4950
    5051  /** @param t the value on the curve [0-1] @returns Vector to the position */
  • branches/playability.new/src/lib/util/loading/fast_factory.cc

    r9869 r10362  
    157157void FastFactory::flush(bool hardFLUSH)
    158158{
     159hardFLUSH = false; // HACK
    159160  FastObjectMember* tmpMember = this->deadList, *delMember = NULL;
    160161  while (tmpMember != NULL)
  • branches/playability.new/src/story_entities/game_world.cc

    r10340 r10362  
    359359      this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
    360360  {
    361     PRINTF(4)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
     361    PRINTF(0)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
    362362  }
    363363  else
    364364  {
    365     PRINTF(2)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
     365    PRINTF(0)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
    366366  }
    367367}
  • branches/playability.new/src/story_entities/menu/game_menu.cc

    r10114 r10362  
    111111
    112112  this->dataTank->localCamera->setRelCoor(this->cameraVector);
     113  //this->dataTank->localCamera->setFovy(60);
    113114
    114115  GraphicsEngine::getInstance()->displayFPS(false);
  • branches/playability.new/src/util/Makefile.am

    r9869 r10362  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/pilot_node.cc
    29 
    30 #                       track/track_manager.cc \
     28                        track/pilot_node.cc \
     29                        track/track.cc \
     30                        track/track_manager.cc \
    3131                        track/track_node.cc
    3232
     
    5252                        animation/t_animation.h \
    5353                        \
    54                         track/pilot_node.h
     54                        track/pilot_node.h \
     55                        track/track.h \
     56                        track/track_manager.h \
     57                        track/track_node.h
    5558
    56 #                       track/track_manager.h \
    57                         track/track_node.h
  • branches/playability.new/src/util/hud.cc

    r9869 r10362  
    2323#include "world_entities/weapons/weapon_manager.h"
    2424#include "glgui_widget.h"
     25#include "glgui_box.h"
     26#include "glgui_bar.h"
     27#include "elements/glgui_energywidgetvertical.h"
    2528
    2629#include "glgui_inputline.h"
    2730#include "specials/glgui_notifier.h"
    2831#include "elements/glgui_radar.h"
     32#include "world_entities/space_ships/space_ship.h"
    2933
    3034
     
    4549  //this->setSize2D(
    4650  this->weaponManager = NULL;
     51  this->weaponManagerSecondary = NULL;
    4752  this->energyWidget = NULL;
    4853  this->shieldWidget = NULL;
    4954  this->armorWidget = NULL;
     55  //this->leftRect = NULL;
     56  //this->rightRect = NULL;
    5057  this->resX = 1;
    5158  this->resY = 1;
     59
     60  this->overlayPercentage = 40;
     61  this->overlayActive = false;
     62  this->rightRect = new OrxGui::GLGuiImage();
     63  this->leftRect = new OrxGui::GLGuiImage();
    5264
    5365  this->inputLine = new OrxGui::GLGuiInputLine();
     
    5870
    5971  this->_radar = new OrxGui::GLGuiRadar();
     72  this->radarCenterNode = NULL;
    6073
    6174  this->subscribeEvent(ES_ALL, EV_VIDEO_RESIZE);
    6275  this->subscribeEvent(ES_ALL, SDLK_TAB);
    6376
    64 
     77  //this->shipValuesBox = NULL;
    6578}
    6679
     
    7588
    7689  delete this->_radar;
     90  delete this->rightRect;
     91  delete this->leftRect;
     92  //if (this->shipValuesBox != NULL)
     93    //delete this->shipValuesBox;
     94
    7795  // delete what has to be deleted here
    7896}
     
    94112void Hud::setEnergyWidget(OrxGui::GLGuiWidget* widget)
    95113{
     114  //if (this->shipValuesBox == NULL)
     115    //this->createShipValuesBox();
     116
    96117  // decopple old widget
    97118  if (this->energyWidget != NULL)
     
    103124  if (this->energyWidget != NULL)
    104125  {
     126    //this->energyWidget->shiftDir2D(270);
     127    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
     128    //this->shipValuesBox->pack(this->energyWidget);
     129    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings();
     130    this->energyWidget->setParent2D(this->leftRect);
    105131    this->energyWidget->show();
    106     this->energyWidget->setBackgroundTexture( "hud_energy_background.png");
    107132    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    108133        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     
    113138
    114139void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
    115 {}
     140{
     141  /*
     142  if (this->shipValuesBox == NULL)
     143    this->createShipValuesBox();
     144  */
     145
     146  // decopple old widget
     147  if (this->shieldWidget != NULL)
     148  {
     149    this->shieldWidget->hide();
     150  }
     151
     152  this->shieldWidget = widget;
     153  if (this->shieldWidget != NULL)
     154  {
     155    //this->shieldWidget->shiftDir2D(270);
     156    //this->shipValuesBox->pack(this->shieldWidget);
     157    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->shieldWidget)->setStandardSettings();
     158    this->shieldWidget->setParent2D(this->leftRect);
     159    this->shieldWidget->show();
     160    /*    this->shieldWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     161        this->shieldWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     162  }
     163  else
     164    printf("schild im hud nicht uebergeben!!!!!!!!!!!!!!!!!!!!!!!!!");
     165
     166  this->updateResolution();
     167}
    116168
    117169void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    118 {}
    119 
    120 void Hud::setWeaponManager(WeaponManager* weaponMan)
    121 {
     170{
     171  /*
     172  if (this->shipValuesBox == NULL)
     173    this->createShipValuesBox();
     174  */
     175
     176// decopple old widget
     177  if (this->armorWidget != NULL)
     178  {
     179    this->armorWidget->hide();
     180  }
     181
     182  this->armorWidget = widget;
     183  if (this->armorWidget != NULL)
     184  {
     185    //this->armorWidget->shiftDir2D(270);
     186    //this->shipValuesBox->pack(this->armorWidget);
     187    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings();
     188    this->armorWidget->setParent2D(this->leftRect);
     189    this->armorWidget->show();
     190    /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     191        this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     192  }
     193
     194  this->updateResolution();
     195}
     196
     197void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec)
     198{
     199  //clearWeaponManager();
     200
     201  //Hide all widgets
    122202  if (this->weaponManager != NULL)
    123203  {
     
    128208      {
    129209        weapon->getEnergyWidget()->hide();
    130         this->weaponsWidgets.remove(weapon->getEnergyWidget());
     210        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    131211      }
    132212    }
    133213  }
    134214
     215  if (this->weaponManagerSecondary != NULL)
     216  {
     217    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
     218    {
     219      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
     220      if (weapon != NULL)
     221      {
     222        weapon->getEnergyWidget()->hide();
     223        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     224      }
     225    }
     226  }
     227
    135228  this->weaponManager = weaponMan;
     229  this->weaponManagerSecondary = weaponManSec;
    136230
    137231  this->updateWeaponManager();
     
    139233}
    140234
     235/*
     236void Hud::clearWeaponManager()
     237{
     238  //Hide all widgets
     239  if (this->weaponManager != NULL)
     240  {
     241    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
     242    {
     243      Weapon* weapon = this->weaponManager->getWeapon(i);
     244      if (weapon != NULL)
     245      {
     246        weapon->getEnergyWidget()->hide();
     247        //this->weaponsWidgetsPrim.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     248      }
     249    }
     250  }
     251
     252  if (this->weaponManagerSecondary != NULL)
     253  {
     254    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
     255    {
     256      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
     257      if (weapon != NULL)
     258      {
     259        weapon->getEnergyWidget()->hide();
     260        //this->weaponsWidgetsSec.remove(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     261      }
     262    }
     263  }
     264
     265  //this->weaponsWidgetsPrim.clear();
     266  //this->weaponsWidgetsSec.clear();
     267}
     268*/
     269
    141270void Hud::updateWeaponManager()
    142271{
    143272  // hide all the Widgets
    144   std::list<OrxGui::GLGuiWidget*>::iterator weaponWidget;
    145   for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++)
     273 
     274  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
     275  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
    146276  {
    147277    (*weaponWidget)->hide();
    148278  }
    149   this->weaponsWidgets.clear();
     279  this->weaponsWidgetsPrim.clear();
     280
     281  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
     282  {
     283    (*weaponWidget)->hide();
     284  }
     285  this->weaponsWidgetsSec.clear();
     286 
    150287
    151288  // add all that we need again.
     289
    152290  if (this->weaponManager != NULL)
    153291    for (unsigned int i = 0; i < this->weaponManager->getSlotCount(); i++)
     
    157295      {
    158296        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
     297        weapon->getEnergyWidget()->setParent2D(this->rightRect);
    159298        weapon->getEnergyWidget()->show();
    160299        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
    161300        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
    162         //      weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
    163         this->weaponsWidgets.push_back(weapon->getEnergyWidget());
     301        weapon->getEnergyWidget()->setWidgetSize(120,30);
     302        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     303        this->weaponsWidgetsPrim.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
    164304      }
    165305    }
     306
     307  if (this->weaponManagerSecondary != NULL)
     308    for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++)
     309    {
     310      Weapon* weapon = this->weaponManagerSecondary->getWeapon(i);
     311      if (weapon != NULL)
     312      {
     313        //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName());
     314        weapon->getEnergyWidget()->setParent2D(this->rightRect);
     315        weapon->getEnergyWidget()->show();
     316        weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1));
     317        weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6));
     318        weapon->getEnergyWidget()->setWidgetSize(150,50);
     319        //weapon->getEnergyWidget()->frontMaterial().setTransparency(.6);
     320        this->weaponsWidgetsSec.push_back(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (weapon->getEnergyWidget()));
     321      }
     322    }
     323
    166324  this->updateResolution();
     325
    167326}
    168327
     
    182341  this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
    183342
     343  int overlayWidth = 0;
     344  if (overlayPercentage >= 20)
     345    overlayWidth = this->resX * (overlayPercentage)/(200);
     346  else
     347    overlayWidth = this->resX * 0.1;
     348  //if (overlayWidth < 100)
     349    //overlayWidth = 100;
     350
     351  this->rightRect->hide();
     352  this->leftRect->hide();
     353
     354  this->leftRect->setParent2D(this);
     355  this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY));
     356  this->leftRect->setAbsCoor2D(0,0);
     357  this->leftRect->setBackgroundTexture(Texture());
     358  this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2));
     359  this->leftRect->setForegroundTexture(Texture());
     360  this->leftRect->setForegroundColor(Color(0,0,0,0));
     361
     362  this->rightRect->setParent2D(this);
     363  this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY));
     364  this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0);
     365  this->rightRect->setBackgroundTexture(Texture());
     366  this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2));
     367  this->rightRect->setForegroundTexture(Texture());
     368  this->rightRect->setForegroundColor(Color(0,0,0,0));
     369
     370
     371  if (this->overlayActive == true)
     372  {
     373    this->rightRect->show();
     374    this->leftRect->show();
     375  }
     376
    184377
    185378  if (State::getPlayer() && State::getPlayer()->getPlayable() && State::getObjectManager())
    186379  {
    187380    PRINTF(4)("UPDATING RADAR\n");
    188     this->_radar->setCenterNode(State::getPlayer()->getPlayable());
    189     this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));
    190     this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_02), Color(1.0, .2, .2));
    191     this->_radar->setAbsCoor2D(0.8 * this->resX, 0.01 * this->resY);
    192     this->_radar->setWidgetSize(0.2 * this->resX, 0.2 * this->resY);
     381    this->_radar->setParent2D(this->leftRect);
     382    if (radarCenterNode == NULL)
     383      this->_radar->setCenterNode(State::getPlayer()->getPlayable());
     384    else
     385      this->_radar->setCenterNode(this->radarCenterNode);
     386
     387    //this->_radar->addEntityList(&State::getObjectManager()->getEntityList((OM_LIST)(State::getPlayer()->getPlayable()->getOMListNumber()+1)), Color(.4, .4, 1.0));
     388    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_00), Color(1, 0, 0));
     389    this->_radar->addEntityList(&State::getObjectManager()->getEntityList(OM_GROUP_01), Color(0, 0, 1));
     390    this->_radar->setAbsCoor2D(0, 0.01 * this->resY);
     391    this->_radar->setWidgetSize(overlayWidth, overlayWidth);
    193392    this->_radar->setRange(300);
    194393    this->_radar->show();
    195   }
    196 
    197 
    198   if (this->energyWidget != NULL)
    199   {
    200     this->energyWidget->setAbsCoor2D(0.0 * this->resX, 0.85 * this->resY);
    201     this->energyWidget->setWidgetSize(.25 * this->resX, 0.1 * this->resY);
    202   }
    203 
    204 
    205   std::list<OrxGui::GLGuiWidget*>::iterator weaponWidget;
    206   Vector2D pos(0.3, .9);
    207   for (weaponWidget = this->weaponsWidgets.begin(); weaponWidget != this->weaponsWidgets.end(); weaponWidget++, pos.x+=.2)
    208   {
    209     if (pos.x > .8)
    210     {
    211       pos.x = 0.3;
    212       pos.y -= .1;
    213 
    214     }
    215     (*weaponWidget)->setAbsCoor2D(pos.x*this->resX, pos.y*this->resY);
    216     (*weaponWidget)->setWidgetSize(.02*this->resX, .1 *this->resY);
     394   
     395    int statWidgetsNumber = 0;
     396    float expectedArmorSizeX = 0;
     397    float expectedArmorSizeY = 0;
     398    float newSizeY = 0; float newSizeX = 0;
     399    float moduloWidth = 0;
     400
     401    if (this->armorWidget != NULL)
     402    {
     403      expectedArmorSizeX = 150;
     404      expectedArmorSizeY = 50;
     405      statWidgetsNumber++;
     406    }
     407
     408    if (this->shieldWidget != NULL)
     409      statWidgetsNumber++;
     410   
     411    if (this->energyWidget != NULL)
     412      statWidgetsNumber++;
     413
     414    if (expectedArmorSizeY * statWidgetsNumber > overlayWidth)
     415    {
     416      newSizeY = overlayWidth / float(statWidgetsNumber);
     417      newSizeX = expectedArmorSizeX;
     418      PRINTF(0)("Statwidgets resized\n");
     419    }
     420    else
     421    {
     422      newSizeY = expectedArmorSizeY;
     423      newSizeX = expectedArmorSizeX;
     424      moduloWidth = int(overlayWidth) % int(expectedArmorSizeY * statWidgetsNumber);
     425    }
     426
     427    float posY = overlayWidth + newSizeX;
     428
     429    if (this->armorWidget != NULL)
     430    {
     431      this->armorWidget->setSize2D(newSizeX, newSizeY);
     432      this->armorWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY);
     433    }
     434    if (this->shieldWidget != NULL)
     435    {
     436      this->shieldWidget->setSize2D(newSizeX, newSizeY);
     437      this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY);
     438    }
     439    if (this->energyWidget != NULL)
     440    {
     441      this->energyWidget->setSize2D(newSizeX, newSizeY);
     442      this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY);
     443    }
     444
     445    /*
     446    if (this->armorWidget != NULL)
     447      this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D());
     448    if (this->shieldWidget != NULL)
     449      this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D());
     450    if (this->energyWidget != NULL)
     451      this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D());
     452    */
     453    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0);
     454    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
     455  }
     456
     457  /*
     458  if (this->shipValuesBox != NULL)
     459  {
     460    this->shipValuesBox->setAbsCoor2D(0.2 * this->resX, 0.4 * this->resY);
     461    this->shipValuesBox->setWidgetSize(.4 * this->resX, 0.1 * this->resY);
     462  }
     463  else
     464    createShipValuesBox();
     465  */
     466
     467  std::list<OrxGui::GLGuiEnergyWidgetVertical*>::iterator weaponWidget;
     468  Vector2D pos = Vector2D(overlayWidth, 0.4*this->resY);
     469  float largestWidgetSizeX = 0;
     470  //PRINTF(0)("Cur Pos: %f,%f\n",pos.x,pos.y);
     471  // out of reasons i can't get behind, this version is segfaulting when calling getSizeX2D or getSizeY2D. the other
     472  // element2D- related function works tough.. :s
     473
     474  for (weaponWidget = this->weaponsWidgetsPrim.begin(); weaponWidget != this->weaponsWidgetsPrim.end(); weaponWidget++)
     475  {
     476    float ySize = (*weaponWidget)->getSizeY2D();
     477    float xSize = (*weaponWidget)->getSizeX2D();
     478    if (xSize > largestWidgetSizeX)
     479      largestWidgetSizeX = xSize;
     480    if (pos.x < ySize)
     481    {
     482      pos.x = overlayWidth;
     483      pos.y += largestWidgetSizeX;
     484    }
     485    pos.x -= ySize;
     486    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
     487    //(*weaponWidget)->setAbsCoor2D(0,100);
    217488    (*weaponWidget)->show();
    218489    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
    219490  }
     491 
     492  weaponWidget = this->weaponsWidgetsSec.begin();
     493  float expectedWidgetSizeY = 0;
     494  if (weaponWidget != this->weaponsWidgetsSec.end())
     495  {
     496    expectedWidgetSizeY = (*weaponWidget)->getSizeY2D();
     497  }
     498  pos.y = resY - expectedWidgetSizeY * 0.6;
     499  pos.x = overlayWidth + this->rightRect->getAbsCoor2D().x;
     500
     501  for (weaponWidget = this->weaponsWidgetsSec.begin(); weaponWidget != this->weaponsWidgetsSec.end(); weaponWidget++)
     502  {
     503    float ySize = (*weaponWidget)->getSizeY2D();
     504    float xSize = (*weaponWidget)->getSizeX2D();
     505    if (xSize > largestWidgetSizeX)
     506      largestWidgetSizeX = xSize;
     507    if (pos.x < ySize)
     508    {
     509      pos.x = overlayWidth;
     510      pos.y -= largestWidgetSizeX + expectedWidgetSizeY * 0.6;
     511    }
     512    pos.x -= ySize;
     513    //PRINTF(0)("secweaponwidget y-size: %f/n", (*weaponWidget)->getSizeY2D());
     514    (*weaponWidget)->setAbsCoor2D(pos.x + this->rightRect->getAbsCoor2D().x, pos.y);
     515    (*weaponWidget)->show();
     516    //printf("update thing %s::%s\n", (*weaponWidget)->getClassCName(), (*weaponWidget)->getName());
     517  }
     518
    220519}
    221520
     
    235534  //  this->inputLine->select();
    236535  }
    237 
    238 
    239 }
    240 
    241 
     536}
     537
     538/*
     539void Hud::createShipValuesBox()
     540{
     541  this->shipValuesBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
     542  //this->shipValuesBox->setWidgetSize(1000,500);
     543  //this->shipValuesBox->setBackgroundTexture("maps/gui_container_background.png");
     544  this->shipValuesBox->setBackgroundTexture(Texture());
     545  this->shipValuesBox->setBackgroundColor(Color(0,0,1,0.5));
     546  this->shipValuesBox->setVisibility(true);
     547}
     548*/
     549
     550
  • branches/playability.new/src/util/hud.h

    r9869 r10362  
    99#include "element_2d.h"
    1010#include "event_listener.h"
     11#include "glgui_box.h"
     12#include "elements/glgui_energywidgetvertical.h"
    1113
    1214
     
    3941  void setShiledWidget(OrxGui::GLGuiWidget* widget);
    4042  void setArmorWidget(OrxGui::GLGuiWidget* widget);
    41   void setWeaponManager(WeaponManager* weaponMan);
     43  inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;};
     44  inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;};
     45  inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;};
     46
     47  void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL);
     48  inline void setRadarCenterNode(PNode* node) {this->radarCenterNode = node;};
    4249
    4350  void addWeaponWidget(OrxGui::GLGuiWidget* widget);
     
    4754
    4855  void updateWeaponManager();
     56  //void clearWeaponManager();
     57
     58  inline void setOverlayPercentage(int perc)
     59  {
     60    if (perc > 100) perc = 100;
     61    else if (perc < 0) perc = 0;
     62
     63    this->overlayPercentage = perc;
     64    updateResolution();
     65  };
     66
     67  inline void setOverlayActive(bool b)
     68  {
     69    overlayActive = b;
     70    updateResolution();
     71  };
    4972
    5073  void draw() const;
     
    5477  private:
    5578    void updateResolution();
     79    //void createShipValuesBox();
    5680
    5781private:
    5882  unsigned int             resX;
    5983  unsigned int             resY;
     84
     85  float                    travelZoneWidth; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
    6086
    6187  OrxGui::GLGuiWidget*     energyWidget;
     
    6692  OrxGui::GLGuiInputLine*  inputLine;
    6793  OrxGui::GLGuiRadar*      _radar;
     94  PNode*                   radarCenterNode;
     95
     96  OrxGui::GLGuiWidget*     rightRect;
     97  OrxGui::GLGuiWidget*     leftRect;
     98  bool                     overlayActive;
     99  int                      overlayPercentage; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
    68100
    69101  WeaponManager*           weaponManager;
     102  WeaponManager*           weaponManagerSecondary;
    70103
    71   std::list<OrxGui::GLGuiWidget*> weaponsWidgets; //!< WeaponWidgets will be displayed one after another
     104  std::list<OrxGui::GLGuiEnergyWidgetVertical*> weaponsWidgetsPrim; //!< WeaponWidgets will be displayed one after another
     105  std::list<OrxGui::GLGuiEnergyWidgetVertical*> weaponsWidgetsSec;
    72106};
    73107
  • branches/playability.new/src/util/state.h

    r8408 r10362  
    109109  static inline int getMenuID() { return State::menuID;}
    110110
     111  ////////////////////////
     112  /// Scroller-Control ///
     113  ////////////////////////
     114  /** sets the scroller-travelnode (center of the screen) */
     115  static void setTravelNode(PNode* travelNode) {State::travelNode = travelNode;}
     116  /** @returns the scroller-travelnode (center of the screen) */
     117  static PNode* getTravelNode() { return State::travelNode; }
    111118
    112119
     
    123130  static GameRules*             gameRules;          //!< A reference to the GameRules
    124131  static Player*                player;             //!< A reference to the Player
     132  static PNode*                 travelNode;         //!< A reference to the scroller-travelnode
    125133
    126134  static SkyBox*                skyBox;            //!< The SkyBox used in the current world.
  • branches/playability.new/src/util/track/track_manager.cc

    r10320 r10362  
    2626#include "t_animation.h"
    2727
     28#include <string.h>
     29
    2830
    2931#include "parser/tinyxml/tinyxml.h"
     
    3234#include <stdarg.h>
    3335
     36ObjectListDefinition(TrackElement);
    3437
    3538
     
    3942TrackElement::TrackElement()
    4043{
    41   this->setClassID(CL_TRACK_ELEMENT, "TrackElement");
     44  this->registerObject(this, TrackElement::_objectList);
     45
    4246
    4347  this->isFresh = true;
     
    126130{
    127131  // return if Found.
    128   if (this->getName() && !strcmp(this->getName(), trackName))
    129     return this;
     132//   if (this->getName() && !strcmp(this->getName(), trackName))
     133//     return this;
    130134  // search all children
    131135  if (this->childCount > 0)
     
    217221void TrackElement::debug() const
    218222{
    219   PRINT(0)("--== TrackElement:%i ==--", this->ID);
    220   if(this->getName())
    221     PRINT(0)("--++Name: %s++--", this->getName());
    222   if(this->isFresh)
    223     PRINT(0)("  -- has not jet eddited in any way --\n");
    224   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
    225   PRINT(0)("   consists of %d Points\n", this->nodeCount);
    226   if (this->childCount == 0)
    227     PRINT(0)("   has no child\n");
    228   else if (this->childCount == 1)
    229     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
    230   else if (this->childCount > 1)
    231     {
    232       PRINT(0)("   has %d children: ", this->childCount);
    233       //TrackElement* enumElem = this->children->enumerate();
    234       tIterator<TrackElement>* iterator = this->children->getIterator();
    235       TrackElement* enumElem = iterator->firstElement();
    236       while (enumElem)
    237         {
    238           PRINT(0)("=%d= ", enumElem->ID);
    239           enumElem = iterator->nextElement();
    240         }
    241       delete iterator;
    242       PRINT(0)("\n");
    243     }
    244 
    245   if(this->isHotPoint)
    246     PRINT(0)("   is a special Point:\n");
    247   if(this->isSavePoint)
    248     PRINT(0)("    is a SavePoint\n");
    249   if(this->isFork)
    250     {
    251       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
    252     }
    253   if(this->isJoined)
    254     PRINT(0)("   is Joined at the End\n");
    255 
    256   if(!this->backLoopCheck()) /* this should not happen */
    257     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
     223//   PRINT(0)("--== TrackElement:%i ==--", this->ID);
     224//   if(this->getName())
     225//     PRINT(0)("--++Name: %s++--", this->getName());
     226//   if(this->isFresh)
     227//     PRINT(0)("  -- has not jet eddited in any way --\n");
     228//   PRINT(0)("\n   TimeTable: startingTime=%f; endTime=%f; duration=%f; jumpTime=%f\n", this->startingTime, this->endTime, this->duration, this->jumpTime);
     229//   PRINT(0)("   consists of %d Points\n", this->nodeCount);
     230//   if (this->childCount == 0)
     231//     PRINT(0)("   has no child\n");
     232//   else if (this->childCount == 1)
     233//     PRINT(0)("   has 1 child: =%d=\n", this->getChild(0)->ID);
     234//   else if (this->childCount > 1)
     235//     {
     236//       PRINT(0)("   has %d children: ", this->childCount);
     237//       //TrackElement* enumElem = this->children->enumerate();
     238//       tIterator<TrackElement>* iterator = this->children->getIterator();
     239//       TrackElement* enumElem = iterator->firstElement();
     240//       while (enumElem)
     241//         {
     242//           PRINT(0)("=%d= ", enumElem->ID);
     243//           enumElem = iterator->nextElement();
     244//         }
     245//       delete iterator;
     246//       PRINT(0)("\n");
     247//     }
     248//
     249//   if(this->isHotPoint)
     250//     PRINT(0)("   is a special Point:\n");
     251//   if(this->isSavePoint)
     252//     PRINT(0)("    is a SavePoint\n");
     253//   if(this->isFork)
     254//     {
     255//       PRINT(0)("    is A Fork with with %d children.\n", this->childCount);
     256//     }
     257//   if(this->isJoined)
     258//     PRINT(0)("   is Joined at the End\n");
     259//
     260//   if(!this->backLoopCheck()) /* this should not happen */
     261//     PRINT(2)(" THERE IS A BACKLOOP TO THIS ELEMENT\n");
    258262}
    259263
     
    358362TrackManager::TrackManager()
    359363{
    360   this->setClassID(CL_TRACK_MANAGER, "TrackManager");
    361   this->setName("TrackManager");
    362 
    363364  TrackManager::singletonRef = this; // do this because otherwise the TrackNode cannot get The instance of the TrackManager
    364365
     
    395396void TrackManager::loadParams(const TiXmlElement* root)
    396397{
    397   double x, y, z, d;
    398 
    399   LOAD_PARAM_START_CYCLE(root, element);
    400   {
    401 
    402     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
    403         .describe("Selects a TrackElement (by name) to work on");
    404 
    405     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
    406         .describe("Adds a new Point to the currently selected TrackElement");
    407 
    408     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
    409         .describe("Sets the Duration of the currently selected TrackElement");
    410 
    411     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
    412         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
    413 
    414     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
    415         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
    416 
    417     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
    418         .describe("Forks the Path into multiple forked Path names seperated by ','");
    419 
    420     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
    421         .describe("Joins multiple joining Path names seperated by ','");
     398//   double x, y, z, d;
     399//
     400//   LOAD_PARAM_START_CYCLE(root, element);
     401//   {
     402//
     403//     LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
     404//         .describe("Selects a TrackElement (by name) to work on");
     405//
     406//     LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
     407//         .describe("Adds a new Point to the currently selected TrackElement");
     408//
     409//     LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
     410//         .describe("Sets the Duration of the currently selected TrackElement");
     411//
     412//     LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
     413//         .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
     414//
     415//     LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
     416//         .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
     417//
     418//     LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
     419//         .describe("Forks the Path into multiple forked Path names seperated by ','");
     420//
     421//     LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
     422//         .describe("Joins multiple joining Path names seperated by ','");
    422423
    423424      /*
     
    445446        }
    446447      */
    447   }
    448   LOAD_PARAM_END_CYCLE(element);
     448
     449//   }
     450//   LOAD_PARAM_END_CYCLE(element);
    449451}
    450452
     
    477479void TrackManager::initChildren(unsigned int childCount, TrackElement* trackElem)
    478480{
    479   if (!trackElem)
    480     trackElem = this->currentTrackElem;
    481 
    482   trackElem->childCount = childCount;
    483   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
    484   trackElem->children =  new tList<TrackElement>();
    485   for (int i = 0; i < childCount; i++)
    486     {
    487       // create a new Element
    488       TrackElement* newElem = new TrackElement();
    489       // setting up the new ID
    490       newElem->ID = ++trackElemCount;
    491       // setting up the Time
    492       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
    493       // adds the conection Point
    494       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
    495                      newElem);
    496       // add the new child to the childList.
    497       trackElem->children->add(newElem);
    498     }
    499 
    500   // setting the Name of the new TrackElement to the name of the last one + _childI
    501 
    502   if (trackElem->getName())
    503     {
    504       for (int i = 0; i < trackElem->childCount; i++)
    505       {
    506         char* childName = new char[strlen(trackElem->getName())+10];
    507         sprintf(childName, "%s_child%d", trackElem->getName(), i);
    508         trackElem->getChild(i)->setName(childName);
    509       }
    510     }
    511   // select the first Child to work on.
    512   this->currentTrackElem = trackElem->getChild(0);
     481//   if (!trackElem)
     482//     trackElem = this->currentTrackElem;
     483//
     484//   trackElem->childCount = childCount;
     485//   trackElem->mainJoin = true;  // this tells join, that this one is the Main Join, if it tries to join multiple Tracks
     486//   trackElem->children =  new tList<TrackElement>();
     487//   for (int i = 0; i < childCount; i++)
     488//     {
     489//       // create a new Element
     490//       TrackElement* newElem = new TrackElement();
     491//       // setting up the new ID
     492//       newElem->ID = ++trackElemCount;
     493//       // setting up the Time
     494//       newElem->startingTime = trackElem->endTime + trackElem->jumpTime;
     495//       // adds the conection Point
     496//       this->addPointV(trackElem->curve->getNode(trackElem->curve->getNodeCount()),
     497//                      newElem);
     498//       // add the new child to the childList.
     499//       trackElem->children->add(newElem);
     500//     }
     501//
     502//   // setting the Name of the new TrackElement to the name of the last one + _childI
     503//
     504//   if (trackElem->getName())
     505//     {
     506//       for (int i = 0; i < trackElem->childCount; i++)
     507//       {
     508//         char* childName = new char[strlen(trackElem->getName())+10];
     509//         sprintf(childName, "%s_child%d", trackElem->getName(), i);
     510//         trackElem->getChild(i)->setName(childName);
     511//       }
     512//     }
     513//   // select the first Child to work on.
     514//   this->currentTrackElem = trackElem->getChild(0);
    513515}
    514516
     
    659661void TrackManager::setSavePointS(const std::string& nextElementName)
    660662{
    661   this->setSavePoint(NULL);
    662   if (strcmp(nextElementName, ""))
    663     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
     663//   this->setSavePoint(NULL);
     664//   if (strcmp(nextElementName, ""))
     665//     this->firstTrackElem->findByID(this->trackElemCount)->setName(nextElementName);
    664666}
    665667
     
    736738void TrackManager::forkS(const std::string& forkString)
    737739{
    738   SubString strings(forkString, ',');
    739 
    740   int* trackIDs = new int[strings.getCount()];
    741   this->forkV(strings.getCount(), trackIDs, NULL);
    742 
    743   for(int i = 0; i < strings.getCount(); i++)
    744     {
    745       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
    746     }
    747   delete []trackIDs;
     740//   SubString strings(forkString, ',');
     741//
     742//   int* trackIDs = new int[strings.getCount()];
     743//   this->forkV(strings.getCount(), trackIDs, NULL);
     744//
     745//   for(int i = 0; i < strings.getCount(); i++)
     746//     {
     747//       this->firstTrackElem->findByID(trackIDs[i])->setName(strings.getString(i));
     748//     }
     749//   delete []trackIDs;
    748750}
    749751
     
    877879void TrackManager::joinS(const std::string& joinString)
    878880{
    879   SubString strings(joinString, ',');
    880 
    881   int* trackIDs = new int[strings.getCount()];
    882   this->joinV(strings.getCount(), trackIDs);
    883 
    884   for(unsigned int i = 0; i < strings.getCount(); i++)
    885     {
    886       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
    887       if (tmpElem != NULL)
    888         trackIDs[i] = tmpElem->ID;
    889       else
    890       {
    891         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
    892         trackIDs[i] = -1;
    893       }
    894     }
    895   this->joinV(strings.getCount(), trackIDs);
    896   delete []trackIDs;
     881//   SubString strings(joinString, ',');
     882//
     883//   int* trackIDs = new int[strings.getCount()];
     884//   this->joinV(strings.getCount(), trackIDs);
     885//
     886//   for(unsigned int i = 0; i < strings.getCount(); i++)
     887//     {
     888//       TrackElement* tmpElem = this->firstTrackElem->findByName(strings.getString(i).c_str());
     889//       if (tmpElem != NULL)
     890//         trackIDs[i] = tmpElem->ID;
     891//       else
     892//       {
     893//         PRINTF(1)("Trying to join a Track, of which the name does not exist: %s\n", strings.getString(i).c_str());
     894//         trackIDs[i] = -1;
     895//       }
     896//     }
     897//   this->joinV(strings.getCount(), trackIDs);
     898//   delete []trackIDs;
    897899}
    898900
     
    10731075void TrackManager::tick(float dt)
    10741076{
    1075   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
    1076   if (this->localTime <= this->firstTrackElem->duration)
    1077     this->jumpTo(this->localTime);
    1078   if (this->localTime <= this->maxTime)
    1079     this->localTime += dt;
    1080   if (this->localTime > this->currentTrackElem->endTime
    1081       && this->currentTrackElem->children)
    1082     {
    1083       if (this->currentTrackElem->jumpTime != 0.0)
    1084         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    1085       // jump to the next TrackElement and also set the history of the new Element to the old one.
    1086       TrackElement* tmpHistoryElem = this->currentTrackElem;
    1087       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
    1088       this->currentTrackElem->history = tmpHistoryElem;
    1089       if (this->currentTrackElem->getName())
    1090         {
    1091           this->trackText->setText(this->currentTrackElem->getName());
    1092           this->textAnimation->replay();
    1093         }
    1094     }
    1095   if (this->bindSlave)
    1096     {
    1097       Vector tmp = this->calcPos();
    1098       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
    1099 
    1100       Vector v(0.0, 1.0, 0.0);
    1101       Quaternion q(-PI/2, v);
    1102       quat = quat * q;
    1103 
    1104       this->bindSlave->setAbsCoor(tmp);
    1105       this->bindSlave->setAbsDir(quat);
    1106     }
     1077//   PRINTF(4)("CurrentTrackID: %d, LocalTime is: %f, timestep is: %f\n", this->currentTrackElem->ID, this->localTime, dt);
     1078//   if (this->localTime <= this->firstTrackElem->duration)
     1079//     this->jumpTo(this->localTime);
     1080//   if (this->localTime <= this->maxTime)
     1081//     this->localTime += dt;
     1082//   if (this->localTime > this->currentTrackElem->endTime
     1083//       && this->currentTrackElem->children)
     1084//     {
     1085//       if (this->currentTrackElem->jumpTime != 0.0)
     1086//         this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
     1087//       // jump to the next TrackElement and also set the history of the new Element to the old one.
     1088//       TrackElement* tmpHistoryElem = this->currentTrackElem;
     1089//       this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem));
     1090//       this->currentTrackElem->history = tmpHistoryElem;
     1091//       if (this->currentTrackElem->getName())
     1092//         {
     1093//           this->trackText->setText(this->currentTrackElem->getName());
     1094//           this->textAnimation->replay();
     1095//         }
     1096//     }
     1097//   if (this->bindSlave)
     1098//     {
     1099//       Vector tmp = this->calcPos();
     1100//       Quaternion quat = Quaternion(this->calcDir(), Vector(this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).x,1,this->currentTrackElem->curve->calcAcc((localTime-this->currentTrackElem->startingTime)/this->currentTrackElem->duration).z));
     1101//
     1102//       Vector v(0.0, 1.0, 0.0);
     1103//       Quaternion q(-PI/2, v);
     1104//       quat = quat * q;
     1105//
     1106//       this->bindSlave->setAbsCoor(tmp);
     1107//       this->bindSlave->setAbsDir(quat);
     1108//     }
    11071109}
    11081110
     
    11161118void TrackManager::jumpTo(float time)
    11171119{
    1118   if (time == 0)
    1119     {
    1120       this->currentTrackElem = this->firstTrackElem;
    1121       if (this->currentTrackElem->getName())
    1122         {
    1123           this->trackText->setText(this->currentTrackElem->getName());
    1124           this->textAnimation->play();
    1125         }
    1126     }
    1127   this->localTime = time;
     1120//   if (time == 0)
     1121//     {
     1122//       this->currentTrackElem = this->firstTrackElem;
     1123//       if (this->currentTrackElem->getName())
     1124//         {
     1125//           this->trackText->setText(this->currentTrackElem->getName());
     1126//           this->textAnimation->play();
     1127//         }
     1128//     }
     1129//   this->localTime = time;
    11281130}
    11291131
  • branches/playability.new/src/util/track/track_manager.h

    r7221 r10362  
    4141class TrackElement : public BaseObject
    4242{
     43  ObjectListDeclaration(TrackElement);
     44
    4345 public:
    4446  TrackElement();
     
    131133    \li TrackElement: A Part of A whole Track
    132134*/
    133 class TrackManager : public BaseObject
     135class TrackManager
    134136{
    135137 public:
  • branches/playability.new/src/util/track/track_node.cc

    r9869 r10362  
    1717
    1818
    19 #include "track_node.h"
     19#include "track/track_node.h"
    2020
    21 #include "track_manager.h"
     21#include "track/track_manager.h"
    2222
    2323
    24 ObjectListDefinition(TracNode);
     24ObjectListDefinition(TrackNode);
     25
    2526/**
    2627 *  standard constructor
     
    2829TrackNode::TrackNode ()
    2930{
    30   this->registerObject(this, TracNode::_objectList);
    31   this->setName("TrackNode");
     31  this->registerObject(this, TrackNode::_objectList);
    3232
    3333  PNode::getNullParent()->addChild(this);
  • branches/playability.new/src/util/track/track_node.h

    r9869 r10362  
    1414#include "p_node.h"
    1515
     16
    1617/* FORWARD DECLARATION */
    1718class TrackManager;
     
    2021class TrackNode : public PNode
    2122{
    22   ObjectListDeclaratrion(TracNode);
     23  ObjectListDeclaration(TrackNode);
    2324 public:
    2425  TrackNode ();
  • branches/playability.new/src/world_entities/Makefile.am

    r9869 r10362  
    66
    77## THESE ARE THE BASE CLASSES OF ALL WORLD_ENTITIES
    8 libORXwe_a_SOURCES = \
    9                 world_entity.cc \
    10                 \
    11                 camera.cc \
    12                 playable.cc \
    13                 player.cc \
    14                 \
    15                 npcs/npc.cc \
    16                 \
    17                 weapons/weapon_manager.cc \
    18                 weapons/crosshair.cc \
    19                 weapons/weapon.cc \
    20                 weapons/ammo_container.cc \
    21                 projectiles/projectile.cc \
    22                 \
    23                 extendable.cc \
    24                 power_ups/power_up.cc \
    25                 power_ups/param_power_up.cc \
    26                 power_ups/weapon_power_up.cc \
    27                 \
    28                 spawning_point.cc \
    29                 \
    30                 \
    31                 effects/explosion.cc \
    32                 effects/billboard.cc \
    33                 \
    34                 \
    35                 elements/glgui_energywidget.cc
     8libORXwe_a_SOURCES = world_entity.cc\
     9                     camera.cc\
     10                     playable.cc\
     11                     player.cc \
     12                     npcs/npc.cc\
     13                     weapons/weapon_manager.cc\
     14                     weapons/crosshair.cc \
     15                     weapons/weapon.cc\
     16                     weapons/ammo_container.cc\
     17                     projectiles/projectile.cc \
     18                     extendable.cc\
     19                     power_ups/power_up.cc\
     20                     power_ups/param_power_up.cc \
     21                     power_ups/weapon_power_up.cc\
     22                     spawning_point.cc\
     23                     effects/explosion.cc\
     24                     effects/billboard.cc\
     25                     effects/wobblegrid.cc\
     26                     effects/trail.cc\
     27                     elements/glgui_energywidget.cc\
     28                     elements/glgui_energywidgetvertical.cc
    3629
    3730
    38 noinst_HEADERS  = \
    39                 world_entity.h \
    40                 \
    41                 camera.h \
    42                 extendable.h \
    43                 playable.h \
    44                 player.h \
    45                 \
    46                 npcs/npc.h \
    47                 \
    48                 weapons/weapon_manager.h \
    49                 weapons/crosshair.h \
    50                 weapons/weapon.h \
    51                 weapons/ammo_container.h \
    52                 projectiles/projectile.h \
    53                 \
    54                 power_ups/power_up.h \
    55                 power_ups/param_power_up.h \
    56                 power_ups/weapon_power_up.h \
    57                 \
    58                 spawning_point.h \
    59                 \
    60                 \
    61                 effects/explosion.h \
    62                 effects/billboard.h \
    63                 \
    64                 \
    65                 \
    66                 elements/glgui_energywidget.h \
    67                 \
    68                 \
    69                 $(WorldEntities_HEADERS_)
     31noinst_HEADERS = world_entity.h \
     32                 camera.h \
     33                 extendable.h \
     34                 playable.h \
     35                 player.h \
     36                 npcs/npc.h \
     37                 weapons/weapon_manager.h \
     38                 weapons/crosshair.h \
     39                 weapons/weapon.h \
     40                 weapons/ammo_container.h \
     41                 projectiles/projectile.h \
     42                 power_ups/power_up.h \
     43                 power_ups/param_power_up.h \
     44                 power_ups/weapon_power_up.h \
     45                 spawning_point.h \
     46                 effects/explosion.h \
     47                 effects/billboard.h \
     48                 effects/trail.h\
     49                 effects/wobblegrid.h\
     50                 elements/glgui_energywidget.h\
     51                 elements/glgui_energywidgetvertical.h
    7052
    7153
  • branches/playability.new/src/world_entities/WorldEntities.am

    r10321 r10362  
    1 
    21## THE SUBCLASSES. THESE MUST BE DYNAMICALLY LINKED OR COMPILED IN DIRECTLY
    32WorldEntities_SOURCES_ = \
     
    2322                world_entities/character_attributes.cc \
    2423                world_entities/test_entity.cc \
     24                world_entities/test_entity2.cc \
    2525                world_entities/planet.cc \
    2626                world_entities/bsp_entity.cc \
     
    3939                world_entities/weapons/fps_sniper_rifle.cc \
    4040                world_entities/weapons/boomerang_gun.cc \
    41                 \
     41                world_entities/weapons/light_blaster.cc \
     42                world_entities/weapons/medium_blaster.cc \
     43                world_entities/weapons/heavy_blaster.cc \
     44                world_entities/weapons/swarm_launcher.cc \
     45                world_entities/weapons/spike_launcher.cc \
     46                world_entities/weapons/spike_thrower.cc \
     47                world_entities/weapons/acid_launcher.cc \
     48                \
     49                world_entities/projectiles/lbolt.cc \
     50                world_entities/projectiles/mbolt.cc \
     51                world_entities/projectiles/hbolt.cc \
     52                world_entities/projectiles/swarm_projectile.cc \
    4253                world_entities/projectiles/bomb.cc \
    4354                world_entities/projectiles/laser.cc \
     
    4859                world_entities/projectiles/boomerang_projectile.cc \
    4960                world_entities/projectiles/hyperblast.cc \
     61                world_entities/projectiles/spike.cc \
     62                world_entities/projectiles/acid_splash.cc \
     63                \
     64                world_entities/projectiles/projectile_weapon.cc \
     65                world_entities/projectiles/spike_ball.cc \
    5066                \
    5167                world_entities/power_ups/turret_power_up.cc \
     
    8399                world_entities/particles/box_emitter.cc \
    84100                world_entities/particles/plane_emitter.cc \
     101                world_entities/particles/emitter_node.cc \
    85102                \
    86103                world_entities/particles/particle_system.cc \
     
    129146                character_attributes.h \
    130147                test_entity.h \
     148                test_entity2.h \
    131149                planet.h \
    132150                bsp_entity.h \
     
    145163                weapons/aiming_system.h \
    146164                weapons/fps_sniper_rifle.h \
    147                 \
     165                weapons/light_blaster.h \
     166                weapons/medium_blaster.h \
     167                weapons/heavy_blaster.h \
     168                weapons/swarm_launcher.h \
     169                weapons/spike_launcher.h \
     170                weapons/spike_thrower.h \
     171                weapons/acid_launcher.h \
     172                \
     173                projectiles/lbolt.h \
     174                projectiles/mbolt.h \
     175                projectiles/hbolt.h \
     176                projectiles/swarm_projectile.h \
    148177                projectiles/bomb.h \
    149178                projectiles/laser.h \
     
    154183                projectiles/boomerang_projectile.h \
    155184                projectiles/hyperblast.h \
     185                projectiles/spike.h \
     186                projectiles/spike_ball.h \
     187                projectiles/acid_splash.h \
     188                \
     189                projectiles/projectile_weapon.h \
     190                projectiles/spike_ball.h \
    156191                \
    157192                power_ups/turret_power_up.h \
     
    188223                particles/box_emitter.h \
    189224                particles/plane_emitter.h \
     225                particles/emitter_node.h \
    190226                \
    191227                particles/particle_system.h \
     
    209245                weather_effects/lense_flare.h
    210246
    211 
  • branches/playability.new/src/world_entities/camera.cc

    r9869 r10362  
    1818#include "key_mapper.h"
    1919#include "glincl.h"
     20//#include "util/loading/load_param.h"
     21#include "world_entity.h"
    2022
    2123ObjectListDefinition(Camera);
     
    2729{
    2830  this->registerObject(this, Camera::_objectList);
     31  this->init();
     32}
     33
     34/*
     35Camera::Camera(const TiXmlElement* root)
     36{
     37  this->registerObject(this, Camera::_objectList);
     38  this->init();
     39  this->loadParams(root);
     40}
     41*/
     42
     43/**
     44 *  default destructor
     45*/
     46Camera::~Camera()
     47{}
     48
     49void Camera::init()
     50{
    2951  this->setName("camera");
    3052  this->target = new CameraTarget();
     
    3759  this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW5);
    3860
    39   this->setFovy(90);
    40   this->setAspectRatio(1.2f);
     61  //this->setFovy(90);
     62  this->setAspectRatio(1.33f);
    4163  this->setClipRegion(.1, 10000);
     64 
     65  this->viewTopFovy = 60;
     66  this->viewNormalFovy = 90;
     67  this->viewFrontFovy = 120;
     68  this->viewRightFovy = 90;
     69  this->viewLeftFovy = 90;
     70
     71  this->viewTopDistance = 70;
     72  this->viewNormalDistance = 10;
     73  this->viewFrontDistance = 4;
     74  this->viewRightDistance = 10;
     75  this->viewLeftDistance = 10;
     76
     77  //this->loadParams(doc.RootElement());
    4278
    4379  this->setViewMode(Camera::ViewNormal);
    4480
    4581  this->setParentMode(PNODE_ALL);
    46 }
    47 
    48 /**
    49  *  default destructor
    50 */
    51 Camera::~Camera()
    52 {}
     82  this->eventHandling = true;
     83}
    5384
    5485/**
     
    100131    default:
    101132    case Camera::ViewNormal:
    102       this->toFovy = 60.0;
    103       this->setRelCoorSoft(-10, 5, 0);
     133    {
     134      this->fovy = viewNormalFovy;
     135      this->toFovy = viewNormalFovy;
     136      //this->fovy = 60;
     137      //this->toFovy = 60;
     138      this->setRelCoorSoft(-2.0/3.0 * this->viewNormalDistance, 1.0/3.0 * this->viewNormalDistance, 0);
    104139      this->target->setRelCoorSoft(0,0,0);
    105140      break;
     141    }
    106142    case Camera::ViewBehind:
    107143      break;
    108144    case Camera::ViewFront:
    109       this->toFovy = 120.0;
    110       this->setRelCoorSoft(4, 0, 0, 5);
     145    {
     146      this->fovy = viewFrontFovy;
     147      this->toFovy = viewFrontFovy;
     148      this->setRelCoorSoft(this->viewFrontDistance, 0, 0, 5);
    111149      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    112150      break;
     151    }
    113152    case Camera::ViewLeft:
    114       this->toFovy = 90;
    115       this->setRelCoorSoft(0, 1, -10, .5);
     153    {
     154      this->fovy = viewLeftFovy;
     155      this->toFovy = viewLeftFovy;
     156      this->setRelCoorSoft(0, 1, -viewLeftDistance, .5);
    116157      this->target->setRelCoorSoft(0,0,0);
    117158      break;
     159    }
    118160    case Camera::ViewRight:
    119       this->toFovy = 90;
    120       this->setRelCoorSoft(Vector(0, 1, 10));
     161    {
     162      this->fovy = viewRightFovy;
     163      this->toFovy = viewRightFovy;
     164      this->setRelCoorSoft(Vector(0, 1, viewRightDistance), 0.5);
    121165      this->target->setRelCoorSoft(0,0,0);
    122166      break;
     167    }
    123168    case Camera::ViewTop:
    124       this->toFovy= 120;
    125       this->setRelCoorSoft(Vector(30, 50, 0));
    126       this->target->setRelCoorSoft(35,0,0);
     169    {
     170      this->fovy= viewTopFovy;
     171      this->toFovy = viewTopFovy;
     172      this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0));
     173      this->target->setRelCoor(0,0,0);
     174    }
    127175  }
    128176}
     
    143191
    144192  float tmpFovy = (this->toFovy - this->fovy);
    145   if (tmpFovy > 0.01)
     193  if (fabsf(tmpFovy) > 0.01)
    146194    this->fovy += tmpFovy * fabsf(dt);
    147195}
     
    192240void Camera::process(const Event &event)
    193241{
    194   if( event.type == KeyMapper::PEV_VIEW0)
     242  if (eventHandling == true)
    195243  {
    196     this->setViewMode(Camera::ViewNormal);
     244    if( event.type == KeyMapper::PEV_VIEW0)
     245    {
     246      this->setViewMode(Camera::ViewNormal);
     247    }
     248    else if( event.type == KeyMapper::PEV_VIEW1)
     249    {
     250      this->setViewMode(Camera::ViewBehind);
     251    }
     252    else if( event.type == KeyMapper::PEV_VIEW2)
     253    {
     254      this->setViewMode(Camera::ViewFront);
     255    }
     256    else if( event.type == KeyMapper::PEV_VIEW3)
     257    {
     258      this->setViewMode(Camera::ViewLeft);
     259    }
     260    else if( event.type == KeyMapper::PEV_VIEW4)
     261    {
     262      this->setViewMode(Camera::ViewRight);
     263    }
     264    else if( event.type == KeyMapper::PEV_VIEW5)
     265    {
     266      this->setViewMode(Camera::ViewTop);
     267    }
    197268  }
    198   else if( event.type == KeyMapper::PEV_VIEW1)
    199   {
    200     this->setViewMode(Camera::ViewBehind);
    201   }
    202   else if( event.type == KeyMapper::PEV_VIEW2)
    203   {
    204     this->setViewMode(Camera::ViewFront);
    205   }
    206   else if( event.type == KeyMapper::PEV_VIEW3)
    207   {
    208     this->setViewMode(Camera::ViewLeft);
    209   }
    210   else if( event.type == KeyMapper::PEV_VIEW4)
    211   {
    212     this->setViewMode(Camera::ViewRight);
    213   }
    214   else if( event.type == KeyMapper::PEV_VIEW5)
    215   {
    216     this->setViewMode(Camera::ViewTop);
    217   }
     269}
     270
     271/*
     272void Camera::loadParams(const TiXmlElement* root)
     273{
     274  // Do the PNode loading stuff
     275  PNode::loadParams(root);
     276
     277  LoadParam(root, "viewTopFovy", this, Camera, setViewTopFovy);
     278  LoadParam(root, "viewFrontFovy", this, Camera, setViewFrontFovy);
     279  LoadParam(root, "viewLeftFovy", this, Camera, setViewLeftFovy);
     280  LoadParam(root, "viewRightFovy", this, Camera, setViewRightFovy);
     281  LoadParam(root, "viewBehindFovy", this, Camera, setViewBehindFovy);
     282  LoadParam(root, "viewNormalFovy", this, Camera, setViewNormalFovy);
     283
     284  LoadParam(root, "viewTopDistance", this, Camera, setViewTopDistance);
     285  LoadParam(root, "viewFrontDistance", this, Camera, setViewFrontDistance);
     286  LoadParam(root, "viewLeftDistance", this, Camera, setViewLeftDistance);
     287  LoadParam(root, "viewRightDistance", this, Camera, setViewRightDistance);
     288  LoadParam(root, "viewBehindDistance", this, Camera, setViewBehindDistance);
     289  LoadParam(root, "viewNormalDistance", this, Camera, setViewNormalDistance);
     290}
     291*/
     292
     293void Camera::setViewTopFovy(float fovy)
     294{
     295  this->viewTopFovy = fovy;
     296}
     297
     298void Camera::setViewFrontFovy(float fovy)
     299{
     300  this->viewFrontFovy = fovy;
     301}
     302
     303void Camera::setViewLeftFovy(float fovy)
     304{
     305  this->viewLeftFovy = fovy;
     306}
     307
     308void Camera::setViewRightFovy(float fovy)
     309{
     310  this->viewRightFovy = fovy;
     311}
     312
     313void Camera::setViewBehindFovy(float fovy)
     314{
     315  this->viewBehindFovy = fovy;
     316}
     317
     318void Camera::setViewNormalFovy(float fovy)
     319{
     320  this->viewNormalFovy = fovy;
     321}
     322
     323void Camera::setViewTopDistance(float Distance)
     324{
     325  this->viewTopDistance = Distance;
     326}
     327
     328void Camera::setViewFrontDistance(float Distance)
     329{
     330  this->viewFrontDistance = Distance;
     331}
     332
     333void Camera::setViewLeftDistance(float Distance)
     334{
     335  this->viewLeftDistance = Distance;
     336}
     337
     338void Camera::setViewRightDistance(float Distance)
     339{
     340  this->viewRightDistance = Distance;
     341}
     342
     343void Camera::setViewBehindDistance(float Distance)
     344{
     345  this->viewBehindDistance = Distance;
     346}
     347
     348void Camera::setViewNormalDistance(float Distance)
     349{
     350  this->viewNormalDistance = Distance;
    218351}
    219352
  • branches/playability.new/src/world_entities/camera.h

    r9869 r10362  
    3636
    3737  Camera();
     38  Camera(const TiXmlElement* root);
    3839  virtual ~Camera();
    3940
     
    4344
    4445  void setAspectRatio(float aspectRatio);
     46  inline float getAspectRatio() {return this->aspectRatio;};
     47
    4548  void setClipRegion(float nearClip, float farClip);
    4649
    4750  /** @param fovy new field of view factor (in degrees) */
    48   void setFovy(float fovy) { this->fovy = fovy; };
     51  inline void setFovy(float fovy)
     52  {
     53    this->fovy = fovy;
     54    this->toFovy = fovy;
     55  };
     56
     57  inline float getFovy() {return this->fovy;};
    4958  /** @param fovy new field of view factor (in degrees) to iterate to */
    5059  void setToFovy(float toFovy) { this->toFovy = toFovy; };
     
    5867  inline float distance(const PNode* node) const { return distance(node->getAbsCoor()); }
    5968
     69  inline void setEventHandling(bool b) {this->eventHandling = b;}
     70  inline bool getEventHandling() {return this->eventHandling;}
     71
    6072  void tick(float dt);
    6173  void apply ();
     
    6476  void process(const Event &event);
    6577
     78  //virtual void loadParams(const TiXmlElement* root);
     79
     80  void              setViewTopFovy(float fovy);
     81  void              setViewLeftFovy(float fovy);
     82  void              setViewRightFovy(float fovy);
     83  void              setViewBehindFovy(float fovy);
     84  void              setViewFrontFovy(float fovy);
     85  void              setViewNormalFovy(float fovy);
     86
     87  void              setViewTopDistance(float Distance);
     88  void              setViewLeftDistance(float Distance);
     89  void              setViewRightDistance(float Distance);
     90  void              setViewBehindDistance(float Distance);
     91  void              setViewFrontDistance(float Distance);
     92  void              setViewNormalDistance(float Distance);
     93
    6694private:
     95
     96  void              init();
     97
    6798  CameraTarget*     target;          //!< The Target of the Camera (where this Camera Looks at)
     99
     100  bool              eventHandling;    //!< True, if the Camera handles the processing of events itself. Set false to overwrite the standard handling.
    68101
    69102  float             fovy;            //!< The field of view Angle (in degrees).
     
    79112  Vector            viewVector;      //!< the direction of the camera view
    80113  Vector            upVector;        //!< direction of the up vector
     114
     115  float             viewTopFovy;
     116  float             viewLeftFovy;
     117  float             viewRightFovy;
     118  float             viewBehindFovy;
     119  float             viewFrontFovy;
     120  float             viewNormalFovy;
     121
     122  float             viewTopDistance;
     123  float             viewLeftDistance;
     124  float             viewRightDistance;
     125  float             viewBehindDistance;
     126  float             viewFrontDistance;
     127  float             viewNormalDistance;
     128 
    81129};
    82130
  • branches/playability.new/src/world_entities/elements/glgui_energywidget.h

    r8988 r10362  
    2626    void setValue(float value);
    2727
     28    inline GLGuiWidget* getNameWidget() {return &this->_name;};
     29    inline GLGuiWidget* getValueWidget() {return &this->_valueText;};
     30    inline GLGuiWidget* getBarWidget() {return &this->_bar;};
     31
    2832  protected:
    2933    virtual void resize();
  • branches/playability.new/src/world_entities/elements/glgui_radar.cc

    r10317 r10362  
    122122          this->_dotLists[i].positions.push_back(Vector2D(((*it)->getAbsCoor().x - _centerNode->getAbsCoor().x) * this->getSizeX2D() ,
    123123                                                 ((*it)->getAbsCoor().z - _centerNode->getAbsCoor().z) * this->getSizeY2D()  )
    124                                                  / (2.0f * _range));
     124                                                 / (3.0f * _range));
    125125        }
    126126
  • branches/playability.new/src/world_entities/particles/particle_emitter.h

    r9869 r10362  
    3636  void start();
    3737  void stop();
    38   void tick(float dt);
     38  virtual void tick(float dt);
    3939
    4040  void setSystem(ParticleSystem* system);
     
    7474  float           momentumRandom;    //!< The random variation of the Momentum.
    7575
    76 private:
     76//private:
    7777  ParticleSystem* system;            //!< The ParticleSystem this Emitter Emits into.
    7878  float           saveTime;          //!< The time that was missing by the last Tick (otherwise there would be no emission when framefate is too big).
  • branches/playability.new/src/world_entities/playable.cc

    r9869 r10362  
    4444
    4545Playable::Playable()
    46     : weaponMan(this),
    47     supportedPlaymodes(Playable::Full3D),
     46    : weaponMan(this)
     47    ,supportedPlaymodes(Playable::Full3D),
    4848    playmode(Playable::Full3D)
    4949{
  • branches/playability.new/src/world_entities/playable.h

    r9869 r10362  
    7171  void setCameraMode(unsigned int cameraMode = 0);
    7272  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
    73   bool setPlaymode(Playable::Playmode playmode);
     73  virtual bool setPlaymode(Playable::Playmode playmode);
    7474  Playable::Playmode getPlaymode() const { return this->playmode; };
    7575  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
     
    117117  void unregisterEvent(int eventType);
    118118
     119protected:
     120  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
     121  bool                  bFire;              //!< If the Ship is firing.
     122  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
     123  Playable::Playmode    playmode;           //!< The current playmode.
     124
    119125private:
    120   WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
    121126  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
    122127
    123128  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
    124129
    125   bool                  bFire;              //!< If the Ship is firing.
    126130  int                   oldFlags;           //!< Used for synchronisation
    127131
     
    131135
    132136  bool                  bDead;
    133   short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
    134   Playable::Playmode    playmode;           //!< The current playmode.
    135137
    136138  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
  • branches/playability.new/src/world_entities/player.cc

    r9869 r10362  
    1616#include "player.h"
    1717#include "playable.h"
     18#include "space_ships/space_ship.h"
    1819
    1920#include "event_handler.h"
     
    7374    PRINTF(4)("Enter new Playable\n");
    7475    this->playable = playable;
    75     this->_hud.setEnergyWidget(this->playable->getHealthWidget());
    76     this->_hud.setWeaponManager(&this->playable->getWeaponManager());
     76    this->_hud.setArmorWidget(this->playable->getHealthWidget());
     77    if (dynamic_cast<SpaceShip*>(this->playable) != 0)
     78      this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary());
     79    else
     80      this->_hud.setWeaponManager(&this->playable->getWeaponManager());
    7781
    7882    this->playable->setPlayer(this);
     
    9498void Player::weaponConfigChanged()
    9599{
    96   this->_hud.updateWeaponManager();
     100  //this->_hud.updateWeaponManager();
     101
     102  if (dynamic_cast<SpaceShip*>(this->playable) != 0)
     103      this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary());
     104    else
     105      this->_hud.setWeaponManager(&this->playable->getWeaponManager());
    97106}
    98107
     
    128137}
    129138
     139
  • branches/playability.new/src/world_entities/player.h

    r9869 r10362  
    1 /*!
     1 /*!
    22 * @file player.h
    33 * Implements a basic playable WorldEntity
     
    4646  private:
    4747    Playable*         playable;                 //!< The one we controll or NULL if none
    48     Hud               _hud;                      //!< The HUD to be displayed for this Player.
     48    Hud               _hud;                     //!< The HUD to be displayed for this Player.
    4949};
    5050
  • branches/playability.new/src/world_entities/projectiles/projectile.cc

    r10013 r10362  
    2525#include "playable.h"
    2626
     27#include <cmath>
     28
    2729#include "debug.h"
    2830
     
    4648  this->subscribeReaction( CoRe::CREngine::CR_PHYSICS_FULL_WALK, Playable::staticClassID());
    4749
     50  this->physDamage = 0.0f;
     51  this->elecDamage = 0.0f;
    4852  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    4953}
     
    6064  */
    6165  //delete this->projectileModel;
     66}
     67
     68Projectile::Projectile (float pDamage, float eDamage, PNode* target) : WorldEntity()
     69{
     70  this->registerObject(this, Projectile::_objectList);
     71
     72  this->lifeCycle = 0.0;
     73  this->lifeSpan = 1.0f; /* sec */
     74  this->removeNode();
     75
     76  /* character attributes */
     77  this->setHealth(1.0f);
     78  this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points
     79
     80  this->physDamage = pDamage;
     81  this->elecDamage = eDamage;
     82  this->target = target;
     83
     84  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     85}
     86
     87void Projectile::initialize(float pDamage, float eDamage, PNode* target)
     88{
     89  /* character attributes*/
     90  this->physDamage = pDamage;
     91  this->elecDamage = eDamage;
     92  this->target = target;
    6293}
    6394
     
    124155
    125156
     157void Projectile::collidesWith (WorldEntity* target, const Vector& location)
     158{
     159  dynamic_cast<SpaceShip*>(target)->damage(this->getPhysDamage(),this->getElecDamage());
     160//   this->destroy(NULL);
     161  this->destroy(target);
     162}
     163
     164
     165
    126166/**
    127167 * signal tick, time dependent things will be handled here
     
    130170void Projectile::tick (float dt)
    131171{
    132   Vector v = this->velocity * (dt);
    133   this->shiftCoor(v);
    134 
    135172  if (this->tickLifeCycle(dt))
    136173    this->destroy( NULL );
  • branches/playability.new/src/world_entities/projectiles/projectile.h

    r9869 r10362  
    1212#include "world_entity.h"
    1313#include "loading/fast_factory.h"
     14#include "space_ships/space_ship.h"
    1415
    1516#include "sound_source.h"
     
    2223    Projectile ();
    2324    virtual ~Projectile ();
     25
     26    /** @brief Constructor with variable passing*/
     27    Projectile (float pDamage, float eDamage, PNode* target);
     28    /** @brief for void construction; setting values later - needed for FastFactory*/
     29    virtual void initialize(float pDamage, float eDamage, PNode* target);
    2430
    2531    void setFlightDirection(const Quaternion& flightDirection);
     
    4450    virtual void destroy (WorldEntity* killer);
    4551
     52    virtual void collidesWith (WorldEntity* target, const Vector& location);  //!< collision handler; used against SpaceShip as most target will be
     53
     54
    4655    virtual void tick (float dt);
    4756    /** @brief convenience function
     
    5059    inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); }
    5160
     61    inline float getPhysDamage() { return this->physDamage; };
     62    inline float getElecDamage() { return this->elecDamage; };
     63
     64    inline void setPhysDamage( float dmg) {this->physDamage = dmg; };
     65    inline void setElecDamage( float dmg) {this->elecDamage = dmg; };
    5266
    5367  protected:
    5468    // energy
    55     float                  energyMin;                 //!< The minimal Energy a Projectile needs to be emitted.
    56     bool                   bChargeable;               //!< if the Projectile is Charegeable
     69    int                origList;                        //!< FIXME currently a fix around the collision seg fault
     70    float                   energyMin;                //!< The minimal Energy a Projectile needs to be emitted.
     71    bool                    bChargeable;              //!< if the Projectile is Charegeable
    5772
    58     float                  lifeCycle;                 //!< The percentage of the Lifetime done [0-1]
    59     float                  lifeSpan;                  //!< The entire lifespan of the Shoot. in seconds
     73    float                   lifeCycle;                //!< The percentage of the Lifetime done [0-1]
     74    float                   lifeSpan;                 //!< The entire lifespan of the Shoot. in seconds
    6075
    61     Vector                 flightDirection;           //!< DOF direction in which the shoot flighs
     76    float                   physDamage;               //!< damage to shield and armor
     77    float                   elecDamage;               //!< damage to elctronic
     78    float                   turningSpeed;             //!< degrees per tick
    6279
    63     Vector                 velocity;                  //!< velocity of the projectile.
     80    Vector                  flightDirection;          //!< DOF direction in which the shoot flighs
    6481
    65     PNode*                 target;                    //!< A target for guided Weapons.
     82    Vector                  velocity;                 //!< velocity of the projectile.
     83
     84    PNode*                  target;                   //!< A target for guided Weapons.
    6685
    6786    OrxSound::SoundSource  soundSource;
  • branches/playability.new/src/world_entities/space_ships/space_ship.cc

    r10317 r10362  
    2323
    2424#include "weapons/test_gun.h"
     25#include "weapons/light_blaster.h"
     26#include "weapons/medium_blaster.h"
     27#include "weapons/heavy_blaster.h"
     28#include "weapons/swarm_launcher.h"
     29#include "weapons/spike_launcher.h"
     30#include "weapons/spike_thrower.h"
     31#include "weapons/acid_launcher.h"
     32#include "weapons/boomerang_gun.h"
    2533#include "weapons/turret.h"
    2634#include "weapons/cannon.h"
    2735
     36#include "elements/glgui_energywidgetvertical.h"
     37#include "glgui_bar.h"
     38
    2839#include "particles/dot_emitter.h"
     40#include "particles/emitter_node.h"
    2941#include "particles/sprite_particles.h"
     42#include "effects/trail.h"
     43
     44#include "effects/wobblegrid.h"
    3045
    3146#include "util/loading/factory.h"
     
    4459#include "state.h"
    4560#include "player.h"
     61#include "camera.h"
     62
    4663
    4764#include "util/loading/load_param.h"
     65#include "time.h"
     66
     67#include "track/track.h"
     68#include "math.h"
    4869
    4970
    5071// #include "lib/gui/gl_gui/glgui_bar.h"
    5172// #include "lib/gui/gl_gui/glgui_pushbutton.h"
    52 
    5373
    5474
     
    7090                        ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
    7191                        ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
     92                        //->addMethod("setCameraSpeed", Executor1<SpaceShip, lua_State*, float>(&SpaceShip::setCameraSpeed))
    7293                       );
    7394
     
    85106 */
    86107SpaceShip::SpaceShip(const std::string& fileName)
     108    : secWeaponMan(this) //,
     109    //supportedPlaymodes(Playable::Vertical) ,
     110    //playmode(Playable::Vertical)
    87111{
    88112  this->init();
     
    105129*/
    106130SpaceShip::SpaceShip(const TiXmlElement* root)
     131    : secWeaponMan(this) //,
     132    //supportedPlaymodes(Playable::Vertical) ,
     133    //playmode(Playable::Vertical)
    107134{
    108135  this->init();
     136  //this->setParentMode(PNODE_REPARENT_DELETE_CHILDREN);
    109137  if (root != NULL)
    110138    this->loadParams(root);
     
    118146void SpaceShip::init()
    119147{
     148
     149  srand(time(0));   //initialize Random Nomber Generator
     150
    120151  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    121152  this->registerObject(this, SpaceShip::_objectList);
    122 
    123153  PRINTF(4)("SPACESHIP INIT\n");
    124 
     154  this->weaponMan.setParentEntity( this);
    125155  //weapons:
    126   Weapon* wpRight = new TestGun(0);
    127   wpRight->setName("testGun Right");
    128   Weapon* wpLeft = new TestGun(1);
    129   wpLeft->setName("testGun Left");
    130   //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON));
    131 
    132   //cannon->setName("BFG");
    133 
    134   this->addWeapon(wpLeft, 1, 0);
    135   this->addWeapon(wpRight,1 ,1);
    136   //this->addWeapon(cannon, 0, 6);
    137 
    138   this->getWeaponManager().changeWeaponConfig(1);
    139 
    140   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    141 
    142   xMouse = yMouse = 0;
    143   yInvert = 1;
    144   mouseSensitivity = 0.001;
    145   airViscosity = 0.9;
    146   controlVelocityX = 25;
    147   controlVelocityY = 150;
    148   shipInertia = 1.5;
    149   //  cycle = 0.0;
    150 
    151   this->setHealthMax(100);
    152   this->setHealth(80);
    153 
    154   travelSpeed = 0.0;
    155   acceleration = 3;
    156   this->velocity = this->getAbsDirX()*travelSpeed;
    157   this->mouseDir = this->getAbsDir();
    158   this->pitchDir = this->getAbsDir();
    159 
    160   //   GLGuiButton* button = new GLGuiPushButton();
    161   //    button->show();
    162   //    button->setLabel("orxonox");
    163   //    button->setBindNode(this);
    164   //     GLGuiBar* bar = new GLGuiBar();
    165   //     bar->show();
    166   //     bar->setValue(7.0);
    167   //     bar->setMaximum(10);
    168   //     bar->setSize2D( 20, 100);
    169   //     bar->setAbsCoor2D( 10, 200);
     156 
     157  Weapon* wpRight1 = new LightBlaster ();
     158  wpRight1->setName( "LightBlaster");
     159  Weapon* wpLeft1 = new LightBlaster ();
     160  wpLeft1->setName( "LightBlaster");
     161
     162  Weapon* wpRight2 = new MediumBlaster ();
     163  wpRight2->setName( "MediumBlaster");
     164  Weapon* wpLeft2 = new MediumBlaster ();
     165  wpLeft2->setName( "MediumBlaster");
     166
     167  Weapon* wpRight3 = new HeavyBlaster (1);
     168  wpRight3->setName( "HeavyBlaster");
     169  Weapon* wpLeft3 = new HeavyBlaster (0);
     170  wpLeft3->setName( "HeavyBlaster");
     171
     172  Weapon* cannon = new SwarmLauncher();
     173  cannon->setName( "SwarmLauncher");
     174
     175  Weapon* spike = new SpikeThrower();
     176  spike->setName( "SpikeThrower" );
     177
     178
     179  Weapon* acid0 = new AcidLauncher();
     180  acid0->setName( "AcidSplasher" );
     181
     182  Weapon* acid1 = new AcidLauncher();
     183  acid1->setName( "AcidSplasher" );
     184
     185
     186  this->weaponMan.addWeapon( wpLeft1, 0, 0);
     187  this->weaponMan.addWeapon( wpRight1, 0, 1);
     188
     189  this->weaponMan.addWeapon( wpLeft2, 1, 2);
     190  this->weaponMan.addWeapon( wpRight2, 1, 3);
     191
     192  this->weaponMan.addWeapon( wpLeft3, 2, 4);
     193  this->weaponMan.addWeapon( wpRight3, 2, 5);
     194/*
     195  this->weaponMan.addWeapon( wpLeft1, 3, 0);
     196  this->weaponMan.addWeapon( wpRight1, 3, 1);
     197
     198  this->weaponMan.addWeapon( wpLeft2, 3, 2);
     199  this->weaponMan.addWeapon( wpRight2, 3, 3);
     200
     201  this->weaponMan.addWeapon( wpLeft3, 3, 4);
     202  this->weaponMan.addWeapon( wpRight3, 3, 5);
     203*/
     204
     205  this->weaponMan.addWeapon( acid0, 3, 0);
     206  this->weaponMan.addWeapon( acid1, 3, 1);
     207
     208
     209  this->secWeaponMan.addWeapon( cannon, 0, 2);
     210  this->secWeaponMan.addWeapon( spike, 1, 3);
     211//   this->secWeaponMan.addWeapon( acid0, 2, 2);
     212//   this->secWeaponMan.addWeapon( acid1, 2, 3);
     213
     214
     215  this->weaponMan.changeWeaponConfig(3);
     216  this->secWeaponMan.changeWeaponConfig(1);
     217
     218  curWeaponPrimary    = 0;
     219  curWeaponSecondary  = 1;
     220
     221  Playable::weaponConfigChanged();
     222
     223  reactorOutput     = 10;
     224
     225  weaponEnergyRegen = 10;       // 10 einheiten pro Sekunde
     226  engineSpeedBase   = 5;
     227  shieldRegen       = 2;
     228
     229  shieldEnergyShare = 0.3;
     230  weaponEnergyShare = 0.3;
     231  engineEnergyShare = 0.4;
     232
     233  shieldCur         = 20;
     234  shieldMax         = 100;
     235  shieldTH          = .2 * shieldMax;   // shield power must be 20% before shield kicks in again
     236
     237  this->setHealth( 20);
     238  this->setHealthMax( 100);
     239
     240  electronicCur = 50;
     241  electronicMax = 50;
     242  electronicRegen   = 3;
     243  electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship
     244
     245
     246  this->loadModel("models/ships/mantawing.obj");
     247  //this->setVisibiliy(false);
     248
     249  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
     250
     251  this->setHealthMax(shieldMax);
     252  this->setHealth(shieldCur);
     253
     254  this->travelNode = new PNode();
     255
     256  // camera - issue
     257  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     258  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
     259
     260  // widget handling
     261  /*
     262  this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     263  this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
     264  this->electronicWidget->setSize2D(30,400);
     265  this->electronicWidget->setAbsCoor2D(150,200);
     266  this->electronicWidget->shiftDir2D(270);
     267  this->updateElectronicWidget();
     268  this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     269  this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:");
     270  this->shieldWidget->setSize2D(30,400);
     271  this->shieldWidget->setAbsCoor2D(200,200);
     272  this->shieldWidget->shiftDir2D(270);
     273  this->updateShieldWidget();
     274  if (this->hasPlayer())
     275  {
     276    State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     277    State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     278  }
     279  */
     280  this->electronicWidget = NULL;
     281  this->shieldWidget = NULL;
    170282
    171283  //add events to the eventlist
     
    177289  //registerEvent(SDLK_e);
    178290  registerEvent(KeyMapper::PEV_FIRE1);
     291  registerEvent(KeyMapper::PEV_FIRE2);                  // Added for secondary weapon support
    179292  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
    180293  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
     
    183296  registerEvent(EV_MOUSE_MOTION);
    184297
    185   this->getWeaponManager().setSlotCount(7);
    186 
    187   this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
    188   this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    189 
    190   this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
    191   this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    192 
    193   this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
    194   this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    195 
    196   this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
    197   this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    198 
    199   this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
    200   this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    201 
    202   this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
    203   this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    204   //
    205   this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
    206   this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    207   //
    208   //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    209   //   this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    210   //
    211   //   this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    212   //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    213 
    214   this->getWeaponManager().getFixedTarget()->setParent(this);
    215   this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
    216 
    217   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    218 
    219   this->burstEmitter = new DotEmitter(200, 0.0, .01);
    220   this->burstEmitter->setParent(this);
    221   this->burstEmitter->setRelCoor(-1, .5, 0);
    222   this->burstEmitter->setName("SpaceShip_Burst_emitter");
     298  this->weaponMan.setParentEntity( this);
     299  this->secWeaponMan.setParentEntity( this);
     300
     301  this->weaponMan.setSlotCount(8);
     302
     303  this->weaponMan.setSlotPosition(0, Vector(0.0, 0, -3.0));
     304  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     305
     306  this->weaponMan.setSlotPosition(1, Vector(0.0, 0, 3.0));
     307  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     308
     309  this->weaponMan.setSlotPosition(2, Vector(1.0, 0, -1.5));
     310  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     311
     312  this->weaponMan.setSlotPosition(3, Vector(1.0, 0, 1.5));
     313  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     314
     315  this->weaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
     316  this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     317
     318  this->weaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
     319  this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
     320
     321  this->weaponMan.setSlotPosition(6, Vector(0.5, 0, 2.5));
     322  this->weaponMan.setSlotDirection(6, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     323
     324  this->weaponMan.setSlotPosition(7, Vector(0.5, 0, -2.5));
     325  this->weaponMan.setSlotDirection(7, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    223326
    224327  this->burstSystem = new SpriteParticles(1000);
     
    236339  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    237340
    238   registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
    239   registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
    240 
    241   registerVar( new SynchronizeableBool( &bUp, &bUp, "bUp", PERMISSION_OWNER ) );
    242   registerVar( new SynchronizeableBool( &bDown, &bDown, "bDown", PERMISSION_OWNER ) );
     341  this->secWeaponMan.setSlotPosition(0, Vector(1.5, 0, 0));
     342  this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     343
     344  this->secWeaponMan.setSlotPosition(1, Vector(2.6, 0, 3.0));
     345  this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     346
     347  this->secWeaponMan.setSlotPosition(2, Vector(1.5, 0, -.5));
     348  this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     349
     350  this->secWeaponMan.setSlotPosition(3, Vector(1.5, 0, .5));
     351  this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     352
     353  this->secWeaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
     354  this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     355
     356  this->secWeaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
     357  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
     358
     359
     360  this->weaponMan.getFixedTarget()->setParent(this);
     361  this->weaponMan.getFixedTarget()->setRelCoor(100000,0,0);
     362
     363 
     364  this->secWeaponMan.getFixedTarget()->setParent(this);
     365  this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
     366  this->secWeaponMan.setRotationSpeed(0);
     367
     368  dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false);
     369
     370
     371  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     372  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
    243373  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
    244374  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
    245   registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
    246   registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
    247   registerVar( new SynchronizeableBool( &bRollL, &bRollL, "bRollL", PERMISSION_OWNER ) );
    248   registerVar( new SynchronizeableBool( &bRollR, &bRollR, "bRollR", PERMISSION_OWNER ) );
     375  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
     376  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
     377  registerVar( new SynchronizeableBool( &bFire, &bFire, "bSecFire", PERMISSION_OWNER));
     378  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
     379
     380  //this->airFriction = 0.5f;
     381  //this->travelDistancePlus = Vector2D(38.0, 43.0);
     382  //this->travelDistanceMinus = Vector2D(-38.0, -43.0);
     383  this->travelDistancePlus = Vector2D(50,50);
     384  this->travelDistanceMinus = Vector2D(-50,-50);
     385  this->isTravelDistanceInit = true;
     386  this->actionWidthPercentage = 1;
     387
     388  this->cameraSpeed = 40;
     389  this->cameraLook = 0.0f;
     390  //this->airFriction = 0.0f;
     391
     392  srand(time(0));  //initaialize RNG
     393
     394  this->travelNode->debugDraw();
     395
     396  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
     397
     398  /// FIXME
     399  this->trail = new Trail( 5, 10, .2, this);
     400  this->trail->setTexture( "maps/engine.png");
     401
     402  this->trailL = new Trail( 5, 10, .2, this);
     403  this->trailL->setTexture( "maps/engine.png");
     404
     405  this->trailR = new Trail( 5, 10, .2, this);
     406  this->trailR->setTexture( "maps/engine.png");
     407
     408
     409  this->toList(OM_GROUP_00);
     410
     411  //FIXME Just testaddition to show the wobblegrid
     412/*
     413  this->test  = new Wobblegrid(5);
     414  test->setTexture("maps/blub.png");
     415 
     416  test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));
     417  test->setParent( this);
     418*/
     419 
    249420}
    250421
     
    257428{
    258429  Playable::loadParams(root);
    259 }
    260 
    261 void SpaceShip::setPlayDirection(const Quaternion& quat, float speed)
    262 {
    263   this->mouseDir = quat;
    264 }
    265 
     430
     431  LoadParam(root, "playmode", this, SpaceShip, setPlaymodeXML);
     432  LoadParam(root, "cameraDistance", this, SpaceShip, setCameraDistance);
     433  LoadParam(root, "cameraFovy", this, SpaceShip, setCameraFovy);
     434  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
     435
     436  State::getCamera()->setViewMode(Camera::ViewTop);
     437}
     438
     439
     440void SpaceShip::setPlayDirection(const Quaternion& rot, float speed)
     441{
     442  //this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
     443}
    266444
    267445void SpaceShip::reset()
    268446{
    269   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    270 
    271   xMouse = yMouse = 0;
     447  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
     448
     449  //xMouse = yMouse = 0;
    272450
    273451  this->setHealth(80);
     
    278456void SpaceShip::enter()
    279457{
    280   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
    281   this->attachCamera();
     458  this->secWeaponMan.showCrosshair();
     459  this->toList( OM_GROUP_01 );
     460  State::getPlayer()->hud().setRadarCenterNode(this->travelNode);
     461  State::getPlayer()->hud().setOverlayActive(true);
     462  //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
     463  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
     464  //this->attachCamera();
     465 // this->setPlaymode(Playable::Horizontal);
    282466}
    283467
    284468void SpaceShip::leave()
    285469{
    286   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    287   this->detachCamera();
     470  this->secWeaponMan.hideCrosshair();
     471  this->toList( OM_GROUP_00);
     472  State::getPlayer()->hud().setOverlayActive(false);
     473  State::getCamera()->setEventHandling(true);
     474  State::getPlayer()->hud().setRadarCenterNode(NULL);
     475  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
     476  //this->detachCamera();
    288477}
    289478
     
    294483void SpaceShip::postSpawn ()
    295484{
     485  if(this->hasPlayer())
     486    Playable::postSpawn();
     487
    296488  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    297489}
     
    301493*/
    302494void SpaceShip::leftWorld ()
    303 {}
     495{
     496
     497}
    304498
    305499WorldEntity* ref = NULL;
    306 /**
    307  *  this function is called, when two entities collide
    308  * @param entity: the world entity with whom it collides
    309  *
    310  * Implement behaviour like damage application or other miscellaneous collision stuff in this function
    311  */
    312 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
    313 {
    314 }
    315500
    316501/**
     
    321506  WorldEntity::draw();
    322507
     508  glMatrixMode(GL_MODELVIEW);
     509  glPushMatrix();
     510
     511  float matrix[4][4];
     512  glTranslatef (this->getAbsCoor ().x-1, this->getAbsCoor ().y-.2, this->getAbsCoor ().z);
     513  this->getAbsDir().matrix (matrix);
     514  glMultMatrixf((float*)matrix);
     515  //glScalef(2.0, 2.0, 2.0);  // no double rescale
     516        // FIXME
     517  this->trail->draw();
     518 
     519  glTranslatef(0,0,-.5);
     520  this->trailL->draw();
     521
     522  glTranslatef(0,0,1);
     523  this->trailR->draw();
     524
     525  glPopMatrix();
    323526  //this->debug(0);
    324527}
     
    330533void SpaceShip::tick (float time)
    331534{
    332   Playable::tick(time);
    333 
    334   if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
    335   {
    336     if (xMouse > controlVelocityX) xMouse = controlVelocityX;
    337     else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
    338     if (yMouse > controlVelocityY) yMouse = controlVelocityY;
    339     else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
    340 
    341     pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
    342 
    343     mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
    344     xMouse = yMouse = 0;
    345   }
    346 
    347 
    348   //   if( this != State::getPlayer()->getControllable())
    349   //     return;
    350 
    351   // spaceship controlled movement fire(bool bF){ this->bFire = bF;}
    352   //if (this->getOwner() == this->getHostID())
    353   this->calculateVelocity(time);
    354 
    355 
    356   Vector move = velocity*time;
    357 
    358   //orient the velocity in the direction of the spaceship.
    359   travelSpeed = velocity.len();
    360   velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    361   velocity = (velocity.getNormalized())*travelSpeed;
    362   this->burstEmitter->setEmissionRate(travelSpeed);
    363   this->burstEmitter->setEmissionVelocity(travelSpeed*.5, travelSpeed *.1);
     535  // Playable::tick(time);
     536
     537 // this->test->tick(time);
     538
     539  // Own Tick Setup, as a different fire routine is used on the weapon manager
     540  this->weaponMan.tick(time);
     541  this->secWeaponMan.tick(time);
     542
     543  if( this->systemFailure() )
     544    bFire = bSecFire = false;
     545
     546  // fire reqeust/release for primary weapons
     547  if( this->bFire)
     548    this->weaponMan.fire();
     549  else
     550    this->weaponMan.releaseFire();
     551
     552  // fire reqeust/release for secondary weapons
     553  if( this->bSecFire)
     554    this->secWeaponMan.fire();
     555  else
     556    this->secWeaponMan.releaseFire();
     557   
     558  // Tracktick
     559  if(this->entityTrack)
     560    this->entityTrack->tick(time);
     561
     562
     563  // Shield Regeneration and other regular calculations on the ship
     564  this->regen(time);
     565
     566  // Weapon Regeneration and other regular calculations on the ship
     567  this->weaponRegen(time);
     568
     569  // current engine speed output
     570  this->engineSpeedCur = this->engineSpeedBase + this->reactorOutput * this->engineEnergyShare;
     571
     572  // calculation of maxSpeed and acceleration:
     573  this->travelSpeed = this->engineSpeedCur * 5;
     574  this->acceleration = this->travelSpeed * 2;
     575
     576  this->movement(time);
     577
     578   // TRYING TO FIX PNode.
     579  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
     580  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
     581
     582 
     583  this->velocity  = (this->getAbsCoor() - this->oldPos) / time;
     584  this->oldPos    = this->getAbsCoor();
     585
     586//FIXME
     587  this->trail->tick(time);
     588  this->trailL->tick(time);
     589  this->trailR->tick(time);
     590
     591  if (!this->isTravelDistanceInit)
     592  {
     593    this->updateTravelDistance();
     594    //this->isTravelDistanceInit = true;
     595  }
    364596
    365597  //orient the spaceship in direction of the mouse
     598  /*
    366599  rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
    367600  if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
    368601    this->setAbsDir( rotQuat);
    369602  //this->setAbsDirSoft(mouseDir,5);
    370 
    371   // this is the air friction (necessary for a smooth control)
    372   if(travelSpeed >= 120) velocity -= velocity.getNormalized()*travelSpeed*travelSpeed*0.0001;
    373   else if (travelSpeed <= 80) velocity -= velocity.getNormalized()*travelSpeed*0.001;
    374 
    375   //other physics (gravity)
    376   //if(travelSpeed < 120)
    377   //move += Vector(0,-1,0)*60*time + Vector(0,1,0)*travelSpeed/2*time;
    378 
    379   //hoover effect
    380   //cycle += time;
    381   //this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    382 
    383   //readjust
    384   //if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
    385   //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    386 
    387   //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    388 
     603  */
     604  /*
    389605  this->shiftCoor(move);
     606  */
    390607
    391608  //   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
    392609
    393 }
    394 
    395 /**
    396  *  calculate the velocity
    397  * @param time the timeslice since the last frame
    398 */
    399 void SpaceShip::calculateVelocity (float time)
    400 {
    401   Vector accel(0.0, 0.0, 0.0);
    402   /*
    403   Vector rot(0.0, 0.0, 0.0); // wird ben�igt fr Helicopter
    404   */
    405   //float rotVal = 0.0;
    406   /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    407   /* calculate the direction in which the craft is heading  */
    408 
    409   //Plane plane(Vector(0,1,0), Vector(0,0,0));
    410 
    411   if( this->bUp )
    412   {
    413     //this->shiftCoor(this->getAbsDirX());
    414     //accel += (this->getAbsDirX())*2;
    415     accel += (this->getAbsDirX())*acceleration;
    416 
    417   }
    418 
    419   if( this->bDown )
    420   {
    421     //this->shiftCoor((this->getAbsDirX())*-1);
    422     //accel -= (this->getAbsDirX())*2;
    423     //if(velocity.len() > 50)
    424     accel -= (this->getAbsDirX())*0.5*acceleration;
    425 
    426 
    427 
    428   }
    429 
    430   if( this->bLeft/* > -this->getRelCoor().z*2*/)
    431   {
    432     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    433     //    accel -= rightDirection;
    434     //velocityDir.normalize();
    435     //rot +=Vector(1,0,0);
    436     //rotVal -= .4;
    437   }
    438   if( this->bRight /* > this->getRelCoor().z*2*/)
    439   {
    440     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    441 
    442     //    accel += rightDirection;
    443     //velocityDir.normalize();
    444     //rot += Vector(1,0,0);
    445     //rotVal += .4;
    446   }
    447 
    448 
    449   if( this->bRollL /* > -this->getRelCoor().z*2*/)
    450   {
    451     mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    452     //    accel -= rightDirection;
    453     //velocityDir.normalize();
    454     //rot +=Vector(1,0,0);
    455     //rotVal -= .4;
    456   }
    457   if( this->bRollR /* > this->getRelCoor().z*2*/)
    458   {
    459     mouseDir *= Quaternion(time*2, Vector(1,0,0));
    460 
    461     //    accel += rightDirection;
    462     //velocityDir.normalize();
    463     //rot += Vector(1,0,0);
    464     //rotVal += .4;
    465   }
    466   if (this->bAscend )
    467   {
    468     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    469 
    470     //    accel += upDirection;
    471     //velocityDir.normalize();
    472     //rot += Vector(0,0,1);
    473     //rotVal += .4;
    474   }
    475   if (this->bDescend )
    476   {
    477     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    478 
    479     //    accel -= upDirection;
    480     //velocityDir.normalize();
    481     //rot += Vector(0,0,1);
    482     //rotVal -= .4;
    483   }
    484 
    485   velocity += accel*time*10;
    486   //rot.normalize();
    487   //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
    488610}
    489611
     
    493615void SpaceShip::process(const Event &event)
    494616{
    495   Playable::process(event);
    496 
     617  //Playable::process(event);
     618 
    497619  if( event.type == KeyMapper::PEV_LEFT)
    498     this->bRollL = event.bPressed;
     620    this->bLeft = event.bPressed;
    499621  else if( event.type == KeyMapper::PEV_RIGHT)
    500     this->bRollR = event.bPressed;
     622  {
     623    this->bRight = event.bPressed;
     624    printf("ShipCoorX: %f \n", this->getRelCoor().x);
     625  }
    501626  else if( event.type == KeyMapper::PEV_FORWARD)
    502     this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     627  {
     628    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
     629   
     630  }
    503631  else if( event.type == KeyMapper::PEV_BACKWARD)
    504     this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
     632    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
     633  else if( event.type == KeyMapper::PEV_FIRE2)
     634    this->bSecFire = event.bPressed;
     635  else if( event.type == KeyMapper::PEV_FIRE1)
     636    this->bFire = event.bPressed;
     637  else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)
     638  {
     639    this->nextWeaponConfig();
     640  }
     641  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
     642    this->previousWeaponConfig();
     643
     644  if (!(State::getCamera()->getEventHandling()))
     645  {
     646    if( event.type == KeyMapper::PEV_VIEW0)
     647    {
     648      State::getCamera()->setViewMode(Camera::ViewNormal);
     649      State::getCameraTargetNode()->setParent(this);
     650      State::getCamera()->setParent(this);
     651    }
     652    else if( event.type == KeyMapper::PEV_VIEW1)
     653    {
     654      State::getCamera()->setViewMode(Camera::ViewBehind);
     655      State::getCameraTargetNode()->setParent(this);
     656      State::getCamera()->setParent(this);
     657    }
     658    else if( event.type == KeyMapper::PEV_VIEW2)
     659    {
     660      State::getCamera()->setViewMode(Camera::ViewFront);
     661      State::getCameraTargetNode()->setParent(this);
     662      State::getCamera()->setParent(this);
     663    }
     664    else if( event.type == KeyMapper::PEV_VIEW3)
     665    {
     666      State::getCamera()->setViewMode(Camera::ViewLeft);
     667      State::getCameraTargetNode()->setParent(this);
     668      State::getCamera()->setParent(this);
     669    }
     670    else if( event.type == KeyMapper::PEV_VIEW4)
     671    {
     672      State::getCamera()->setViewMode(Camera::ViewRight);
     673      State::getCameraTargetNode()->setParent(this);
     674      State::getCamera()->setParent(this);
     675    }
     676    else if( event.type == KeyMapper::PEV_VIEW5)
     677    {
     678      State::getCamera()->setViewMode(Camera::ViewTop);
     679      State::getCameraTargetNode()->setParent(this->travelNode);
     680      State::getCamera()->setParent(this->travelNode);
     681    }
     682  }
     683
     684
     685  /*
    505686  else if( event.type == EV_MOUSE_MOTION)
    506687  {
     688
    507689    this->xMouse += event.xRel;
    508690    this->yMouse += event.yRel;
    509691  }
     692  */
    510693}
    511694
    512695void SpaceShip::destroy( WorldEntity* killer )
    513696{
    514   PRINTF(0)("spaceship destroy\n");
     697  if(this->hasPlayer())
     698    Playable::destroy( killer);
     699
     700  PRINTF(5)("spaceship destroy\n");
     701
     702  EmitterNode* node  = NULL;
     703  DotEmitter* emitter = NULL;
     704  SpriteParticles*  explosionParticles  = NULL;
     705
     706  explosionParticles = new SpriteParticles(200);
     707  explosionParticles->setName("SpaceShipExplosionParticles");
     708  explosionParticles->setLifeSpan(.2, .3);
     709  explosionParticles->setRadius(0.0, 10.0);
     710  explosionParticles->setRadius(.5, 6.0);
     711  explosionParticles->setRadius(1.0, 3.0);
     712  explosionParticles->setColor(0.0, 1,1,1,.9);
     713  explosionParticles->setColor(0.1,  1,1,0,.9);
     714  explosionParticles->setColor(0.5, .8,.4,0,.5);
     715  explosionParticles->setColor(1.0, .2,.2,.2,.5);
     716
     717 
     718  emitter = new DotEmitter( 2000, 70, 360);
     719  //emitter->setSpread( 0, M_2_PI);
     720  emitter->setEmissionRate( 200.0);
     721  //emitter->setEmissionVelocity( 200.0);
     722  //emitter->setSystem( explosionParticles);
     723  //emitter->setAbsCoor( this->getAbsCoor());
     724
     725  node  = new EmitterNode( .1f);
     726  node->setupParticle( emitter, explosionParticles);
     727  node->setAbsDir( this->getAbsDir());
     728  node->setVelocity( this->getVelocity() * .9f);
     729  node->setAbsCoor( this->getAbsCoor());
     730  if( !node->start())
     731    PRINTF(0)("Explosion node not correctly started!");
     732/*
     733  PNode* node          = new PNode();
     734  node->setAbsCoor(this->getAbsCoor());
     735  Explosion* explosion = new Explosion();
     736  explosion->explode( node, Vector(5,5,5));
     737*/
     738/*
     739  if( this->hasPlayer())
     740  {
     741        this->setAbsCoor(Vector(-10000,10000,10000));
     742        this->hide();
     743  }
     744  else
     745  {*/
     746    this->setAbsCoor( this->getAbsCoor() + Vector(100,0,0) + Vector(1,0,0) * VECTOR_RAND(150).dot(Vector(1,0,0)));
     747  //}
     748
    515749}
    516750
    517751void SpaceShip::respawn( )
    518752{
    519   toList( OM_PLAYERS );
    520 }
    521 
    522 
    523 
    524 
     753  Playable::respawn();
     754}
     755
     756
     757void SpaceShip::damage(float pDamage, float eDamage){
     758  PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage);
     759
     760  if( this->shieldActive) {
     761    if( this->shieldCur > pDamage) {
     762      this->shieldCur = this->shieldCur - pDamage;
     763    }
     764    else { // shield <= pDamage
     765      this->shieldCur -=pDamage;
     766      this->shieldActive = false; //shield collapses
     767      pDamage += this->shieldCur;
     768      if( !this->shieldActive) {
     769        this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
     770        this->electronicCur -= eDamage;
     771      }
     772    }
     773  }
     774  else {
     775    this->armorCur = this->armorCur - pDamage;
     776    this->electronicCur = this->electronicCur - eDamage;
     777  }
     778  if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     779    this->destroy(this);
     780
     781  updateElectronicWidget();
     782  updateShieldWidget();
     783
     784  this->setHealth( this->armorCur);
     785}
     786
     787
     788void SpaceShip::regen(float time){
     789  float tmp;
     790  if (this->armorCur != this->armorMax || this->armorRegen != 0){
     791    tmp = this->armorCur + this->armorRegen * time;
     792    if ( tmp > electronicMax)
     793      this->armorCur = this->armorMax;
     794    else
     795      this->armorCur = tmp;
     796  }
     797  if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){
     798    tmp =  this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time;
     799    if( tmp > shieldMax)
     800      this->shieldCur = this->shieldMax;
     801    else
     802      this->shieldCur = tmp;
     803    this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
     804
     805    updateShieldWidget();
     806  }
     807
     808  this->setHealth( this->shieldCur);      // FIXME currently just to test share system
     809
     810  if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){
     811    tmp = this->electronicCur + this->electronicRegen * time;
     812    if ( tmp > electronicMax)
     813      this->electronicCur = this->electronicMax;
     814    else
     815      this->electronicCur = tmp;
     816
     817    updateElectronicWidget();
     818  }
     819
     820}
     821
     822
     823/**
     824 * Weapon regeneration
     825 * does not use any reactor capacity, as it wouldn't work in a consistent way.
     826 */
     827void SpaceShip::weaponRegen(float time)
     828{
     829  float energy  = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;
     830  Weapon* weapon;
     831  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)
     832  {
     833    weapon = this->weaponMan.getWeapon(i);
     834    if( weapon != NULL && weapon->isActive())
     835    {
     836      weapon->increaseEnergy( energy);
     837    }
     838
     839  }
     840  // weaponMan.increaseAmmunition( weapon, energy);
     841}
     842
     843
     844void SpaceShip::enterPlaymode(Playable::Playmode playmode)
     845{
     846  switch(playmode)
     847  {
     848    case Playable::Full3D:
     849      /*
     850      if (State::getCameraNode != NULL)
     851      {
     852        Vector absCoor = this->getAbsCoor();
     853        this->setParent(PNode::getNullParent());
     854        this->setAbsCoor(absCoor);
     855        State::getCameraNode()->setParentSoft(&this->cameraNode);
     856        State::getCameraNode()->setRelCoorSoft(-10, 0,0);
     857        State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
     858        State::getCameraTargetNode()->setRelCoorSoft(100, 0,0);
     859
     860      }
     861      */
     862      //break;
     863
     864      break;
     865    case Playable::Horizontal:
     866      if (State::getCameraNode != NULL)
     867      {
     868        this->debugNode(1);
     869        this->travelNode->debugNode(1);
     870
     871        this->travelNode->setAbsCoor(this->getAbsCoor());
     872        this->travelNode->updateNode(0.01f);
     873
     874        this->isTravelDistanceInit = false;
     875
     876        if(this->entityTrack)
     877           this->travelNode->setParent(this->entityTrack->getTrackNode());
     878
     879        this->setParent(this->travelNode);
     880        this->setRelCoor(0,0,0);
     881
     882        State::getCameraNode()->setParentSoft(this->travelNode);
     883        //State::getCameraNode()->setParentSoft(this);
     884        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
     885        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     886        //State::getCameraTargetNode()->setParentSoft(this);
     887        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     888        this->setCameraMode(Camera::ViewTop);
     889        State::getCamera()->setEventHandling(false);
     890        registerEvent(KeyMapper::PEV_VIEW0);
     891        registerEvent(KeyMapper::PEV_VIEW1);
     892        registerEvent(KeyMapper::PEV_VIEW2);
     893        registerEvent(KeyMapper::PEV_VIEW3);
     894        registerEvent(KeyMapper::PEV_VIEW4);
     895        registerEvent(KeyMapper::PEV_VIEW5);
     896
     897        State::getCamera()->setParentMode(PNODE_ALL);
     898
     899        //this->updateTravelDistance();
     900
     901        this->debugNode(1);
     902        this->travelNode->debugNode(1);
     903      }
     904      break;
     905
     906    default:
     907      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
     908  }
     909}
     910
     911/**
     912 * @brief calculate the velocity
     913 * @param time the timeslice since the last frame
     914*/
     915
     916void SpaceShip::movement (float dt)
     917{
     918  //by releasing the buttons, the velocity decreases with airCoeff*Acceleration. Should be strong enough so
     919  //the ship doesn't slide too much.
     920  float airCoeff = 2.5;
     921  float pi = 3.14;
     922
     923  switch(this->getPlaymode())
     924  {
     925    case Playable::Horizontal:
     926    {
     927      // these routines will change the travel movement into zero in a short amout of time, if the player
     928      // doesn't press any buttons.
     929      if (this->travelVelocity.x >= 0)
     930      {
     931        if (this->travelVelocity.x > airCoeff*this->acceleration * dt)
     932          this->travelVelocity.x -= airCoeff* this->acceleration * dt;
     933        else
     934          this->travelVelocity.x = 0;
     935      }
     936      else
     937      {
     938        if (this->travelVelocity.x < -airCoeff*this->acceleration * dt)
     939          this->travelVelocity.x += airCoeff* this->acceleration * dt;
     940        else
     941          this->travelVelocity.x = 0;
     942      }
     943      if (this->travelVelocity.z >= 0)
     944      {
     945        if (this->travelVelocity.z > airCoeff*this->acceleration * dt)
     946          this->travelVelocity.z -= airCoeff* this->acceleration * dt;
     947        else
     948          this->travelVelocity.z = 0;
     949      }
     950      else
     951      {
     952        if (this->travelVelocity.z < -airCoeff*this->acceleration * dt)
     953          this->travelVelocity.z += airCoeff* this->acceleration * dt;
     954        else
     955          this->travelVelocity.z = 0;
     956      }
     957   
     958      // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons
     959      // and its continuing to slide a bit.
     960      Vector oldCoor = this->getRelCoor();
     961      if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z);
     962      if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z);
     963      if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y);
     964      if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y);
     965   
     966      if( this->systemFailure() )
     967        bForward = bBackward = bLeft = bRight = false;
     968   
     969      if( this->bForward )
     970      {
     971        //printf("ShipCoorX: %f \n", this->getRelCoor().x);
     972        if(this->getRelCoor().x < this->travelDistancePlus.x)
     973        {
     974          if (this->travelVelocity.x < this->travelSpeed)
     975          {
     976            this->travelVelocity.x += (airCoeff + 1.0)*this->acceleration*dt;
     977          }
     978          else
     979          {
     980            this->travelVelocity.x = this->travelSpeed;
     981          }
     982        }
     983        else
     984        {
     985          this->travelVelocity.x = 0.0f;
     986        }
     987      }
     988   
     989      if( this->bBackward )
     990      {
     991        if(this->getRelCoor().x > this->travelDistanceMinus.x)
     992        {
     993          if (this->travelVelocity.x > -this->travelSpeed)
     994          {
     995            this->travelVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
     996          }
     997          else
     998          {
     999            this->travelVelocity.x = -this->travelSpeed;
     1000          }
     1001        }
     1002        else
     1003        {
     1004          this->travelVelocity.x = 0.0f;
     1005        }
     1006      }
     1007   
     1008      if( this->bLeft)
     1009      {
     1010        if(this->getRelCoor().z > this->travelDistanceMinus.y)
     1011        {
     1012          if (this->travelVelocity.z > -this->travelSpeed)
     1013          {
     1014            this->travelVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
     1015          }
     1016          else
     1017          {
     1018            this->travelVelocity.z = -this->travelSpeed;
     1019          }
     1020        }
     1021        else
     1022        {
     1023          this->travelVelocity.z = 0.0f;
     1024        }
     1025        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6);
     1026      }
     1027   
     1028      if( this->bRight)
     1029      {
     1030        //printf("ShipCoorZ: %f \n", this->getRelCoor().z);
     1031        if(this->getRelCoor().z < this->travelDistancePlus.y)
     1032        {
     1033          if (this->travelVelocity.z < this->travelSpeed)
     1034          {
     1035            this->travelVelocity.z += (airCoeff + 1.0)*this->acceleration*dt;
     1036          }
     1037          else
     1038          {
     1039            this->travelVelocity.z = this->travelSpeed;
     1040          }
     1041        }
     1042        else
     1043        {
     1044          this->travelVelocity.z = 0.0f;
     1045        }
     1046        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6);
     1047      }
     1048      if (!this->bRight && !this->bLeft)
     1049      {
     1050        this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 6);
     1051      }
     1052
     1053    //normalisation of the vectors (vector sum must be <= travelspeed)
     1054    float xzNorm = sqrt(pow(this->travelVelocity.x, 2) + pow(this->travelVelocity.z, 2));
     1055    if (xzNorm > this->travelSpeed)
     1056    {
     1057      this->travelVelocity.x = this->travelVelocity.x/xzNorm * this->travelSpeed;
     1058      this->travelVelocity.z = this->travelVelocity.z/xzNorm * this->travelSpeed;
     1059    }
     1060
     1061    //this moves camera and ship along the travel path.
     1062    if(!this->entityTrack)
     1063       this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
     1064
     1065    break;
     1066    }
     1067    case Playable::Vertical:
     1068      break;
     1069    default:
     1070      PRINTF(4)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
     1071  }
     1072   //set new coordinates calculated through key- events.
     1073  this->shiftCoor (this->travelVelocity * dt);
     1074}
     1075
     1076void SpaceShip::setPlaymodeXML(const std::string& playmode)
     1077{
     1078  this->setPlaymode(Playable::stringToPlaymode(playmode));
     1079}
     1080
     1081/**
     1082 * @brief jumps to the next WeaponConfiguration
     1083 */
     1084void SpaceShip::nextWeaponConfig()
     1085{
     1086  PRINTF(0)("Requested next weapon config!\n");
     1087  this->weaponMan.nextWeaponConfig();
     1088  Playable::weaponConfigChanged();
     1089}
     1090
     1091/**
     1092 * @brief moves to the last WeaponConfiguration
     1093 */
     1094void SpaceShip::previousWeaponConfig()
     1095{
     1096  this->curWeaponPrimary    = (this->curWeaponPrimary + 1) % 3;
     1097  this->weaponMan.changeWeaponConfig(this->curWeaponPrimary);
     1098  Playable::weaponConfigChanged();
     1099}
     1100
     1101void SpaceShip::hit( float damage, WorldEntity* killer)
     1102{
     1103  this->damage(killer->getDamage(),0);
     1104}
     1105
     1106void SpaceShip::updateElectronicWidget()
     1107{
     1108  if (this->electronicWidget != NULL)
     1109  { //if it exists already: update it
     1110     this->electronicWidget->setMaximum(this->electronicMax);
     1111     this->electronicWidget->setValue(this->electronicCur);
     1112  }
     1113  else
     1114  { //create the widget
     1115    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1116    this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1117    //this->electronicWidget->setDisplayedName("Electronics:");
     1118    //this->electronicWidget->setSize2D(100,20);
     1119    //this->electronicWidget->setAbsCoor2D(150,200);
     1120    this->updateElectronicWidget();
     1121    if (this->hasPlayer())
     1122      State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     1123  }
     1124}
     1125
     1126void SpaceShip::updateShieldWidget()
     1127{
     1128  if (this->shieldWidget != NULL)
     1129  {
     1130    this->shieldWidget->setMaximum(this->shieldMax);
     1131    this->shieldWidget->setValue(this->shieldCur);;
     1132  }
     1133  else
     1134  {
     1135    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1136    this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1137    //this->shieldWidget->setDisplayedName("Shield:");
     1138    //his->shieldWidget->setSize2D(100,20);
     1139    //this->shieldWidget->setAbsCoor2D(200,200);
     1140    this->updateShieldWidget();
     1141    if (this->hasPlayer())
     1142      State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     1143  }
     1144}
     1145
     1146void SpaceShip::setCameraDistance(float dist)
     1147{
     1148  State::getCamera()->setViewTopDistance(dist);
     1149}
     1150
     1151void SpaceShip::setCameraFovy(float fovy)
     1152{
     1153  State::getCamera()->setViewTopFovy(fovy);
     1154}
     1155
     1156void SpaceShip::updateTravelDistance()
     1157{
     1158  float x = 1.25 * this->actionWidthPercentage * fabsf(State::getCamera()->getAbsCoor().y) * tan(State::getCamera()->getFovy()*M_PI /360.0);
     1159  float y = x / State::getCamera()->getAspectRatio() / this->actionWidthPercentage;
     1160  //State::getCamera()->setAbsCoor(-5, 1000, 0);
     1161
     1162
     1163  //State::getCamera()->getAbsCoor().print();
     1164  //printf("CameraRelCoorY: %f \n", State::getCamera()->getRelCoor().y);
     1165
     1166  //printf("x: %f, y: %f \n", x, y);
     1167  this->travelDistancePlus = Vector2D(y, x);
     1168  this->travelDistanceMinus = Vector2D(-y, -x);
     1169
     1170  State::getPlayer()->hud().setOverlayPercentage(100-int(100*this->actionWidthPercentage));
     1171  PRINTF(0)("TravelDistance has been updated\n");
     1172  this->isTravelDistanceInit = true;
     1173}
     1174
     1175void SpaceShip::setActionWidthPercentage(int i)
     1176{
     1177  if (i>100) i=100;
     1178  if (i<0) i=0;
     1179  this->actionWidthPercentage = i/100.0;
     1180
     1181  if (this->hasPlayer())
     1182    this->isTravelDistanceInit = false;
     1183};
  • branches/playability.new/src/world_entities/space_ships/space_ship.h

    r9869 r10362  
    22 * @file space_ship.h
    33 * Implements the Control of a Spaceship
     4 * Space Ships are the core class for all types of ships in Orxonox
     5 * By default is on OM_GROUP_00
     6 * If player boards the ship, it is moved to OM_GROUP_01
    47 */
    58
     
    1619class ParticleEmitter;
    1720class ParticleSystem;
     21class Trail;
     22class Wobblegrid;
    1823
    1924class SpaceShip : public Playable
     
    2934
    3035    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
     36    /*
     37    void setTravelHeight(float travelHeight);
     38    void setTravelDistance(const Vector2D& distance);
     39    void setTravelDistance(float x, float y);
     40    */
     41
     42    //void setAirFriction(float friction) { this->airFriction = friction; };
    3143
    3244    virtual void enter();
     
    4153    virtual void respawn();
    4254
    43     virtual void collidesWith(WorldEntity* entity, const Vector& location);
     55    inline Vector getVelocity() { return this->velocity; };
     56
    4457    virtual void tick(float time);
    4558    virtual void draw() const;
    4659
    4760    virtual void process(const Event &event);
     61//    virtual void hit (WorldEntity* entity, float damage);
     62
     63    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
     64
     65    //Functions for GUI
     66    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
     67    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
     68
     69    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
     70    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
     71
     72    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
     73    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
     74
     75    inline PNode* getTravelNode() { return this->travelNode; };
     76
     77    //damage handler
     78    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
     79
     80    //included by Michel:
     81    virtual void enterPlaymode(Playable::Playmode playmode);
     82    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
     83    void setActionWidthPercentage(int i);
     84    void updateTravelDistance();
     85    virtual void movement (float dt);
     86
     87    //
     88
     89    void nextWeaponConfig();
     90    void previousWeaponConfig();
     91
     92    virtual void hit(float damage, WorldEntity* killer);
    4893
    4994  private:
    5095    void init();
    5196
    52     void calculateVelocity(float time);
    53 
    54     bool                  bUp;                //!< up button pressed.
    55     bool                  bDown;              //!< down button pressed.
     97    //void calculateVelocity(float time);
     98
     99    void regen(float time);  //!< handler for shield and electronic regeneration
     100
     101    void weaponRegen(float time);   //!< weapon energy regeneration
     102
     103    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
     104
     105    void updateElectronicWidget();
     106    void updateShieldWidget();
     107
     108    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
     109    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
     110    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
     111    Playable::Playmode    playmode;           //!< The current playmode.
     112
     113    //ship atributes
     114    float       shieldCur;          //!< current shield
     115    float       shieldMax;          //!< maximum shield
     116    float       shieldEnergyShare;  //!< percentage of reactor output
     117    float       shieldRegen;        //!< shield regeneration rate per second
     118    float       shieldTH;           //!< shield threshhold for reactivation
     119    bool        shieldActive;       //!< wheather the shield is working
     120    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
     121
     122    float       armorCur;           //!< current armor
     123    float       armorMax;           //!< maximum armor
     124    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
     125    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
     126
     127    float       electronicCur;      //!< current electronic
     128    float       electronicMax;      //!< maximum electronic
     129    float       electronicRegen;    //!< electronic regenration rate per tick
     130    float       electronicTH;       //!< Threshhold for electronic failure
     131    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
     132
     133    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
     134    float       engineSpeedBase;    //!< speed base
     135    int         enginePowerConsume; //!< energy needed
     136    float       engineEnergyShare;  //!< percentage of reactor output
     137
     138    int         weaponEnergySlot;   //!< number of energy weapon slots
     139    int         weaponEnergyUsed;
     140    float       weaponEnergyShare;
     141    float       weaponEnergyRegen;
     142    int         weaponSpecialSlot;  //!< number of special weapon slots
     143    int         weaponSpecialUsed;
     144
     145    float       reactorOutput;      //!< reactor output
     146    float       reactorCapacity;    //!< reactor capacity
     147
     148    int         curWeaponPrimary;   //!< current primary weapon config
     149    int         curWeaponSecondary; //!< current secondary weapon config
     150
     151    bool                  bForward;                //!< up button pressed.
     152    bool                  bBackward;              //!< down button pressed.
    56153    bool                  bLeft;              //!< left button pressed.
    57154    bool                  bRight;             //!< right button pressed.
    58155    bool                  bAscend;            //!< ascend button pressed.
    59156    bool                  bDescend;           //!< descend button presses.
    60 //    bool                  bFire;              //!< fire button pressed.(moved to playable)
    61157    bool                  bRollL;             //!< rolling button pressed (left)
    62158    bool                  bRollR;             //!< rolling button pressed (right)
    63 
     159    bool                  bSecFire;           //!< second fire button pressed
     160
     161    /*
    64162    float                 xMouse;             //!< mouse moved in x-Direction
    65163    float                 yMouse;             //!< mouse moved in y-Direction
     
    68166    int                   controlVelocityX;
    69167    int                   controlVelocityY;
    70 //    float                 cycle;              //!< hovercycle
     168    */
    71169
    72170    Vector                velocity;           //!< the velocity of the player.
    73     Vector                oldVelocity;        //!< the velocity the player had last synced
     171    Vector                oldPos;
     172
     173// 2D-traveling
     174    PNode*                travelNode;
     175    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
     176    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
     177    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
     178    Vector2D              travelDistanceMinus;
     179    bool                  isTravelDistanceInit;
     180
     181    float                 actionWidthPercentage;
     182
     183// Camera
     184    PNode                 cameraNode;
     185    float                 cameraLook;
     186    float                 rotation;
     187    float                 cameraSpeed;
     188
     189    void                  setCameraDistance(float dist);
     190    void                  setCameraFovy(float fovy);
     191
     192    /*
    74193    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    75194    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
     
    77196    Quaternion            rotQuat;
    78197    Quaternion            pitchDir;
    79     float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    80     float                 acceleration;       //!< the acceleration of the player.
    81 
    82     float                 airViscosity;
     198    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
     199    */
     200
     201    //Quaternion            direction;          //!< the direction of the ship.
     202    float                 acceleration;       //!< the acceleration of the ship.
     203    //float                 airFriction;        //!< AirFriction.
     204    //float                 airViscosity;
    83205
    84206    byte                  oldMask;            //!< used for synchronisation
    85207
    86     ParticleEmitter*      burstEmitter;
    87     ParticleSystem*       burstSystem;
     208    Trail*                trail;              //!< Burst trail
     209    Trail*                trailL;              //!< Burst trail
     210    Trail*                trailR;              //!< Burst trail
     211
     212
    88213};
    89214
  • branches/playability.new/src/world_entities/space_ships/spacecraft_2d.cc

    r10317 r10362  
    273273{
    274274  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
    275   this->setPlaymode(this->getPlaymode());
     275//   this->setPlaymode(this->getPlaymode());
     276  this->setPlaymode(Playable::Horizontal);
     277  this->setTravelSpeed(10.0f);
    276278}
    277279
  • branches/playability.new/src/world_entities/space_ships/spacecraft_2d.h

    r9869 r10362  
    6666    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
    6767    float                 airFriction;        //!< AirFriction.
    68 
    6968    float                 airViscosity;
    7069
  • branches/playability.new/src/world_entities/test_entity.cc

    r10114 r10362  
    8686}
    8787
     88void TestEntity::draw() const
     89{
     90//   if(!mediaLoaded)
     91//     false;
    8892
     93  glPushAttrib(GL_ENABLE_BIT);
     94  glDisable(GL_LIGHTING);
     95//   glDisable(GL_BLEND);
     96//
     97//   glEnable(GL_TEXTURE_2D);
     98//   glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
     99
     100  glPushMatrix();
     101 /* glTranslatef (this->getAbsCoor ().x,
     102                this->getAbsCoor ().y,
     103                this->getAbsCoor ().z);
     104  glRotatef(axis, 0.0f, 1.0f, 0.0f);*/
     105//PRINTF(0)("axis: %f\n", axis);
     106
     107  glColor3f(1.0, 0, 0);
     108
     109  glBegin(GL_QUADS);
     110    glVertex3f( 0.0f, -100.0f, 0.0f);
     111//     glTexCoord2f(1.0f, 1.0f);
     112    glVertex3f( 0.0f,  -100.0f , 2000.0f);
     113//     glTexCoord2f(0.0f, 1.0f);
     114    glVertex3f( 10000.0f,  -100.0f , 2000.0f );
     115//     glTexCoord2f(0.0f, 0.0f);
     116    glVertex3f( 10000.0f, -100.0f, 0.0f );
     117//     glTexCoord2f(1.0f, 0.0f);
     118   
     119  glEnd();
     120
     121  glPopMatrix();
     122  glPopAttrib();
     123}
    89124
    90125/**
     
    98133
    99134
    100 /**
    101  *
    102  */
    103 void TestEntity::draw() const
    104 {
    105 
    106 }
    107135
    108136
  • branches/playability.new/src/world_entities/weapons/weapon.cc

    r9869 r10362  
    3333#include "resource_sound_buffer.h"
    3434
    35 #include "elements/glgui_energywidget.h"
     35#include "elements/glgui_energywidgetvertical.h"
    3636
    3737ObjectListDefinition(Weapon);
     
    119119  }
    120120
    121   this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
    122   this->emissionPoint.setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
    123   this->emissionPoint.setName("EmissionPoint");
    124   this->emissionPoint.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     121  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource
     122
     123  this->barrels = 1;
     124  this->segs = 1;
     125
     126  this->shootAnim = new Animation3D**[this->getBarrels()];
     127  for (int i = 0; i < this->getBarrels(); i++)
     128    this->shootAnim[i] = new Animation3D* [this->getSegs()];
     129
     130  this->emissionPoint = new PNode*[this->barrels];
     131  for(int i = 0; i < this->barrels; i++){
     132    this->emissionPoint[i] = new PNode;
     133    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     134    this->emissionPoint[i]->setName("EmissionPoint");
     135    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     136  }
    125137
    126138  this->defaultTarget = NULL;                      //< Nothing is Targeted by default.
     
    145157
    146158/**
     159 * needed, if there are more than one barrel or segments
     160 */
     161void Weapon::init2()
     162{
     163  if (this->barrels == 1 && this->segs == 1)
     164    return;
     165
     166  delete this->emissionPoint[0];
     167  delete this->emissionPoint;
     168  delete this->shootAnim[0];
     169  delete this->shootAnim;
     170
     171  this->shootAnim = new Animation3D**[this->barrels];
     172  this->emissionPoint = new PNode*[this->barrels];
     173  for(int i = 0; i < this->barrels; i++){
     174    this->emissionPoint[i] = new PNode;
     175    this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     176    this->emissionPoint[i]->setName("EmissionPoint");
     177    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     178    this->shootAnim[i] = new Animation3D* [this->segs];
     179  }
     180}
     181
     182/**
     183 * deconstructor for init2
     184 */
     185void Weapon::deconstr()
     186{
     187  for(int i = 0; i < this->barrels; i++) {
     188    delete this->emissionPoint[i];
     189    for (int j = 0; j < this->segs; j++)
     190      delete this->shootAnim[i][j];
     191    delete this->shootAnim[i];
     192  }
     193
     194  delete this->emissionPoint;
     195  delete this->shootAnim;
     196}
     197
     198/**
    147199 * loads the Parameters of a Weapon
    148200 * @param root the XML-Element to load the Weapons settings from
     
    154206  LoadParam(root, "projectile", this, Weapon, setProjectileTypeC)
    155207  .describe("Sets the name of the Projectile to load onto the Entity");
    156 
     208/*
    157209  LoadParam(root, "emission-point", this, Weapon, setEmissionPoint)
    158   .describe("Sets the Point of emission of this weapon");
     210  .describe("Sets the Point of emission of this weapon (1: EmmsionVector; 2: EmissionPoint)");*/
    159211
    160212  LoadParam(root, "state-duration", this, Weapon, setStateDuration)
     
    253305 * @param point the Point relative to the mass-point of the Weapon
    254306 */
     307void Weapon::setEmissionPoint(const Vector& point, int barrel)
     308{
     309  this->emissionPoint[barrel]->setRelCoor(point);
     310}
     311
    255312void Weapon::setEmissionPoint(const Vector& point)
    256313{
    257   this->emissionPoint.setRelCoor(point);
    258 }
    259 
     314  this->emissionPoint[0]->setRelCoor(point);
     315}
    260316
    261317/**
     
    315371}
    316372
     373Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node)
     374{
     375  if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known
     376    return NULL;
     377
     378  if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it.
     379  {
     380    if (likely(node != NULL))
     381      return this->shootAnim[barrel][seg] = new Animation3D(node);
     382    else
     383    {
     384//       PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state));
     385      return NULL;
     386    }
     387  }
     388  else
     389    return this->shootAnim[barrel][seg];
     390}
     391
    317392OrxGui::GLGuiWidget* Weapon::getEnergyWidget()
    318393{
    319   if (this->energyWidget == NULL)
    320   {
    321     this->energyWidget = new OrxGui::GLGuiEnergyWidget();
    322     this->energyWidget->setDisplayedName(this->getClassCName());
     394  if ( this->energyWidget == NULL)
     395  {
     396    this->energyWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     397    //this->energyWidget->setDisplayedName(this->getClassCName());
    323398    this->energyWidget->setSize2D( 20, 100);
    324399    this->energyWidget->setMaximum(this->getEnergyMax());
     
    352427  if (likely(this->isActive()))
    353428  {
     429    /** Disabled for releaseFire() from WM*/
    354430    if (this->requestedAction != WA_NONE)
    355431      return;
     
    378454  {
    379455    this->energy += energyToAdd;
     456    this->updateWidgets();
    380457    return 0.0;
    381458  }
     
    383460  {
    384461    this->energy += maxAddEnergy;
     462    this->updateWidgets();
    385463    return energyToAdd - maxAddEnergy;
    386464  }
     465 
    387466}
    388467
     
    431510    break;
    432511    default:
    433     PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     512    PRINTF(5)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
    434513    return false;
    435514  }
     
    507586bool Weapon::fireW()
    508587{
     588//   printf("fireW Weapon\n");
    509589  //if (likely(this->currentState != WS_INACTIVE))
    510590  if (this->minCharge <= this->energy)
     
    513593    if (this->soundBuffers[WA_SHOOT].loaded())
    514594      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    515     this->updateWidgets();
    516595    // fire
    517596    this->energy -= this->minCharge;
     
    519598    // setting up for the next state
    520599    this->enterState(WS_SHOOTING);
     600    this->updateWidgets();
    521601  }
    522602  else  // reload if we still have the charge
     
    538618      unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge))
    539619  {
    540     this->requestAction(WA_DEACTIVATE);
     620    //this->requestAction(WA_DEACTIVATE);
    541621    this->execute();
    542622    return false;
  • branches/playability.new/src/world_entities/weapons/weapon.h

    r9869 r10362  
    126126
    127127    // EMISSION
     128    /** keeping old functions*/
     129    void setEmissionPoint(const Vector& point, int barrel);
    128130    void setEmissionPoint(const Vector& point);
    129131    /** @see void setEmissionPoint(const Vector& point); */
     132    inline void setEmissionPoint(float x, float y, float z, int barrel) { this->setEmissionPoint(Vector(x, y, z), barrel); };
    130133    inline void setEmissionPoint(float x, float y, float z) { this->setEmissionPoint(Vector(x, y, z)); };
    131134    /** @returns the absolute Position of the EmissionPoint */
    132     inline const Vector& getEmissionPoint() const { return this->emissionPoint.getAbsCoor(); };
     135    inline const Vector& getEmissionPoint(int barrel) const { return this->emissionPoint[barrel]->getAbsCoor(); };
     136    inline const Vector& getEmissionPoint() const { return this->emissionPoint[0]->getAbsCoor(); };
     137
    133138
    134139    inline void setDefaultTarget(PNode* defaultTarget) { this->defaultTarget = defaultTarget; };
     
    158163
    159164    Animation3D* getAnimation(WeaponState state, PNode* node = NULL);
     165    Animation3D* getAnimation(int barrel, int seg, PNode* node);
    160166    Animation3D* copyAnimation(WeaponState from, WeaponState to);
    161167
     
    169175    bool check() const;
    170176    void debug() const;
     177
     178    inline int getBarrels() {return this->barrels; };
     179    inline int getSegs() { return this->segs; };
     180    inline void setBarrels(int barrels) { this->barrels = barrels; };
     181    inline void setSegs(int segs) { this->segs = segs; };
     182
     183    inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
     184    inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
     185
     186    void init2();
     187    void deconstr();
    171188
    172189  protected:
     
    184201    static WeaponState   charToState(const std::string& state);
    185202    static const char*   stateToChar(WeaponState state);
     203
     204
    186205
    187206  private:
     
    214233    float                maxCharge;                        //!< The maximal energy to be loaded onto one projectile (this is only availible if chargeable is enabled)
    215234
    216     OrxGui::GLGuiEnergyWidget* energyWidget;
     235    OrxGui::GLGuiEnergyWidgetVertical* energyWidget;
    217236
    218237    PNode*               defaultTarget;                    //!< A target for targeting Weapons.
     
    230249    OrxSound::SoundBuffer  soundBuffers[WA_ACTION_COUNT];   //!< SoundBuffers for all actions @see WeaponAction.
    231250
    232     PNode                  emissionPoint;                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
     251    PNode**                emissionPoint;                   //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
    233252
    234253    bool                   hideInactive;                    //!< Hides the Weapon if it is inactive
     
    237256    ClassID                projectile;                      //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.)
    238257    FastFactory*           projectileFactory;               //!< A factory, that produces and handles the projectiles.
     258
     259    int                    barrels;                         //!< # of barrels
     260    int                    segs;                             //!< # of segments, one barrel has
     261    Animation3D***         shootAnim;
     262
    239263  };
    240264
  • branches/playability.new/src/world_entities/weapons/weapon_manager.cc

    r9869 r10362  
    103103
    104104  this->currentConfigID = 0;
    105   this->slotCount = 2;
     105  this->slotCount = WM_MAX_SLOTS;
    106106  //this->weaponChange;
    107107
     
    114114  this->crossHairSizeAnim->addKeyFrame(100, .05, ANIM_LINEAR);
    115115  this->crossHairSizeAnim->addKeyFrame(50, .01, ANIM_LINEAR);
     116
     117  this->hideCrosshair();
     118
     119  this->bFire = false;
     120}
     121
     122void WeaponManager::showCrosshair()
     123{
     124  this->crosshair->setVisibility( true);
     125}
     126
     127void WeaponManager::hideCrosshair()
     128{
     129  this->crosshair->setVisibility( false);
     130}
     131
     132void WeaponManager::setRotationSpeed(float speed)
     133{
     134  this->crosshair->setRotationSpeed(speed);
    116135}
    117136
     
    300319    if (this->parentEntity->isA(Playable::staticClassID()))
    301320      dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
     321   
    302322    weapon->setDefaultTarget(this->crosshair);
    303323  }
     
    317337
    318338/**
    319  * @brief does the same as the funtion inclreaseAmmunition, added four your convenience
     339 * @brief does the same as the funtion increaseAmmunition, added four your convenience
    320340 * @param weapon, the Weapon to read the ammo-info about.
    321341 * @param ammo how much ammo to add.
    322342 */
    323 float WeaponManager::inclreaseAmmunition(const Weapon* weapon, float ammo)
     343float WeaponManager::increaseAmmunition(const Weapon* weapon, float ammo)
    324344{
    325345  assert (weapon != NULL);
     
    400420  this->currentConfigID = weaponConfig;
    401421  PRINTF(4)("Changing weapon configuration: to %i\n", this->currentConfigID);
     422
    402423  for (int i = 0; i < WM_MAX_SLOTS; i++)
    403424    this->currentSlotConfig[i].nextWeapon = this->configs[currentConfigID][i];
     
    410431void WeaponManager::fire()
    411432{
     433//   printf("firing WM: ");
    412434  Weapon* firingWeapon;
    413435  for(int i = 0; i < this->slotCount; i++)
    414436  {
     437//     printf("%i ", i);
     438          firingWeapon = this->currentSlotConfig[i].currentWeapon;
     439      if( firingWeapon != NULL && firingWeapon->getCurrentState() == WS_SHOOTING) continue;
     440          if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
     441  }
     442//   printf("\n");
     443  /*
     444        this->crosshair->setRotationSpeed(500);
     445        this->crossHairSizeAnim->replay();
     446  */
     447}
     448
     449/**
     450 * triggers fire of all weapons in the current weaponconfig
     451 */
     452void WeaponManager::releaseFire()
     453{
     454  Weapon* firingWeapon;
     455  for(int i = 0; i < this->slotCount; i++)
     456  {
    415457    firingWeapon = this->currentSlotConfig[i].currentWeapon;
    416     if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
    417   }
     458    if( firingWeapon != NULL) firingWeapon->requestAction(WA_NONE);
     459  }
     460
     461  /*
    418462  this->crosshair->setRotationSpeed(500);
    419463  this->crossHairSizeAnim->replay();
    420 }
    421 
     464  */
     465}
    422466
    423467/**
     
    429473  Weapon* tickWeapon;
    430474
     475
    431476  for(int i = 0; i < this->slotCount; i++)
    432477  {
    433 /*
    434     NICE LITTLE DEBUG FUNCTION
    435        if (this->currentSlotConfig[i].currentWeapon != NULL || this->currentSlotConfig[i].nextWeapon != NULL)
     478
     479    //NICE LITTLE DEBUG FUNCTION
     480    /*   if (this->currentSlotConfig[i].currentWeapon != NULL || this->currentSlotConfig[i].nextWeapon != NULL)
    436481      printf("%p %p\n", this->currentSlotConfig[i].currentWeapon, this->currentSlotConfig[i].nextWeapon);*/
    437482
     
    455500        }
    456501      }
    457 
    458502      // switching to next Weapon
    459503      tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon;
     504     
    460505      if (tickWeapon != NULL)
    461506      {
    462            //        if (this->parent != NULL)
    463           tickWeapon->toList(this->parentEntity->getOMListNumber());
     507        //if (this->parent != NULL)
     508        tickWeapon->toList(this->parentEntity->getOMListNumber());
    464509        tickWeapon->requestAction(WA_ACTIVATE);
    465510        this->currentSlotConfig[i].position.activateNode();
  • branches/playability.new/src/world_entities/weapons/weapon_manager.h

    r9869 r10362  
    6060    void loadWeapons(const TiXmlElement* root);
    6161
     62    void showCrosshair();
     63    void hideCrosshair();
     64    void setRotationSpeed(float speed);
     65
    6266    void setSlotCount(unsigned int slotCount);
    6367    unsigned int getSlotCount() const { return this->slotCount; };
     
    9195
    9296    float increaseAmmunition(const ClassID& projectileType, float ammo);
    93     float inclreaseAmmunition(const Weapon* weapon, float ammo);
     97    float increaseAmmunition(const Weapon* weapon, float ammo);
    9498
    9599    /** @returns a fixed target namely the Crosshair's 3D position */
     
    99103    //! @TODO: implement this function (maybe also in Weapon itself)
    100104    void releaseFire();
     105    //inline void setFire() { this->bFire = true; };
    101106
    102107    void tick(float dt);
     
    127132
    128133    std::vector<CountPointer<AmmoContainer> > ammo;                   //!< Containers
     134
     135    bool                    bFire;
    129136};
    130137
  • branches/playability.new/src/world_entities/world_entity.cc

    r10314 r10362  
    3232
    3333#include "util/loading/load_param.h"
     34#include "loading/load_param_xml.h"
     35#include "util/loading/factory.h"
     36
    3437#include "obb_tree.h"
    3538
    3639#include "elements/glgui_energywidget.h"
     40#include "elements/glgui_energywidgetvertical.h"
    3741
    3842#include "state.h"
     
    4448#include "kill.h"
    4549#include "debug.h"
     50
     51#include "track/track.h"
    4652
    4753#include "projectiles/projectile.h"
     
    8692  this->_bOnGround = false;
    8793
     94  // Track of this entity
     95  this->entityTrack = NULL;
     96
    8897  // registering default reactions:
    8998  this->subscribeReaction(CoRe::CREngine::CR_OBJECT_DAMAGE, Projectile::staticClassID());
     
    148157  .describe("the fileName of the object information file (optional)");
    149158
     159  // Entity Attributes
    150160  LoadParam(root, "maxHealth", this, WorldEntity, setHealthMax)
    151161  .describe("The Maximum health that can be loaded onto this entity")
     
    157167
    158168  LoadParam(root, "list", this, WorldEntity, toListS);
     169
     170
     171  // Track
     172  LoadParamXML(root, "Track", this, WorldEntity, addTrack)
     173   .describe("creates and adds a track to this WorldEntity");
     174}
     175
     176
     177/**
     178 * this functions adds a track to this workd entity. This can be usefull, if you like this WE to follow a some waypoints.
     179 * here the track is created and further initializing left for the Track itself
     180 */
     181void WorldEntity::addTrack(const TiXmlElement* root)
     182{
     183  // The problem we have is most likely here. The track should be constructed WITH the XML-Code
     184  this->entityTrack = new Track(root);
     185  this->setParent(this->entityTrack->getTrackNode());
     186  this->entityTrack->getTrackNode()->setParentMode(PNODE_ALL);
     187  /*LOAD_PARAM_START_CYCLE(root, element);
     188  {
     189    PRINTF(4)("element is: %s\n", element->Value());
     190    Factory::fabricate(element);
     191  }
     192  LOAD_PARAM_END_CYCLE(element);*/
     193 
     194
    159195}
    160196
     
    613649*/
    614650void WorldEntity::tick(float time)
    615 {}
     651{
     652}
    616653
    617654
     
    652689      this->models[0]->draw();
    653690    }
     691   
     692    //if (this->entityTrack)
     693       //this->entityTrack->drawGraph(0.02);
    654694
    655695    //     if( this->aabbNode != NULL)
     
    721761  if (this->healthWidget == NULL)
    722762  {
    723     this->healthWidget = new OrxGui::GLGuiEnergyWidget();
    724     this->healthWidget->setDisplayedName(std::string(this->getClassName()) + " Energy:");
    725     this->healthWidget->setSize2D(30,400);
    726     this->healthWidget->setAbsCoor2D(10,100);
     763    this->healthWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     764    //this->healthWidget->setDisplayedName("Health");
     765    //this->healthWidget->setSize2D(100,20);
     766    //this->healthWidget->setAbsCoor2D(100,200);
    727767
    728768    this->updateHealthWidget();
     
    773813void WorldEntity::hit(float damage, WorldEntity* killer)
    774814{
     815
    775816  this->decreaseHealth(damage);
    776817
  • branches/playability.new/src/world_entities/world_entity.h

    r10314 r10362  
    2525// FORWARD DECLARATION
    2626namespace OrxSound { class SoundBuffer; class SoundSource; }
    27 namespace OrxGui { class GLGuiWidget; class GLGuiBar; class GLGuiEnergyWidget; };
     27namespace OrxGui { class GLGuiWidget; class GLGuiBar; class GLGuiEnergyWidget; class GLGuiEnergyWidgetVertical; };
    2828namespace CoRe { class Collision; }
    2929
     
    3232class AABBTreeNode;
    3333class Model;
     34class Track;
     35class TiXmlElement;
    3436
    3537class ObjectInformationFile;
     
    156158  void increaseHealthMax(float increaseHealth);
    157159  OrxGui::GLGuiWidget* getHealthWidget();
    158   bool hasHealthWidget() const { return this->healthWidget; };
     160  bool hasHealthWidget() const { return this->healthWidget != NULL; };
    159161
    160162  virtual void varChangeHandler( std::list<int> & id );
     
    185187private:
    186188  void updateHealthWidget();
     189  void addTrack(const TiXmlElement* root);
    187190
    188191
     
    192195  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
    193196  float                   healthMax;          //!< The Maximal energy this entity can take.
    194   OrxGui::GLGuiEnergyWidget* healthWidget;    //!< The Slider (if wanted).
     197  OrxGui::GLGuiEnergyWidgetVertical* healthWidget;    //!< The Slider (if wanted).
    195198
    196199  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     
    235238protected:
    236239  Vector                  velocity;                        //!< speed of the entity
     240  Track*                  entityTrack;                     //!< this is the track this entity follows (or NULL if none)
    237241
    238242};
Note: See TracChangeset for help on using the changeset viewer.