Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10695 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 14, 2007, 4:46:18 PM (18 years ago)
Author:
snellen
Message:

changes on soundengine and mover by fabian landau

Location:
trunk/src
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/math/quaternion.cc

    r9656 r10695  
    7979 * @param yaw: the yaw in radians
    8080 */
    81 Quaternion::Quaternion (float roll, float pitch, float yaw)
    82 {
     81Quaternion::Quaternion (float attitude, float heading, float bank)
     82{
     83/*
    8384  float cr, cp, cy, sr, sp, sy, cpcy, spsy;
    8485
     
    99100  v.y = cr * sp * cy + sr * cp * sy;
    100101  v.z = cr * cp * sy - sr * sp * cy;
    101 }
     102*/
     103  float c1, c2, c3, s1, s2, s3;
     104
     105  c1 = cos(heading / 2);
     106  c2 = cos(attitude / 2);
     107  c3 = cos(bank / 2);
     108
     109  s1 = sin(heading / 2);
     110  s2 = sin(attitude / 2);
     111  s3 = sin(bank / 2);
     112
     113  w = c1 * c2 * c3 - s1 * s2 * s3;
     114  v.x = s1 * s2 * c3 +c1 * c2 * s3;
     115  v.y = s1 * c2 * c3 + c1 * s2 * s3;
     116  v.z = c1 * s2 * c3 - s1 * c2 * s3;
     117}
     118
    102119
    103120/**
     
    271288}
    272289
     290/**
     291 * @returns Bank, Attitude, Heading
     292 */
     293Vector Quaternion::getRotation() const
     294{
     295  return Vector(getAttitude(), getHeading(), getBank());
     296}
    273297
    274298
  • trunk/src/lib/math/quaternion.h

    r9656 r10695  
    109109    float getBank() const;
    110110    Quaternion getBankQuat() const;
     111
     112    Vector getRotation() const;
     113
    111114    /** @returns the rotational axis of this Quaternion */
    112115    inline Vector getSpacialAxis() const { return this->v / sin(acos(w));/*sqrt(v.x*v.x + v.y*v.y + v.z+v.z);*/ };
  • trunk/src/lib/sound/sound_engine.cc

    r10618 r10695  
    317317      alSourcef (source, AL_PITCH,    1.0      );
    318318      alSourcef (source, AL_GAIN,     this->getEffectsVolume() );
     319      alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
    319320      alSourcei (source, AL_LOOPING,  AL_FALSE );
    320321      this->ALSources.push(source);
  • trunk/src/lib/sound/sound_source.cc

    r9869 r10695  
    126126      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    127127      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    128       alSourcef (this->sourceID, AL_GAIN, 1);
     128//      alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
     129      alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
    129130      alSourcePlay(this->sourceID);
    130131
     
    151152    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    152153    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    153     alSourcef (this->sourceID, AL_GAIN, 1);
     154//    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
     155    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
    154156
    155157    alSourcePlay(this->sourceID);
     
    168170   * @param buffer the buffer to play back on this Source
    169171   * @param gain the gain of the sound buffer
    170   */
    171   void SoundSource::play(const SoundBuffer& buffer, float gain)
     172   * @param rolloff the rolloff of the sound buffer
     173  */
     174  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff)
    172175  {
    173176    if (!this->retrieveSource())
     
    180183    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    181184    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     185    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
    182186    alSourcef (this->sourceID, AL_GAIN, gain);
    183187
     
    193197
    194198  /**
    195    * @brief Plays back buffer on this Source with gain and looping possibility
     199   * @brief Plays back buffer on this Source with gain, rolloff and looping possibility
    196200   * @param buffer the buffer to play back on this Source
    197    *  @param gain the gain of the sound buffer
     201   * @param gain the gain of the sound buffer
     202   * @param rolloff the rolloff of the sound buffer
    198203   * @param loop if true, sound gets looped
    199204   */
    200   void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
     205  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff, bool loop)
    201206  {
    202207    if (!this->retrieveSource())
     
    215220
    216221    alSourcef (this->sourceID, AL_GAIN, gain);
     222    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
    217223
    218224    alSourcePlay(this->sourceID);
     
    226232  }
    227233
     234  /**
     235   * @brief Plays back buffer on this Source with looping possibility
     236   * @param buffer the buffer to play back on this Source
     237   * @param loop if true, sound gets looped
     238   */
     239  void SoundSource::play(const SoundBuffer& buffer, bool loop)
     240  {
     241    if (!this->retrieveSource())
     242    {
     243      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     244      return;
     245    }
     246
     247    alSourceStop(this->sourceID);
     248    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
     249
     250    if (loop)
     251      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     252    else
     253      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     254
     255    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
     256
     257    alSourcePlay(this->sourceID);
     258
     259    if (unlikely(this->buffer.getID() != 0))
     260      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
     261    this->bPlay = true;
     262
     263    if (DEBUG_LEVEL >= 3)
     264      SoundEngine::checkError("Play Source", __LINE__);
     265  }
     266 
    228267  /**
    229268   * @brief Changes the volume of an (active) buffer
  • trunk/src/lib/sound/sound_source.h

    r9869 r10695  
    3030    void play();
    3131    void play(const SoundBuffer& buffer);
    32     void play(const SoundBuffer& buffer, float gain);
    33     void play(const SoundBuffer& buffer, float gain, bool loop);
     32    void play(const SoundBuffer& buffer, float gain, float rolloff);
     33    void play(const SoundBuffer& buffer, float gain, float rolloff, bool loop);
     34    void play(const SoundBuffer& buffer, bool loop);
    3435
    3536    void gain(const SoundBuffer& buffer, float gain);
  • trunk/src/world_entities/WorldEntities.am

    r10638 r10695  
    1212                world_entities/npcs/repair_station.cc \
    1313                world_entities/npcs/attractor_mine.cc \
    14                 world_entities/npcs/mover.cc \
    1514                \
    1615                \
     
    7978                world_entities/environments/planet.cc \
    8079                world_entities/environments/bsp_entity.cc \
     80                world_entities/environments/mover.cc \
     81                world_entities/environments/mover_station.cc \
     82                world_entities/environments/mover_station_list.cc \
     83                world_entities/environments/mover_trigger.cc \
     84                world_entities/environments/mover_trigger_approach.cc \
     85                world_entities/environments/mover_trigger_delay_list.cc \
     86                world_entities/environments/mover_trigger_event.cc \
     87                world_entities/environments/mover_trigger_event_list.cc \
     88                world_entities/environments/mover_trigger_intervisibility.cc \
     89                world_entities/environments/mover_trigger_key.cc \
     90                world_entities/environments/mover_trigger_list.cc \
     91                world_entities/environments/mover_trigger_pointer_list.cc \
     92                world_entities/environments/mover_trigger_mapstart.cc \
    8193                \
    8294                \
     
    146158                npcs/repair_station.h \
    147159                npcs/attractor_mine.h \
    148                 npcs/mover.h \
    149160                \
    150161                environments/environment.h \
     
    224235                environments/mapped_water.h \
    225236                environments/rotor.h \
     237                environments/mover.h \
     238                environments/mover_station.h \
     239                environments/mover_station_list.h \
     240                environments/mover_trigger.h \
     241                environments/mover_trigger_approach.h \
     242                environments/mover_trigger_delay_list.h \
     243                environments/mover_trigger_event.h \
     244                environments/mover_trigger_event_list.h \
     245                environments/mover_trigger_intervisibility.h \
     246                environments/mover_trigger_key.h \
     247                environments/mover_trigger_list.h \
     248                environments/mover_trigger_pointer_list.h \
     249                environments/mover_trigger_mapstart.h \
    226250                \
    227251                elements/image_entity.h \
  • trunk/src/world_entities/effects/explosion.cc

    r10665 r10695  
    2525#include "particles/sprite_particles.h"
    2626
     27#include "sound/resource_sound_buffer.h"
     28#include "sound_engine.h"
     29
     30
    2731ObjectListDefinition(Explosion);
    2832CREATE_FAST_FACTORY_STATIC(Explosion);
     
    3842                        //Explode !
    3943                            ->addMethod("explode", Executor3<Explosion, lua_State*, float, float, float>(&Explosion::explode))
     44                            ->addMethod("setExplosionSound", Executor1<Explosion, lua_State*, const std::string&>(&Explosion::setExplosionSound))
    4045                       );
    4146
     
    5560  this->lifeCycle = 0.0f;
    5661  this->lifeTime = .5f;
    57 
     62 
     63  this->explosionSound.setSourceNode(this);
     64 
    5865}
    5966
     
    6572{
    6673  delete this->emitter;
    67 
     74  if (this->explosionSound.isPlaying())
     75    this->explosionSound.stop();
    6876  /* this is normaly done by World.cc by deleting the ParticleEngine */
    6977  if (Explosion::explosionParticles != NULL && Explosion::objectList().size() <= 1)
     
    8896  explosion->emitter->setSize(Vector(x,y,z));
    8997  explosion->activate();
     98 
     99 
    90100}
    91101
     
    113123  this->toList(OM_DEAD_TICK);
    114124  this->lifeCycle = 0.0;
     125 
     126  this->explosionSound.play(this->explosionSoundBuffer, OrxSound::SoundEngine::getInstance()->getEffectsVolume(), 0.01, true);
    115127}
    116128
  • trunk/src/world_entities/effects/explosion.h

    r10665 r10695  
    88
    99#include "world_entity.h"
     10#include "sound_source.h"
     11#include "sound_buffer.h"
     12#include "sound/resource_sound_buffer.h"
    1013
    1114class SpriteParticles;
     
    1922    static void explode (PNode* position, const Vector& size);
    2023    void explode (float x, float y, float z); /// Explode at the current position with size (x,y,z)
     24    void setExplosionSound(const std::string& newExplosionSound){  this->explosionSoundBuffer = OrxSound::ResourceSoundBuffer(newExplosionSound);  }
    2125   
    2226    Explosion ();
     
    3640    static SpriteParticles*    explosionParticles;
    3741    BoxEmitter*                emitter;
     42   
     43    OrxSound::SoundSource      explosionSound;
     44    OrxSound::SoundBuffer      explosionSoundBuffer;
    3845};
    3946
Note: See TracChangeset for help on using the changeset viewer.