Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5961 in orxonox.OLD for branches/avi_play/src/lib


Ignore:
Timestamp:
Dec 7, 2005, 2:53:43 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/avi_play: merged the trunk back to the avi_play branche again
merged with command
svn merge -r 5924:HEAD ../trunk/ avi_play/

Location:
branches/avi_play/src/lib
Files:
2 deleted
17 edited
14 copied

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/Makefile.am

    r5822 r5961  
    1515                            network/libORXnet.a \
    1616                            graphics/spatial_separation/libORXquadtree.a \
    17                             tinyxml/libtinyxml.a \
     17                            parser/tinyxml/libtinyxml.a \
     18                            parser/ini_parser/libIniParser.a \
    1819                            shell/libORXshell.a
    1920
     
    2930                            network/libORXnet.a \
    3031                            graphics/spatial_separation/libORXquadtree.a \
    31                             tinyxml/libtinyxml.a \
    3232                            shell/libORXshell.a \
    3333                            $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
     
    3737                        lang/base_object.cc \
    3838                        lang/class_list.cc \
    39                         util/ini_parser.cc \
    4039                        util/substring.cc \
    4140                        util/color.cc \
     
    5352                        graphics/render2D/render_2d.h \
    5453                        lang/class_list.h \
    55                         util/ini_parser.h \
    5654                        util/substring.h \
    5755                        util/array.h \
     
    7573          collision_detection \
    7674          network \
    77           tinyxml \
     75          parser \
    7876          shell \
    7977          gui \
  • branches/avi_play/src/lib/event/key_mapper.cc

    r5924 r5961  
    2424
    2525#include "globals.h"
    26 #include "ini_parser.h"
     26#include "parser/ini_parser/ini_parser.h"
    2727#include "key_names.h"
    2828#include "debug.h"
     
    132132  int* index;
    133133
    134   iniParser->getFirstVar();
     134  iniParser->firstVar();
    135135  while(iniParser->getCurrentName())
    136136  {
     
    151151  }
    152152
    153   iniParser->getFirstVar();
     153  iniParser->firstVar();
    154154  while(iniParser->getCurrentName())
    155155  {
  • branches/avi_play/src/lib/graphics/graphics_engine.cc

    r5924 r5961  
    2626#include "debug.h"
    2727
    28 #include "ini_parser.h"
     28#include "parser/ini_parser/ini_parser.h"
    2929#include "substring.h"
    3030#include "text.h"
  • branches/avi_play/src/lib/graphics/light.cc

    r5750 r5961  
    2222#include "glincl.h"
    2323#include "vector.h"
    24 #include "tinyxml.h"
     24#include "parser/tinyxml/tinyxml.h"
    2525#include "load_param.h"
    2626#include "factory.h"
  • branches/avi_play/src/lib/graphics/render2D/element_2d.cc

    r5783 r5961  
    2323#include "graphics_engine.h"
    2424#include "load_param.h"
    25 #include "tinyxml.h"
     25#include "parser/tinyxml/tinyxml.h"
    2626#include "class_list.h"
    2727
  • branches/avi_play/src/lib/gui/gtk_gui/gui_audio.cc

    r5298 r5961  
    4242    {
    4343      CheckButton* enableSound; //!< A Ckeckbutton for enabling Sound.
     44      Slider* audioChannels;    //!< A Slider for the count of audio-channels.
    4445      Slider* musicVolume;      //!< A Slider for music volume.
    4546      Slider* effectsVolume;    //!< A Slider for effects volume.
     
    5152      enableSound->saveability();
    5253      audioBox->fill(enableSound);
     54
     55      Label* audioChannelsLabel = new Label(CONFIG_NAME_AUDIO_CHANNELS);
     56      audioBox->fill(audioChannelsLabel);
     57      audioChannels = new Slider(CONFIG_NAME_AUDIO_CHANNELS, 0, 32);
     58      audioChannels->setFlagName("channels", "c", 32);
     59      audioChannels->setDescription("Sets the count of channels in the game");
     60      audioChannels->saveability();
     61      audioBox->fill (audioChannels);
     62
     63
    5364      Label* musicVolumeLabel = new Label(CONFIG_NAME_MUSIC_VOLUME);
    5465      audioBox->fill(musicVolumeLabel);
     
    5869      musicVolume->saveability();
    5970      audioBox->fill (musicVolume);
     71
    6072      Label* effectsVolumeLabel = new Label (CONFIG_NAME_EFFECTS_VOLUME);
    6173      audioBox->fill (effectsVolumeLabel);
  • branches/avi_play/src/lib/gui/gtk_gui/gui_exec.cc

    r5241 r5961  
    2727
    2828#include "resource_manager.h"
    29 #include "ini_parser.h"
     29#include "parser/ini_parser/ini_parser.h"
    3030
    3131#include <string.h>
     
    254254
    255255/**
    256  * Reads in Configuration Data.
     256 * @brief Reads in Configuration Data.
    257257 * @param widget from which Widget on should be saved.
    258258*/
     
    265265    return;
    266266
    267   iniParser.getFirstSection();
     267  iniParser.firstSection();
    268268  Widget* groupWidget = widget;
    269269  const char* groupName;
     
    272272  while (groupName = iniParser.getCurrentSection())
    273273  {
     274    printf("GROUP:::%s\n", groupName);
    274275    if((groupWidget = locateGroup(widget, groupName, 1))==NULL)
    275     {
    276       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", groupName);
    277       groupWidget = widget;
    278       continue;
    279     }
     276      {
     277        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", groupName);
     278        groupWidget = widget;
     279        continue;
     280      }
    280281    else
    281       PRINT(0)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName);
    282 
    283     iniParser.getFirstVar();
    284     while(iniParser.getCurrentName())
    285     {
    286       varInfo.variableName = iniParser.getCurrentName();
     282      PRINT(4)("Group %s located.\n", static_cast<Packer*>(groupWidget)->groupName);
     283
     284    const char* entryName;
     285    iniParser.firstVar();
     286    while(entryName = iniParser.getCurrentName())
     287    {
     288      PRINTF(4)("ENTRY:::%s = %s\n", entryName, iniParser.getCurrentValue());
     289      varInfo.variableName = entryName;
    287290      varInfo.variableValue = iniParser.getCurrentValue();
    288291      groupWidget->walkThrough(this->readFileText, &varInfo, 0);
     
    303306{
    304307  VarInfo* info =(VarInfo*)varInfo;
     308  if (info == NULL || info->variableName == NULL)
     309    return;
     310
    305311  if(widget->title && !strcmp(widget->title, info->variableName))
    306312    {
    307313      PRINT(5)("Located Option %s.\n", widget->title);
    308314      if(widget->optionType > GUI_NOTHING)
    309         static_cast<Option*>(widget)->load(info->variableValue);
     315        if (info->variableValue != NULL)
     316          static_cast<Option*>(widget)->load(info->variableValue);
    310317    }
    311318}
     
    323330{
    324331  Widget* tmp;
     332  if (widget  == NULL || groupName == NULL)
     333    return NULL;
    325334
    326335  if(widget->optionType < GUI_NOTHING)
    327336    {
    328       if(static_cast<Packer*>(widget)->getGroupName() &&
     337      if(static_cast<Packer*>(widget)->getGroupName() != NULL &&
    329338         !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
    330         {
    331           return widget;
    332         }
     339        return widget;
    333340      else
    334341        {
    335           if((tmp = locateGroup(static_cast<Packer*>(widget)->down, groupName, depth+1)) != NULL)
     342          if((tmp = locateGroup(static_cast<Packer*>(widget)->down,
     343                                groupName, depth+1)) != NULL)
    336344            return tmp;
    337345        }
  • branches/avi_play/src/lib/gui/gtk_gui/gui_keys.cc

    r5766 r5961  
    119119        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_LEFT, "LEFT"));
    120120        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_RIGHT, "RIGHT"));
    121         pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, "MOUSE_LEFT"));
     121        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_FIRE, "BUTTON_LEFT"));
    122122        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_NEXT_WEAPON, "m"));
    123123        pKeysBox->fill(addKey(CONFIG_NAME_PLAYER_PREV_WEAPON, "n"));
  • branches/avi_play/src/lib/particles/particle_engine.h

    r5447 r5961  
    1212#include "particle_emitter.h"
    1313
    14 #include "tinyxml.h"
     14#include "parser/tinyxml/tinyxml.h"
    1515
    1616// FORWARD DECLARATION
  • branches/avi_play/src/lib/particles/particle_system.cc

    r5750 r5961  
    3030#include "shell_command.h"
    3131
    32 #include "tinyxml.h"
     32#include "parser/tinyxml/tinyxml.h"
    3333
    3434CREATE_FACTORY(ParticleSystem, CL_PARTICLE_SYSTEM);
  • branches/avi_play/src/lib/physics/physics_engine.cc

    r5779 r5961  
    2020#include "class_list.h"
    2121#include "list.h"
    22 #include "tinyxml.h"
     22#include "parser/tinyxml/tinyxml.h"
    2323#include "factory.h"
    2424#include "load_param.h"
  • branches/avi_play/src/lib/sound/sound_buffer.cc

    r5422 r5961  
    2020#include "sound_engine.h"
    2121
    22 
    2322using namespace std;
    24 
    2523
    2624//////////////////
     
    3634  this->setName(fileName);
    3735
    38   SoundEngine::getInstance()->addBuffer(this);
    39 
    4036  ALenum format;
    4137  ALvoid* data;
     
    4743  alGenBuffers(1, &this->bufferID);
    4844  if ((result = alGetError()) != AL_NO_ERROR)
    49     SoundEngine::PrintALErrorString(result);
     45    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
    5046
    5147  // read in the wav data
     
    5955#endif
    6056  if ((result = alGetError()) != AL_NO_ERROR)
    61     SoundEngine::PrintALErrorString(result);
     57    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
    6258
    6359  // send the loaded wav data to the buffer
    6460  alBufferData(this->bufferID, format, data, this->size, freq);
    6561  if ((result = alGetError()) != AL_NO_ERROR)
    66     SoundEngine::PrintALErrorString(result);
     62    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
    6763
    6864  // remove the wav data (redundant)
    6965  alutUnloadWAV(format, data, this->size, freq);
    7066  if ((result = alGetError()) != AL_NO_ERROR)
    71     SoundEngine::PrintALErrorString(result);
     67    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
    7268}
    7369
  • branches/avi_play/src/lib/sound/sound_engine.cc

    r5924 r5961  
    2727#include "resource_manager.h"
    2828#include "debug.h"
    29 #include "ini_parser.h"
     29#include "parser/ini_parser/ini_parser.h"
    3030#include "globals.h"
    3131
     
    4747  this->bufferList = NULL;
    4848  this->sourceList = NULL;
     49
     50  this->device = NULL;
     51  this->context = NULL;
     52
     53  this->maxSourceCount = 32;
    4954}
    5055
     
    6469    while (this->sourceList->size() > 0)
    6570      delete dynamic_cast<SoundSource*>(this->sourceList->front());
     71  }
     72
     73  while(!this->ALSources.empty())
     74  {
     75    alDeleteSources(1, &this->ALSources.top());
     76    this->ALSources.pop();
    6677  }
    6778
     
    8697void SoundEngine::loadSettings(IniParser* iniParser)
    8798{
     99  const char* channels = iniParser->getVar(CONFIG_NAME_AUDIO_CHANNELS, CONFIG_SECTION_AUDIO, "32");
     100  this->maxSourceCount = atoi(channels);
    88101  const char* musicVolume = iniParser->getVar(CONFIG_NAME_MUSIC_VOLUME, CONFIG_SECTION_AUDIO, "80");
    89102  this->musicVolume = atof(musicVolume)/100.0;
     
    118131
    119132
    120 /**
    121  *  adds a SoundBuffer to the bufferList of the SoundEngine
    122  * @param buffer The buffer to add to the bufferList
    123 */
    124 void SoundEngine::addBuffer(SoundBuffer* buffer)
    125 {
    126   if (unlikely(this->bufferList == NULL))
    127     this->bufferList = ClassList::getList(CL_SOUND_BUFFER);
    128 }
    129 
    130 /**
    131  *  removes a SoundBuffer from the bufferList of the SoundEngine
    132  * @param buffer The buffer to delete from the SoundEngine
    133 */
    134 void SoundEngine::removeBuffer(SoundBuffer* buffer)
    135 {
    136   // look if there are any sources that have the buffer still loaded
    137   if (this->sourceList != NULL)
    138   {
    139     list<BaseObject*>::const_iterator source;
    140     for (source = this->sourceList->begin(); source != this->sourceList->end(); source++)
    141     {
    142       if (buffer == static_cast<SoundSource*>(*source)->getBuffer())
    143         delete (*source);
     133void SoundEngine::popALSource(ALuint& source)
     134{
     135  if (source != 0)
     136    return;
     137  else
     138  {
     139
     140    /// @TODO try to create more sources if needed
     141    if (!this->ALSources.empty())
     142    {
     143
     144      source = this->ALSources.top();
     145      printf("test: : %d\n", source);
     146      this->ALSources.pop();
    144147    }
    145148  }
    146149}
    147150
    148 /**
    149  * adds a SoundSource to the sourceList of the SoundEngine
    150  * @param source The source to add to the sourceList
    151 */
    152 void SoundEngine::addSource(SoundSource* source)
    153 {
    154   this->sourceList = ClassList::getList(CL_SOUND_SOURCE);
    155 }
    156151
    157152/**
     
    180175
    181176  // updating all the Sources positions
    182   if (likely(this->sourceList != NULL))
     177  if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL))
    183178  {
    184179    list<BaseObject*>::const_iterator sourceIT;
     
    187182    {
    188183      source = static_cast<SoundSource*>(*sourceIT);
    189       if (likely(source->getNode() != NULL))
     184      if (source->isPlaying())
    190185      {
    191         alSource3f(source->getID(), AL_POSITION,
    192                    source->getNode()->getAbsCoor().x,
    193                    source->getNode()->getAbsCoor().y,
    194                    source->getNode()->getAbsCoor().z);
    195         alSource3f(source->getID(), AL_VELOCITY,
    196                    source->getNode()->getVelocity().x,
    197                    source->getNode()->getVelocity().y,
    198                    source->getNode()->getVelocity().z);
     186        int play;
     187        alGetSourcei(source->getID(), AL_SOURCE_STATE, &play);
     188        if(play == AL_PLAYING)
     189        {
     190          if (likely(source->getNode() != NULL))
     191          {
     192            alSource3f(source->getID(), AL_POSITION,
     193                       source->getNode()->getAbsCoor().x,
     194                       source->getNode()->getAbsCoor().y,
     195                       source->getNode()->getAbsCoor().z);
     196            alSource3f(source->getID(), AL_VELOCITY,
     197                       source->getNode()->getVelocity().x,
     198                       source->getNode()->getVelocity().y,
     199                       source->getNode()->getVelocity().z);
     200          }
     201
     202        }
     203        else
     204        {
     205          source->stop();
     206        }
    199207      }
    200208    }
     
    281289
    282290  // INITIALIZING THE DEVICE:
    283 #ifndef AL_VERSION_1_1
     291#ifdef AL_VERSION_1_1
    284292  ALubyte deviceName[] =
    285293#else
     
    300308
    301309  if ((result = alGetError()) != AL_NO_ERROR)
    302     SoundEngine::PrintALErrorString(result);
     310    PRINTF(2)("%s\n", SoundEngine::getALErrorString(result));
    303311
    304312  this->setDopplerValues(SOUND_DOPPLER_FACTOR, SOUND_DOPPLER_VELOCITY);
     
    313321bool SoundEngine::allocateSources(unsigned int count)
    314322{
    315   ALuint* sourceList = new ALuint[count];
    316323  ALenum result;
    317 
    318   alGenSources(count, sourceList);
    319   if ((result = alGetError()) != AL_NO_ERROR)
    320   {
    321     SoundEngine::PrintALErrorString(result);
    322     return false;
    323   }
    324 
    325   /// @TODO check syntax
    326 
    327 
    328324  // Setting default values.
    329   for (int i = 0; i < count; i++)
    330   {
    331     alSourcef (sourceList[i], AL_PITCH,    1.0      );
    332     alSourcef (sourceList[i], AL_GAIN,     this->getEffectsVolume() );
    333     alSourcei (sourceList[i], AL_LOOPING,  AL_FALSE );
    334     this->ALSources.push(sourceList[i]);
     325  for (unsigned int i = 0; i < count; i++)
     326  {
     327    ALuint source;
     328
     329    alGenSources(1, &source);
     330    if ((result = alGetError()) != AL_NO_ERROR)
     331      PRINTF(1)("Error Generating Sources: '%s'\n", SoundEngine::getALErrorString(result));
     332
     333    alSourcef (source, AL_PITCH,    1.0      );
     334    alSourcef (source, AL_GAIN,     this->getEffectsVolume() );
     335    alSourcei (source, AL_LOOPING,  AL_FALSE );
     336    this->ALSources.push(source);
    335337  }
    336338  return true;
     
    341343 * @param err The error found
    342344*/
    343 void SoundEngine::PrintALErrorString(ALenum err)
     345const char* SoundEngine::getALErrorString(ALenum err)
    344346{
    345347  switch(err)
    346348    {
    347349    case AL_NO_ERROR:
    348       PRINTF(4)("AL_NO_ERROR\n");
    349       break;
    350 
     350      return ("AL_NO_ERROR");
    351351    case AL_INVALID_NAME:
    352       PRINTF(2)("AL_INVALID_NAME\n");
    353       break;
    354 
     352      return ("AL_INVALID_NAME");
    355353    case AL_INVALID_ENUM:
    356       PRINTF(2)("AL_INVALID_ENUM\n");
    357       break;
    358 
     354      return ("AL_INVALID_ENUM");
    359355    case AL_INVALID_VALUE:
    360       PRINTF(2)("AL_INVALID_VALUE\n");
    361       break;
    362 
     356      return ("AL_INVALID_VALUE");
    363357    case AL_INVALID_OPERATION:
    364       PRINTF(2)("AL_INVALID_OPERATION\n");
    365       break;
    366 
     358      return ("AL_INVALID_OPERATION");
    367359    case AL_OUT_OF_MEMORY:
    368       PRINTF(2)("AL_OUT_OF_MEMORY\n");
    369       break;
     360      return ("AL_OUT_OF_MEMORY");
    370361    };
    371362}
     
    373364void SoundEngine::listDevices()
    374365{
    375 
    376366  printf("%s\n",(const char*)alcGetString(NULL, ALC_DEVICE_SPECIFIER));
    377367}
  • branches/avi_play/src/lib/sound/sound_engine.h

    r5924 r5961  
    2626//! A class that handles audio via the openAudioLibrary
    2727class SoundEngine : public BaseObject {
    28 
    2928  public:
    3029    virtual ~SoundEngine();
     
    4948
    5049  // administrative
    51     void addBuffer(SoundBuffer* buffer);
    52     void removeBuffer(SoundBuffer* buffer);
    53     void addSource(SoundSource* source);
     50    void popALSource(ALuint& source);
     51    void pushALSource(ALuint& source) { if (source != 0) this->ALSources.push(source); };
    5452
    5553    void flushUnusedBuffers();
     
    5755    void flushAllSources();
    5856
     57    bool initAudio();
    5958    bool allocateSources(unsigned int count);
    60     bool initAudio();
    6159
    6260  // error handling:
    63     static void PrintALErrorString(ALenum err);
    64   //  static void PrintALCErrorString(ALenum err);
    65 
     61    static const char* getALErrorString(ALenum err);
    6662
    6763  private:
    6864    SoundEngine();
     65
    6966    void listDevices();
    7067
  • branches/avi_play/src/lib/sound/sound_source.cc

    r5924 r5961  
    3434
    3535  // adding the Source to the SourcesList of the SoundEngine
    36   SoundEngine::getInstance()->addSource(this);
    37 
    3836  this->buffer = buffer;
    3937  this->sourceNode = sourceNode;
    4038
    41   alGenSources(1, &this->sourceID);
    42   if ((result = alGetError()) != AL_NO_ERROR)
    43     SoundEngine::PrintALErrorString(result);
    44   if (this->buffer != NULL)
    45     alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
    46   alSourcef (this->sourceID, AL_PITCH,    1.0      );
    47   alSourcef (this->sourceID, AL_GAIN,     SoundEngine::getInstance()->getEffectsVolume() );
    48   alSourcei (sourceID, AL_LOOPING,  AL_FALSE     );
     39  this->sourceID = 0;
     40  this->bPlay = false;
    4941}
    5042
     
    5446SoundSource::~SoundSource()
    5547{
    56   //SoundEngine::getInstance()->removeSource(this);
    57   alDeleteSources(1, &this->sourceID);
     48  SoundEngine::getInstance()->pushALSource(this->sourceID);
    5849}
    5950
     
    6354void SoundSource::play()
    6455{
     56  if (this->sourceID == 0)
     57    SoundEngine::getInstance()->popALSource(this->sourceID);
    6558  alSourcePlay(this->sourceID);
     59  this->bPlay = true;
    6660}
    6761
     
    7266void SoundSource::play(const SoundBuffer* buffer)
    7367{
     68  if (unlikely(this->sourceID == 0))
     69    SoundEngine::getInstance()->popALSource(this->sourceID);
     70
     71  printf("%d\n",sourceID);
    7472  alSourceStop(this->sourceID);
    7573  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     
    7876  if (unlikely(this->buffer != NULL))
    7977    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     78  this->bPlay = true;
    8079}
    8180
     
    8584void SoundSource::stop()
    8685{
     86  this->bPlay = false;
    8787  alSourceStop(this->sourceID);
     88  SoundEngine::getInstance()->pushALSource(this->sourceID);
    8889}
    8990
  • branches/avi_play/src/lib/sound/sound_source.h

    r5924 r5961  
    3131    /** @returns The ID of this Source */
    3232    inline ALuint getID() const { return this->sourceID; }
     33    /** @returns true, if the Source is Playing */
     34    inline bool   isPlaying() const { return this->bPlay; };
    3335    /** @returns the SoundBuffer of this Source */
    3436    inline const SoundBuffer* getBuffer() const { return this->buffer; }
  • branches/avi_play/src/lib/util/executor/executor_specials.h

    r5754 r5961  
    1010
    1111#include "compiler.h"
    12 #include "tinyxml.h"
     12#include "parser/tinyxml/tinyxml.h"
    1313// FORWARD DECLARATION
    1414
Note: See TracChangeset for help on using the changeset viewer.