Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4830 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jul 11, 2005, 5:43:37 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented aim

Location:
orxonox/trunk/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4817 r4830  
    6767}
    6868
     69/**
     70 * initializes the GraphicsEngine with default settings.
     71 */
    6972int GraphicsEngine::init()
    7073{
    71   this->initVideo(640,480,16);
    72 }
     74  if (this->isInit)
     75    return -1;
     76  this->initVideo(640, 480, 16);
     77  this->isInit = true;
     78}
     79
     80/**
     81 * loads the GraphicsEngine's settings from a given ini-file and section
     82 * @param iniParser the iniParser to load from
     83 * @param section the Section in the ini-file to load from
     84 * @returns nothing usefull
     85 */
     86int GraphicsEngine::initFromIniFile(IniParser* iniParser)
     87{
     88
     89  // looking if we are in fullscreen-mode
     90  const char* fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
     91  if (strchr(fullscreen, '1'))
     92    this->fullscreenFlag = SDL_FULLSCREEN;
     93
     94
     95
     96  // looking if we are in fullscreen-mode
     97  const char* textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
     98  if (strchr(textures, '1'))
     99    this->texturesEnabled = true;
     100  else
     101    this->texturesEnabled = false;
     102
     103  // searching for a usefull resolution
     104  SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
     105  this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
     106}
     107
     108
    73109
    74110/**
     
    123159
    124160/**
    125  * loads the GraphicsEngine's settings from a given ini-file and section
    126  * @param iniParser the iniParser to load from
    127  * @param section the Section in the ini-file to load from
    128  * @returns nothing usefull
    129  */
    130 int GraphicsEngine::initFromIniFile(IniParser* iniParser)
    131 {
    132   // searching for a usefull resolution
    133   SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480"), 'x');
    134   this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16);
    135 
    136   // looking if we are in fullscreen-mode
    137   const char* fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
    138   if (strchr(fullscreen, '1'))
    139     this->setFullscreen(true);
    140 
    141   // looking if we are in fullscreen-mode
    142   const char* textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
    143   if (strchr(textures, '1'))
    144     this->texturesEnabled = true;
    145   else
    146     this->texturesEnabled = false;
    147 
    148 }
    149 
    150 
    151 
    152 /**
    153161 * sets the Window Captions and the Name of the icon.
    154162 * @param windowName The name of the Window
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r4806 r4830  
    2626 * \todo implement this stuff
    2727*/
    28 typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST,
    29                          MODEL_VERTEX_ARRAY};
     28typedef enum MODEL_TYPE {
     29  MODEL_DISPLAY_LIST,
     30  MODEL_VERTEX_ARRAY
     31};
    3032
    3133
     
    3638
    3739//! an enumerator for VERTEX_FORMAT
    38 typedef enum VERTEX_FORMAT { VERTEX_ONLY = VERTEX,
    39                              VERTEX_NORMAL = NORMAL,
    40                              VERTEX_TEXCOORD = TEXCOORD,
    41                              VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD };
     40typedef enum VERTEX_FORMAT {
     41  VERTEX_ONLY = VERTEX,
     42  VERTEX_NORMAL = NORMAL,
     43  VERTEX_TEXCOORD = TEXCOORD,
     44  VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD
     45};
    4246
    4347////////////////////
  • orxonox/trunk/src/lib/graphics/text_engine.cc

    r4746 r4830  
    254254      glTranslatef(pos.x, pos.y, 0);
    255255
    256       char* tmpText = this->text;
     256      const char* tmpText = this->text;
    257257      while (*tmpText != '\0')
    258258        {
     
    921921  // drawing all the texts
    922922  tIterator<Text>* textIterator = textList->getIterator();
    923   Text* text = textIterator->nextElement();
    924   while( text != NULL)
    925     {
    926       text->draw();
    927       text = textIterator->nextElement();
     923  Text* drawText = textIterator->nextElement();
     924  while( drawText != NULL)
     925    {
     926      drawText->draw();
     927      drawText = textIterator->nextElement();
    928928    }
    929929  delete textIterator;
  • orxonox/trunk/src/lib/gui/gui_exec.cc

    r4746 r4830  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program; if not, write to the Free Software Foundation,
    18    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
     18   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1919
    2020
     
    3838HashTable* orxonoxFlagHash;
    3939
    40 /** 
     40/**
    4141    \brief Creates the Exec-Frame
    4242*/
     
    5959      CheckButton* alwaysShow;     //!< A CheckButton, for if orxonox should start with or without gui.
    6060      Button* quit;                //!< A Button to quit the Gui without starting orxonox.
    61      
     61
    6262      start = new Button("Start");
    6363#ifdef HAVE_GTK2
     
    7373      verboseMode = new Menu(CONFIG_NAME_VERBOSE_MODE, "nothing",
    7474#if DEBUG >=1
    75                              "error",
     75                             "error",
    7676#endif
    7777#if DEBUG >=2
    78                              "warning",
     78                             "warning",
    7979#endif
    8080#if DEBUG >=3
    81                              "info",
     81                             "info",
    8282#endif
    8383#if DEBUG >=4
    84                              "debug",
     84                             "debug",
    8585#endif
    8686#if DEBUG >=5
    87                              "heavydebug",
    88 #endif
    89                              "lastItem");
     87                             "heavydebug",
     88#endif
     89                             "lastItem");
    9090      verboseMode->setFlagName("verbose", "v", 2);
    9191      verboseMode->setDescription("Sets the Output Mode", "This Enables Outbug messages\n"
    92                                   "0: nothing will be displayed, but stuff one cannot do without (eg.GUI)\n"
     92                                  "0: nothing will be displayed, but stuff one cannot do without (eg.GUI)\n"
    9393#if DEBUG >=1
    94                                   "1: error: outputs all the above and errors"
     94                                  "1: error: outputs all the above and errors"
    9595#endif
    9696#if DEBUG >=2
    97                                   "2: warning: outputs all the above plus warnings"
     97                                  "2: warning: outputs all the above plus warnings"
    9898#endif
    9999#if DEBUG >=3
    100                                   "3: info: outputs all the above plus Information"
     100                                  "3: info: outputs all the above plus Information"
    101101#endif
    102102#if DEBUG >=4
    103                                   "4: debug: displays all the above plus debug information"
     103                                  "4: debug: displays all the above plus debug information"
    104104#endif
    105105#if DEBUG >=5
    106                                   "5: heavydebug: displays all the above plus heavy debug information: WARNING: the game will run very slow with this."
    107 #endif
    108                                   );
     106                                  "5: heavydebug: displays all the above plus heavy debug information: WARNING: the game will run very slow with this."
     107#endif
     108                                  );
    109109      verboseMode->saveability();
    110110      execBox->fill(verboseMode);
     
    152152
    153153  PRINTF(5)("Config Directory is: %s.\n", this->confDir);
    154   //! \todo F** Windows-support
     154  //! @todo F** Windows-support
    155155#ifndef __WIN32__
    156156  mkdir(this->confDir, 0755);
     
    192192}
    193193
    194 /** 
     194/**
    195195    \brief Saves the configuration-file to the Disk.\n
    196196    \param widget from which Widget on should be saved.
     
    215215  int counter = 0;
    216216  while(counter < depth &&((widget->optionType > GUI_NOTHING
    217                               &&(static_cast<Option*>(widget)->isSaveable()))
    218                              ||(widget->optionType < GUI_NOTHING
    219                                 && static_cast<Packer*>(widget)->getGroupName())))
     217                              &&(static_cast<Option*>(widget)->isSaveable()))
     218                             ||(widget->optionType < GUI_NOTHING
     219                                && static_cast<Packer*>(widget)->getGroupName())))
    220220    {
    221221      fprintf(this->CONFIG_FILE, "  ", depth);
    222222      counter++;
    223223    }
    224  
     224
    225225  // check if it is a Packer, and if it is, check if it has a name and if there is something in it.
    226226  if(widget->optionType < GUI_NOTHING)
    227227    {
    228228      if(static_cast<Packer*>(widget)->getGroupName())
    229         {
    230           fprintf(CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
    231           this->writeFileText(static_cast<Packer*>(widget)->down, depth+1);
    232           fprintf(CONFIG_FILE, "\n");
    233         }
     229        {
     230          fprintf(CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
     231          this->writeFileText(static_cast<Packer*>(widget)->down, depth+1);
     232          fprintf(CONFIG_FILE, "\n");
     233        }
    234234      else
    235         {
    236           this->writeFileText(static_cast<Packer*>(widget)->down, depth);
    237         }
    238     } 
     235        {
     236          this->writeFileText(static_cast<Packer*>(widget)->down, depth);
     237        }
     238    }
    239239
    240240  if(widget->optionType > GUI_NOTHING)
    241241    if (static_cast<Option*>(widget)->isSaveable())
    242242      {
    243         char Buffer[256];
    244         char* space2under;
    245         strcpy(Buffer, static_cast<Option*>(widget)->title);
    246         if(strchr(Buffer, '_'))
    247           PRINTF(2)("Optionname %s is not Valid for Saving, because it includes an underscore\n", Buffer);
    248         while(space2under = strchr(Buffer, ' '))
    249           {
    250             space2under[0] = '_';
    251           }
    252           fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<Option*>(widget)->save());
     243        char Buffer[256];
     244        char* space2under;
     245        strcpy(Buffer, static_cast<Option*>(widget)->title);
     246        if(strchr(Buffer, '_'))
     247          PRINTF(2)("Optionname %s is not Valid for Saving, because it includes an underscore\n", Buffer);
     248        while(space2under = strchr(Buffer, ' '))
     249          {
     250            space2under[0] = '_';
     251          }
     252          fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<Option*>(widget)->save());
    253253      }
    254254
     
    272272      char* Value;
    273273      while(fscanf(this->CONFIG_FILE, "%s", Buffer) != EOF)
    274         {
    275           // group-search //
    276           if(!strncmp(Buffer, "[", 1))
    277             {
    278               if((groupWidget = locateGroup(widget, Buffer, 1))==NULL)
    279                 {
    280                   PRINTF(2)("!!There is no group called %s in this GUI.\n First best Widget will get the Infos assigned.\n Config-File will be updated in next Save\n", Buffer);
    281                   groupWidget = widget;
    282                 }
    283               else
    284                 PRINT(5)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName);
    285             }
    286           // option-setting //
    287           if(!strcmp(Buffer, "="))
    288             {
    289               char* under2space;
    290               while(under2space = strchr(Variable, '_'))
    291                 {
    292                   sprintf(under2space, " %s", under2space+1);
    293                 }
    294              
    295               fscanf(this->CONFIG_FILE, "%s", Buffer);
    296               varInfo.variableName = Variable;
    297               varInfo.variableValue = Buffer;
    298               groupWidget->walkThrough(this->readFileText, &varInfo, 0);
    299               sprintf(Variable, "");
    300             }
    301           sprintf(Variable, "%s", Buffer);
    302         }
     274        {
     275          // group-search //
     276          if(!strncmp(Buffer, "[", 1))
     277            {
     278              if((groupWidget = locateGroup(widget, Buffer, 1))==NULL)
     279                {
     280                  PRINTF(2)("!!There is no group called %s in this GUI.\n First best Widget will get the Infos assigned.\n Config-File will be updated in next Save\n", Buffer);
     281                  groupWidget = widget;
     282                }
     283              else
     284                PRINT(5)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName);
     285            }
     286          // option-setting //
     287          if(!strcmp(Buffer, "="))
     288            {
     289              char* under2space;
     290              while(under2space = strchr(Variable, '_'))
     291                {
     292                  sprintf(under2space, " %s", under2space+1);
     293                }
     294
     295              fscanf(this->CONFIG_FILE, "%s", Buffer);
     296              varInfo.variableName = Variable;
     297              varInfo.variableValue = Buffer;
     298              groupWidget->walkThrough(this->readFileText, &varInfo, 0);
     299              sprintf(Variable, "");
     300            }
     301          sprintf(Variable, "%s", Buffer);
     302        }
    303303      widget->walkThrough(widget->setOptions, 0);
    304304    }
     305    fclose(this->CONFIG_FILE);
    305306}
    306307
     
    317318      PRINT(5)("Located Option %s.\n", widget->title);
    318319      if(widget->optionType > GUI_NOTHING)
    319         static_cast<Option*>(widget)->load(info->variableValue);
     320        static_cast<Option*>(widget)->load(info->variableValue);
    320321    }
    321322}
     
    344345    {
    345346      if(static_cast<Packer*>(widget)->getGroupName() &&
    346         !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
    347         {
    348           return widget;
    349         }
     347        !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
     348        {
     349          return widget;
     350        }
    350351      else
    351         {
    352           if((tmp = locateGroup(static_cast<Packer*>(widget)->down, groupName, depth+1)) != NULL)
    353             return tmp;
    354         }
    355     } 
    356  
     352        {
     353          if((tmp = locateGroup(static_cast<Packer*>(widget)->down, groupName, depth+1)) != NULL)
     354            return tmp;
     355        }
     356    }
     357
    357358  if(widget->next != NULL && depth != 0)
    358359    {
    359360      if((tmp = locateGroup(widget->next, groupName, depth)) != NULL)
    360         return tmp;
     361        return tmp;
    361362    }
    362363  return NULL;
  • orxonox/trunk/src/lib/sound/sound_engine.cc

    r4746 r4830  
    378378void SoundEngine::flushAllBuffers()
    379379{
    380     tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
     380  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
    381381  SoundBuffer* enumBuffer = bufferIterator->nextElement();
    382382  while (enumBuffer)
     
    389389
    390390/**
     391  * @brief SourceEngine::flushAllBuffers
     392 */
     393void SoundEngine::flushAllSources()
     394{
     395  tIterator<SoundSource>* Iterator = this->sourceList->getIterator();
     396  SoundSource* enumSource = Iterator->nextElement();
     397  while (enumSource)
     398  {
     399    delete enumSource;
     400    enumSource = Iterator->nextElement();
     401  }
     402  delete Iterator;
     403}
     404
     405
     406/**
    391407   \brief initializes Audio in general
    392408*/
  • orxonox/trunk/src/lib/sound/sound_engine.h

    r4761 r4830  
    9191  void flushUnusedBuffers();
    9292  void flushAllBuffers();
     93  void flushAllSources();
    9394  bool initAudio();
    9495
  • orxonox/trunk/src/lib/util/substring.cc

    r4734 r4830  
    2929SubString::SubString( const char* string, char splitter)
    3030{
    31   n = 0;
     31  this->splittersCount = 0;
    3232
    3333  assert( string != NULL);
    3434
    35   for( int i = 0; i < strlen(string); i++) if( string[i] == splitter) n++;
     35  for( int i = 0; i < strlen(string); i++) if( string[i] == splitter)
     36      splittersCount++;
    3637
    37   n += 1;
     38  this->splittersCount += 1;
    3839
    39   strings = new char*[n];
    40 
     40  this->strings = new char*[this->splittersCount];
    4141  assert (strings != NULL);
    4242
     
    4848  while( end != NULL)
    4949    {
    50       assert( i < n);
     50      assert( i < this->splittersCount);
    5151      l = end - offset;
    52       strings[i] = new char[l + 1];
     52      this->strings[i] = new char[l + 1];
    5353      assert( strings[i] != NULL);
    5454      strncpy( strings[i], offset, l);
     
    7171SubString::~SubString()
    7272{
    73   for( int i = 0; i < n; i++)
     73  for( int i = 0; i < this->splittersCount; i++)
    7474    {
    75       delete strings[i];
     75      delete this->strings[i];
    7676    }
    7777
    78   delete strings;
    79 }
    80 
    81 /**
    82    \brief get the amount of substrings
    83    \returns the amount of substrings
    84 */
    85 int SubString::getCount()
    86 {
    87   return n;
     78  delete this->strings;
    8879}
    8980
     
    9586const char* SubString::getString( int i)
    9687{
    97   if( i < n && i >= 0) return strings[i];
    98   else return NULL;
     88  if( i < this->splittersCount && i >= 0)
     89    return this->strings[i];
     90  else
     91    return NULL;
    9992}
  • orxonox/trunk/src/lib/util/substring.h

    r4734 r4830  
    1414  ~SubString();
    1515
    16   int getCount();
     16  inline int getCount() { return this->splittersCount; };
    1717  const char* getString( int i);
    1818
    1919 private:
    20   char**     strings;         //!< strings produced from a single string splitted in multiple strings
    21   int        n;               //!< how many splitted parts
     20  char**     strings;                      //!< strings produced from a single string splitted in multiple strings
     21  int        splittersCount;               //!< how many splitted parts
    2222};
    2323
  • orxonox/trunk/src/orxonox.cc

    r4827 r4830  
    7171  this->argv = NULL;
    7272
     73  this->configFileName = NULL;
     74
    7375}
    7476
     
    7981{
    8082  delete this->iniParser;
     83  delete this->configFileName;
    8184
    8285  delete GraphicsEngine::getInstance(); // deleting the Graphics
     
    116119 * it's path and name into configfilename
    117120*/
    118 const char* Orxonox::getConfigFile (int argc, char** argv)
    119 {
     121const char* Orxonox::getConfigFile ()
     122{
     123  this->configFileName = new char[strlen(DEFAULT_CONFIG_FILE)];
    120124  strcpy (this->configFileName, DEFAULT_CONFIG_FILE);
    121125  this->iniParser = new IniParser(this->configFileName);
     
    133137
    134138  // initialize the Config-file
    135   this->getConfigFile(argc, argv);
     139  this->getConfigFile();
    136140
    137141
     
    351355int startOrxonox(int argc, char** argv)
    352356{
    353   // checking for existence of the configuration-files
     357  // checking for existence of the configuration-files, or if the lock file is still used
    354358  if (showGui ||
    355359      !ResourceManager::isFile(DEFAULT_CONFIG_FILE) ||
  • orxonox/trunk/src/orxonox.h

    r4822 r4830  
    4141  int initResources ();
    4242
    43   const char* getConfigFile (int argc, char** argv);
     43  const char* getConfigFile ();
    4444
    4545 private:
     
    4747
    4848  IniParser*        iniParser;               //!< Reference to the ini-parser used in orxonox
    49   char              configFileName[256];     //!< Filename of the configuration-file.
     49  char*             configFileName;          //!< Filename of the configuration-file.
    5050  GameLoader*       gameLoader;              //!< The gameLoader
    5151
  • orxonox/trunk/src/story_entities/world.cc

    r4829 r4830  
    186186
    187187  delete WorldInterface::getInstance();
    188   delete this->nullParent;
     188  delete NullParent::getInstance();
    189189  delete this->entities;
     190  State::setWorldEntityList(NULL);
     191
     192
    190193  delete LightManager::getInstance();
    191194  delete TrackManager::getInstance();
     
    194197  TextEngine::getInstance()->flush();
    195198  SoundEngine::getInstance()->flushAllBuffers();
     199  SoundEngine::getInstance()->flushAllSources();
    196200
    197201  delete AnimationPlayer::getInstance(); // this should be at the end of the unloading sequence.
     
    203207
    204208  ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL);
     209
     210
     211
     212  crosshair=NULL;
    205213}
    206214
     
    238246  LoadParam<World>(root, "path", this, &World::setPath)
    239247    .describe("The Filename of this World (relative from the data-dir)");
    240 
    241   if (!crosshair)
    242     crosshair = new Crosshair();
    243248}
    244249
     
    273278
    274279  GraphicsEngine::getInstance()->displayFPS(true);
     280
     281  if (!crosshair)
     282    crosshair = new Crosshair();
    275283}
    276284
     
    849857  glCallList (objectList);
    850858
    851   ParticleEngine::getInstance()->draw(); //!< \todo should be dts like in the Trunk;
     859  ParticleEngine::getInstance()->draw();
     860
     861  crosshair->draw();
    852862
    853863  TextEngine::getInstance()->draw();
    854864  LightManager::getInstance()->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
    855   crosshair->draw();
    856865}
    857866
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4826 r4830  
    2323#include "p_node.h"
    2424#include "state.h"
     25#include "model.h"
    2526
    2627#include <iostream>
     
    3738  this->setName("Crosshair");
    3839
     40  this->material = NULL;
     41  this->model = NULL;
     42  this->rotation = 0;
     43
     44  this->material = new Material("Crosshair Material");
     45  this->material->setDiffuseMap("maps/aim.png");
     46
     47  float size = 50;
     48  this->model = new Model();
     49  this->model->addVertex (-0.5*size, -0.5*size, 0);
     50  this->model->addVertex (0.5*size, -0.5*size, 0);
     51  this->model->addVertex (0.5*size, 0.5*size, 0);
     52  this->model->addVertex (-0.5*size, 0.5*size, 0);
     53
     54  this->model->addVertexTexture(0,0);
     55  this->model->addVertexTexture(1,0);
     56  this->model->addVertexTexture(1,1);
     57  this->model->addVertexTexture(0,1);
     58
     59  this->model->setMaterial(this->material);
     60  this->model->addFace(4, VERTEX_TEXCOORD, 0,0, 1,1 ,2,2, 3,3);
     61  this->model->finalize();
     62
    3963  EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION);
    4064
     
    4771Crosshair::~Crosshair ()
    4872{
     73 // delete this->model;
     74
    4975  // delete what has to be deleted here
    5076  EventHandler::getInstance()->unsubscribe(this);
     
    81107
    82108
    83 void Crosshair::draw() const
     109void Crosshair::draw()
    84110{
    85111  /*
     
    118144  GraphicsEngine::storeMatrices();
    119145
    120   float z;
    121   glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    122 
    123 
    124   printf("%f %f %f\n", (int)position2D[0], (int)position2D[1], z);
     146///  float z;
     147//   glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
     148
    125149
    126150  //cout << z <<"  "<< scale << "  "  << bias<< endl;
     151
    127152
    128153  GLdouble objX, objY, objZ;
    129154  gluUnProject(position2D[0],
    130155               GraphicsEngine::getInstance()->getResolutionY()-position2D[1]-1,
    131                .5,
     156               .99,
    132157               GraphicsEngine::modMat,
    133158               GraphicsEngine::projMat,
     
    137162               &objZ );
    138163
    139   glBegin(GL_TRIANGLES);
    140   glColor3f(1,0,0);
    141   glVertex3f(objX, objY, objZ);
    142   glVertex3f(objX, objY+1, objZ);
    143   glVertex3f(objX, objY, objZ+1);
     164  this->setAbsCoor(objX, objY, objZ);
     165
     166//   glBegin(GL_TRIANGLES);
     167//   glColor3f(1,0,0);
     168//   glVertex3f(objX, objY, objZ);
     169//   glVertex3f(objX, objY+1, objZ);
     170//   glVertex3f(objX, objY, objZ+1);
     171//   glEnd();
     172
     173
     174  GraphicsEngine::enter2DMode();
     175  GLdouble pos[3];
     176  gluProject(this->getAbsCoor().x,
     177             this->getAbsCoor().y,
     178             this->getAbsCoor().z,
     179             GraphicsEngine::modMat,
     180             GraphicsEngine::projMat,
     181             GraphicsEngine::viewPort,
     182             pos, pos+1, pos+2 );
     183
     184  printf("%d %d %d\n", (int)pos[0], (int)pos[1], (int)pos[2]);
     185  this->rotation += 5;
     186
     187  glTranslatef(position2D[0], position2D[1], 0);
     188  glRotatef(this->rotation, 0,0,1);
     189  this->model->draw();
     190  /*
     191  glBegin(GL_QUADS);
     192  {
     193    glColor4f(1,0,0,1);
     194    glVertex2f(position2D[0]-10, position2D[1]-10);
     195    glVertex2f(position2D[0]+10, position2D[1]-10);
     196    glVertex2f(position2D[0]+10, position2D[1]+10);
     197    glVertex2f(position2D[0]-10, position2D[1]+10);
     198
     199    //     glVertex2f(pos[0]-10, pos[1]-10);
     200    //     glVertex2f(pos[0]-10, pos[1]+10);
     201    //     glVertex2f(pos[0]+10, pos[1]+10);
     202    //     glVertex2f(pos[0]+10, pos[1]-10);
     203  }
    144204  glEnd();
    145 }
     205  */
     206  GraphicsEngine::leave2DMode();
     207}
  • orxonox/trunk/src/world_entities/weapons/crosshair.h

    r4781 r4830  
    99
    1010#include "event_listener.h"
    11 
     11#include "p_node.h"
    1212#include "vector.h"
    1313
    1414// FORWARD DEFINITION
    15 
     15class Model;
     16class Material;
    1617
    1718//! A class that enables the
    18 class Crosshair : public EventListener {
     19class Crosshair : public PNode, public EventListener {
    1920
    2021 public:
     
    2526  virtual void process(const Event &event);
    2627
    27   /** @returns the current 3D-position of the Crosshair */
    28   const Vector& getPosition() { return this->position; };
    29 
    3028  void tick(float dt);
    31   void draw() const;
     29  void draw();
    3230
    3331 private:
    34    Vector           position;             //!< The current position of the Crosshair
    3532   float            position2D[2];        //!< The 2D-position on the screen
    3633
     34   Model*           model;                //!< A model for the crosshair representing the Aim
     35   Material*        material;             //!< a material for the Aim.
     36   float            rotation;             //!< a rotation of the aim.
     37   float            size;                 //!< The Size of the Crosshair (in % of screen resolution 1 is fullscreen)
    3738};
    3839
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4828 r4830  
    3333  this->setRelCoor(coordinate);
    3434  this->setRelDir(direction);
    35   this->worldEntities = State::getWorldEntityList();
    3635}
    3736
     
    156155   can destroy the weapons of enemies or vice versa.
    157156*/
    158 void Weapon::hit (WorldEntity* entity, Vector* position)
     157void Weapon::hit (WorldEntity* entity, const Vector& position)
    159158{}
    160159
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4827 r4830  
    3232class TiXmlElement;
    3333
     34//! An enumerator defining actions a Weapon can take
     35typedef enum {
     36  WA_NONE          =    0,    //!< No Action taken
     37  WA_SHOOT         =    1,    //!< emitting Shot
     38  WA_CHARGE        =    2,    //!< charge action (one click before the shot)
     39  WA_RELOAD        =    3,    //!< reload right after shoot is finished
     40  WA_ACTIVATE      =    4,    //!< activate the GUN
     41  WA_DEACTIVATE    =    5,    //!< deactivate the GUN
     42  WA_SPECIAL1      =    6,    //!< Special Action taken
    3443
    35 // typedef enum {
    36 //   W_SHOOT,
    37 //   W_EMPTY,
    38 //   W_RELOAD,
    39 //   W_SPECIAL1,
    40 //   W_SPECIAL2,
    41 //   W_SPECIAL3
    42 // } WeaponSoundType;
    43 
     44  WA_ACTION_COUNT  =    6     //!< This must match the count of enumerations (without W_NONE)
     45} WeaponActions;
    4446
    4547//! An enumerator defining the States of a Weapon
    4648typedef enum {
    47   W_NONE          =    0,    //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable)
    48   W_SHOOT         =    1,    //!< The State of the Shooting
    49   W_RELOAD        =    2,    //!< The State of the Reloading
    50   W_ACTIVATING    =    3,    //!< The State in which the weapon gets activated
    51   W_DEACTIVATING  =    4,    //!< The State in which the weapon gets deactivated
    52   W_INACTIVE      =    5,    //!< The State where the weapon is inactive (unable to shoot)
    53   W_IDLE          =    6,    //!< The State where the weapon is idle
     49  WS_NONE          =    0,    //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable)
     50  WS_SHOOTING      =    1,    //!< The State of the Shooting
     51  WS_RELOADING     =    3,    //!< The State of the Reloading
     52  WS_ACTIVATING    =    4,    //!< The State in which the weapon gets activated
     53  WS_DEACTIVATING  =    5,    //!< The State in which the weapon gets deactivated
     54  WS_INACTIVE      =    6,    //!< The State where the weapon is inactive (unable to shoot)
     55  WS_IDLE          =    7,    //!< The State where the weapon is idle
    5456
    55   W_STATES_COUNT  =    6     //!< This must match the count of the enumerations (without W_NONE)
     57  WS_STATE_COUNT  =    7     //!< This must match the count of the enumerations (without W_NONE)
    5658} WeaponState;
    5759
    5860
    5961//! a weapon can be left or right sided
     62/**
     63 * @todo this will be reset with mirror X/Y/Z
     64 */
    6065#define    W_LEFT        0
    6166#define    W_RIGHT       1
     
    99104  /** @brief fires the weapon */
    100105  virtual void fire() = 0;
    101   virtual void hit (WorldEntity* weapon, Vector* loc);
     106  virtual void hit (WorldEntity* weapon, const Vector& loc);
    102107  virtual void destroy();
    103108
     
    107112
    108113 protected:
    109   tList<WorldEntity>*  worldEntities;
    110114
    111   float                localTime;                 //<! this is the local time. important for shooting attributes like frequency
    112   float                idleTime;                  //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
    113   float                slowDownFactor;            //<! if the shooting frequency is a linear function of time...
     115  float                localTime;                        //<! this is the local time. important for shooting attributes like frequency
     116  float                idleTime;                         //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
     117  float                slowDownFactor;                   //<! if the shooting frequency is a linear function of time...
     118
     119  ////////////
     120  // PHASES //
     121  ////////////
     122  float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState
     123  SoundBuffer*         soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction
     124
     125
    114126
    115127  SoundBuffer*         fireSound;
     
    118130
    119131 private:
    120   bool                 enabled;                    //<! states if the weapon is enabled or not
    121   Projectile*          projectile;          //<! the projectile used for this weapon
     132  bool                 enabled;                          //<! states if the weapon is enabled or not
     133  Projectile*          projectile;                       //<! the projectile used for this weapon
    122134  //WeaponSound sound;
    123135};
Note: See TracChangeset for help on using the changeset viewer.