Index: branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 8050)
+++ branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc	(revision 8052)
@@ -22,4 +22,5 @@
 #include "glincl.h"
 //#include "graphics_engine.h"
+#include "material.h"
 #include <math.h>
 
@@ -69,10 +70,13 @@
 
 	// Generate noise map a
-	CloudEffect::genNoiseMap(cloudMap32_a);
+	//CloudEffect::genNoiseMap(cloudMap32_a);
 	
 	if (this->cloudAnimTimeStep > 0) {
 		// Generate noise map b
-		CloudEffect::genNoiseMap(cloudMap32_b);
+		//CloudEffect::genNoiseMap(cloudMap32_b);
 	}
+
+  this->material = new Material();
+
 }
 
@@ -80,12 +84,6 @@
 {
 	PRINTF(0)( "Activating CloudEffect\n");
-	if (this->cloudAnimTimeStep == 0) {
-		for (int i = 0; i < 32*32; i++)
-			cloudMap32_c[i] = cloudMap32_a[i];
 
-		CloudEffect::overlapOctaves();
-		CloudEffect::expFilter();
-		CloudEffect::genCloudTexture();
-	}
+
 }
 
@@ -95,43 +93,36 @@
 }
 
-void CloudEffect::genCloudTexture() {
-	for(int i=0; i<256; i++)
-		for(int j=0; j<256; j++) 
-		{
-			float color = cloudMap256[i*256+j]; 
-			cloudTexture[i][j][0] = (char) color;
-			cloudTexture[i][j][1] = (char) color;
-			cloudTexture[i][j][2] = (char) color;
-		}
-
-	glBindTexture(GL_TEXTURE_2D, texID[0]);
-
-	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, cloudTexture);
-	gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, cloudTexture);
-
-}
-
-void CloudEffect::calcAnimMap(float timer) {
-
-	for (int x=0; x<32*32; x++)
-		cloudMap32_c[x] = (cloudMap32_a[x] * ((this->cloudAnimTimeStep - timer) / this->cloudAnimTimeStep)) + (cloudMap32_b[x] * (timer / this->cloudAnimTimeStep));
-
-}
-
 void CloudEffect::draw() const
 {
+	/* TODO:
+		-Load a texture, for now from an existing image, a cloud texture
+		-Blend / Overlay this with a blue sky like in the tutorial
+		-Make a skybox or whatever....
+		-Animate it (for now move it along the sky)
+	*/
+
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
+  this->material->setDiffuseMap("maps/lightning_bolt.png");
+  this->material->select();
+
 	glPushMatrix();
-	glEnable(GL_TEXTURE_2D);
+ 	glEnable(GL_TEXTURE_2D);
 
-	glBindTexture(GL_TEXTURE_2D, texID[0]);
+ 	glBindTexture(GL_TEXTURE_2D, texID[0]);
 
 	// FIXME : Bind this to the sky - how do I do this?
 	glBegin(GL_QUADS);
-		glTexCoord2f(0.0f, 0.0f); glVertex3f(20, 20,  60);	// Bottom Left Of The Texture and Quad
-		glTexCoord2f(1.0f, 0.0f); glVertex3f(60, 20,  60);	// Bottom Right Of The Texture and Quad
-		glTexCoord2f(1.0f, 1.0f); glVertex3f(60, 60,  60);	// Top Right Of The Texture and Quad
-		glTexCoord2f(0.0f, 1.0f); glVertex3f(20, 60,  60);	// Top Left Of The Texture and Quad
+		glTexCoord2f(0.0f, 0.0f);
+		glVertex3f(20, 20,  60);	// Bottom Left Of The Texture and Quad
+
+		glTexCoord2f(1.0f, 0.0f);
+		glVertex3f(60, 20,  60);	// Bottom Right Of The Texture and Quad
+
+		glTexCoord2f(1.0f, 1.0f);
+		glVertex3f(60, 60,  60);	// Top Right Of The Texture and Quad
+
+		glTexCoord2f(0.0f, 1.0f);
+		glVertex3f(20, 60,  60);	// Top Left Of The Texture and Quad
 	glEnd(); 
 
@@ -141,133 +132,4 @@
 void CloudEffect::tick (float dt)
 {
-	if (this->cloudAnimTimeStep > 0) {
-		if (timer >= this->cloudAnimTimeStep) {
-			timer -= this->cloudAnimTimeStep;
-			for (int i = 0; i < 32*32; i++)
-				cloudMap32_a[i] = cloudMap32_b[i];
-			CloudEffect::genNoiseMap(cloudMap32_b);
-		}
-
-		//map32anim = (map32a * (10 - timer)) + (map32b * timer);
-		CloudEffect::calcAnimMap(timer);
-		//CloudEffect::overlapOctaves();
-		//CloudEffect::expFilter();
-		CloudEffect::genCloudTexture();
-
-		timer += dt;
-	}
+	
 }
-
-/* 
-	Random noise generator
-*/
-float CloudEffect::noise(int x, int y, int random)
-{
-		int n = x + y * 57 + random * 131;
-		n = (n<<13) ^ n;
-		return (1.0f - ( (n * (n * n * 15731 + 789221) +
-						1376312589)&0x7fffffff)* 0.000000000931322574615478515625f);
-}
-
-/*
-	Set noise for the 32*32 noise map:
-*/
-void CloudEffect::genNoiseMap(float  *map)
-{
-	float temp[34][34];
-
-	int random = rand() % 5000;
-
-	for (int y = 1; y < 33; y++)
-		for (int x = 1; x < 33; x++)
-			temp[x][y] = 128.0f + CloudEffect::noise(x,  y,  random) * 128.0f;
-
-	// Seamless cloud
-	for (int x=1; x<33; x++)
-	{
-		temp[0][x] = temp[32][x];
-		temp[33][x] = temp[1][x];
-		temp[x][0] = temp[x][32];
-		temp[x][33] = temp[x][1];
-	}
-	temp[0][0] = temp[32][32];
-	temp[33][33] = temp[1][1];
-	temp[0][33] = temp[32][1];
-	temp[33][0] = temp[1][32];
-
-	// We mirror the side and corner elements so our final cloud will be seamless without any ugly borders showing.
-	for (int y=1; y<33; y++)
-		for (int x=1; x<33; x++)
-		{
-			float center = temp[x][y]/4.0f;
-			float sides = (temp[x+1][y] + temp[x-1][y] + temp[x][y+1] + temp[x][y-1])/8.0f;
-			float corners = (temp[x+1][y+1] + temp[x+1][y-1] + temp[x-1][y+1] + temp[x-1][y-1])/16.0f;
-
-			map[((x-1)*32) + (y-1)] = center + sides + corners;
-		}
-}
-
-/*
-	Interpolation - average the value of each pixel value with that of its neighbors' values.
-*/
-float CloudEffect::interpolate(float x, float y, float  *map)
-{
-	int Xint = (int)x;
-	int Yint = (int)y;
-
-	float Xfrac = x - Xint;
-	float Yfrac = y - Yint;
-
-	int X0 = Xint % 32;
-	int Y0 = Yint % 32;
-	int X1 = (Xint + 1) % 32;
-	int Y1 = (Yint + 1) % 32;
-
-	float bot = map[X0*32 + Y0] + Xfrac * (map[X1*32 + Y0] - map[X0*32 + Y0]);
-	float top = map[X0*32 + Y1] + Xfrac * (map[X1*32 +  Y1] - map[X0*32 + Y1]);
-
-	return (bot + Yfrac * (top - bot));
-}
-
-
-/*
-	Octaves are overlapped together to give cloud more turbulence. We will use four octaves for our cloud.
-*/
-void CloudEffect::overlapOctaves()
-{
-	for (int x=0; x<256*256; x++)
-	{
-		cloudMap256[x] = 0;
-	}
-
-	for (int octave=0; octave<4; octave++)
-		for (int x=0; x<256; x++)
-			for (int y=0; y<256; y++)
-			{
-				float scale = 1 / pow(2.0f, (float) 3-octave);
-				float noise = CloudEffect::interpolate(x*scale, y*scale , cloudMap32_c);
-
-				//The octaves are added together with the proper weight factors.
-				//You could replace pow(2, i) with 1<<i for faster computation
-				cloudMap256[(y*256) + x] += noise / pow(2.0f, (float) octave);
-			}
-}
-
-
-/*
-	Filter the noise with exponential function
-*/
-void CloudEffect::expFilter()
-{
-	float cover = 20.0f;
-	float sharpness = 0.95f;
-
-	for (int x=0; x<256*256; x++)
-	{
-		float c = cloudMap256[x] - (255.0f-cover);
-		if (c<0)     c = 0;
-		cloudMap256[x] = 255.0f - ((float)(pow(sharpness, c))*255.0f);
-	}
-}
-
-
Index: branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 8050)
+++ branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h	(revision 8052)
@@ -13,4 +13,7 @@
 #include "sound_buffer.h"
 #include "sound_source.h"
+
+class Material;
+
 
 class CloudEffect : public WeatherEffect
@@ -57,4 +60,5 @@
 		void  														genCloudTexture();
 		void  														calcAnimMap(float timer);
+		Material*	material;
 
 };
Index: branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc
===================================================================
--- branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc	(revision 8050)
+++ branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc	(revision 8052)
@@ -35,5 +35,5 @@
 CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT);
 
-// TODO: Dim Light with Rain, Finish preCaching, check out if multiple rain emitters work,  Think about what happens with building poss. to hang movewithcam off, sound volume, benchmark, possible to activate lightening, turn off visibility when in a building, variable emitter size depending on playable, also rain velocity
+// TODO: Dim Light with Rain, Finish preCaching, check out if multiple rain emitters work,  Think about what happens with building poss. to hang movewithcam off, benchmark, possible to activate lightening, turn off visibility when in a building, variable emitter size depending on playable, also rain velocity
 
 RainEffect::RainEffect(const TiXmlElement* root)
@@ -139,7 +139,7 @@
 	this->emitter->setSpread(this->rainWindForce / 50, 0.2);
 	
-	this->soundSource.loop(this->rainBuffer);
+	this->soundSource.loop(this->rainBuffer, 0.8f);
 	if (this->rainWindForce > 0)
-		this->soundSource.loop(this->windBuffer);
+		this->soundSource.loop(this->windBuffer, 0.5f);
 }
 
Index: branches/atmospheric_engine/src/lib/sound/sound_source.cc
===================================================================
--- branches/atmospheric_engine/src/lib/sound/sound_source.cc	(revision 8050)
+++ branches/atmospheric_engine/src/lib/sound/sound_source.cc	(revision 8052)
@@ -1,15 +1,15 @@
 /*
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   ### File Specific:
-   main-programmer: Benjamin Grauer
-   co-programmer: ...
+	orxonox - the future of 3D-vertical-scrollers
+
+	Copyright (C) 2004 orx
+
+	This program is free software; you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation; either version 2, or (at your option)
+	any later version.
+
+	### File Specific:
+	main-programmer: Benjamin Grauer
+	co-programmer: ...
 */
 
@@ -24,262 +24,341 @@
 namespace OrxSound
 {
-  /**
-   * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
-   */
-  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
-  {
-    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
-
-    // adding the Source to the SourcesList of the SoundEngine
-    this->buffer = buffer;
-    this->sourceNode = sourceNode;
-    this->resident = false;
-
-    this->sourceID = 0;
-    this->bPlay = false;
-  }
-
-
-  /**
-   * @brief construct a SoundSource out of the another soundSource
-   * @param source the Source to create this source from.
-   *
-   * Copies the buffer from source to this Source.
-   * Acquires a new SourceID if source is Playing.
-   */
-  SoundSource::SoundSource(const SoundSource& source)
-  {
-    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
-
-    // adding the Source to the SourcesList of the SoundEngine
-    this->buffer = source.buffer;
-    this->sourceNode = source.sourceNode;
-    this->resident = source.resident;
-
-    this->sourceID = 0;
-    if (source.bPlay == true)
-    {
-      this->bPlay = true;
-      SoundEngine::getInstance()->popALSource(this->sourceID);
-    }
-    else
-      this->bPlay = false;
-  }
-
-
-  /**
-   * @brief paste a copy of the source into this Source.
-   * @param source the SoundSource to paste into this one.
-   * @returns a Reference to this Source.
-   *
-   */
-  SoundSource& SoundSource::operator=(const SoundSource& source)
-  {
-    this->buffer = source.buffer;
-    this->sourceNode = sourceNode;
-    this->resident = source.resident;
-
-    if (source.bPlay)
-      this->play();
-    else
-      this->stop();
-  }
-
-
-  /**
-   * @brief compares two Sources with each other.
-   * @param source the Source to compare against this One.
-   * Two Sources are the same, if the PNodes match, and the Sound Played are the same.
-   * The alSource must not match, because no two Sources can have the same alSource.
-   */
-  bool SoundSource::operator==(const SoundSource& source)
-  {
-    return (this->buffer == source.buffer &&
-            this->bPlay == source.bPlay &&
-            this->sourceNode == source.sourceNode);
-  }
-
-
-  /**
-   * @brief deletes a SoundSource
-   */
-  SoundSource::~SoundSource()
-  {
-    this->stop();
-    if (this->sourceID != 0)
-      SoundEngine::getInstance()->pushALSource(this->sourceID);
-  }
-
-
-  /**
-   * @brief Plays back a SoundSource
-   */
-  void SoundSource::play()
-  {
-    if (this->buffer && this->retrieveSource())
-    {
-      if (this->bPlay)
-        alSourceStop(this->sourceID);
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
-    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE  );
-    alSourcePlay(this->sourceID);
-
-      if (DEBUG_LEVEL >= 3)
-        SoundEngine::checkError("Play Source", __LINE__);
-      this->bPlay = true;
-    }
-  }
-
-
-  /**
-   * @brief Plays back buffer on this Source
-   * @param buffer the buffer to play back on this Source
-   */
-  void SoundSource::play(const SoundBuffer* buffer)
-  {
-    if (!this->retrieveSource())
-    {
-      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
-      return;
-    }
-
-  alSourceStop(this->sourceID);
-  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
-  alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE  );
-  alSourcePlay(this->sourceID);
-
-    if (unlikely(this->buffer != NULL))
-      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
-    this->bPlay = true;
-
-    if (DEBUG_LEVEL >= 3)
-      SoundEngine::checkError("Play Source", __LINE__);
-  }
-
+	/**
+	* @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
+	*/
+	SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
+	{
+		this->setClassID(CL_SOUND_SOURCE, "SoundSource");
+
+		// adding the Source to the SourcesList of the SoundEngine
+		this->buffer = buffer;
+		this->sourceNode = sourceNode;
+		this->resident = false;
+
+		this->sourceID = 0;
+		this->bPlay = false;
+	}
+
+
+	/**
+	* @brief construct a SoundSource out of the another soundSource
+	* @param source the Source to create this source from.
+	*
+	* Copies the buffer from source to this Source.
+	* Acquires a new SourceID if source is Playing.
+	*/
+	SoundSource::SoundSource(const SoundSource& source)
+	{
+		this->setClassID(CL_SOUND_SOURCE, "SoundSource");
+
+		// adding the Source to the SourcesList of the SoundEngine
+		this->buffer = source.buffer;
+		this->sourceNode = source.sourceNode;
+		this->resident = source.resident;
+
+		this->sourceID = 0;
+		if (source.bPlay == true)
+		{
+			this->bPlay = true;
+			SoundEngine::getInstance()->popALSource(this->sourceID);
+		}
+		else
+			this->bPlay = false;
+	}
+
+
+	/**
+	* @brief paste a copy of the source into this Source.
+	* @param source the SoundSource to paste into this one.
+	* @returns a Reference to this Source.
+	*
+	*/
+	SoundSource& SoundSource::operator=(const SoundSource& source)
+	{
+		this->buffer = source.buffer;
+		this->sourceNode = sourceNode;
+		this->resident = source.resident;
+
+		if (source.bPlay)
+			this->play();
+		else
+			this->stop();
+	}
+
+
+	/**
+	* @brief compares two Sources with each other.
+	* @param source the Source to compare against this One.
+	* Two Sources are the same, if the PNodes match, and the Sound Played are the same.
+	* The alSource must not match, because no two Sources can have the same alSource.
+	*/
+	bool SoundSource::operator==(const SoundSource& source)
+	{
+		return (this->buffer == source.buffer &&
+						this->bPlay == source.bPlay &&
+						this->sourceNode == source.sourceNode);
+	}
+
+
+	/**
+	* @brief deletes a SoundSource
+	*/
+	SoundSource::~SoundSource()
+	{
+		this->stop();
+		if (this->sourceID != 0)
+			SoundEngine::getInstance()->pushALSource(this->sourceID);
+	}
+
+
+	/**
+	* @brief Plays back a SoundSource
+	*/
+	void SoundSource::play()
+	{
+		if (this->buffer && this->retrieveSource())
+		{
+			if (this->bPlay)
+				alSourceStop(this->sourceID);
+			
+			alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+			alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+			alSourcef (this->sourceID, AL_GAIN, 1);
+			alSourcePlay(this->sourceID);
+
+			if (DEBUG_LEVEL >= 3)
+				SoundEngine::checkError("Play Source", __LINE__);
+			this->bPlay = true;
+		}
+	}
+
+
+	/**
+	* @brief Plays back buffer on this Source
+	* @param buffer the buffer to play back on this Source
+	*/
+	void SoundSource::play(const SoundBuffer* buffer)
+	{
+		if (!this->retrieveSource())
+		{
+			PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+			return;
+		}
+
+		alSourceStop(this->sourceID);
+		alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+		alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+		alSourcef (this->sourceID, AL_GAIN, 1);
+
+		alSourcePlay(this->sourceID);
+
+		if (unlikely(this->buffer != NULL))
+			alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+		this->bPlay = true;
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Play Source", __LINE__);
+	}
+
+
+	/**
+	* @brief Plays back buffer on this Source with gain
+	* @param buffer the buffer to play back on this Source
+	*/
+	void SoundSource::play(const SoundBuffer* buffer, float gain)
+	{
+		if (!this->retrieveSource())
+		{
+			PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+			return;
+		}
+
+		alSourceStop(this->sourceID);
+		alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+		alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+		alSourcef (this->sourceID, AL_GAIN, gain);
+
+		alSourcePlay(this->sourceID);
+
+		if (unlikely(this->buffer != NULL))
+			alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+		this->bPlay = true;
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Play Source", __LINE__);
+	}
+
+
+	/**
+	* @brief Plays and loops back a SoundSource
+	*/
+	void SoundSource::loop()
+	{
+		if (this->buffer && this->retrieveSource())
+		{
+			if (this->bPlay)
+				alSourceStop(this->sourceID);
+			
+			alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+			alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
+			alSourcef (this->sourceID, AL_GAIN, 1);
+			alSourcePlay(this->sourceID);
+
+			if (DEBUG_LEVEL >= 3)
+				SoundEngine::checkError("Play Source", __LINE__);
+			this->bPlay = true;
+		}
+	}
 
 /**
- * @brief Plays and loops buffer on this Source
- * @param buffer the buffer to play back on this Source
- */
+* @brief Plays and loops buffer on this Source
+* @param buffer the buffer to play back on this Source
+*/
 void SoundSource::loop(const SoundBuffer* buffer)
 {
-  if (this->buffer && this->retrieveSource())
-  {
-    if (this->bPlay)
-      alSourceStop(this->sourceID);
-
-    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
-    alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE  );
-    alSourcePlay(this->sourceID);
-
-    if (DEBUG_LEVEL >= 3)
-      SoundEngine::checkError("Play LoopSource", __LINE__);
-    this->bPlay = true;
-  }
+	if (this->buffer && this->retrieveSource())
+	{
+		if (this->bPlay)
+			alSourceStop(this->sourceID);
+
+		alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+		alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
+		alSourcef (this->sourceID, AL_GAIN, 1);
+
+		alSourcePlay(this->sourceID);
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Play LoopSource", __LINE__);
+		this->bPlay = true;
+	}
 }
 
 
 /**
- * @brief Stops playback of a SoundSource
- */
+* @brief Plays and loops buffer on this Source with gain control
+* @param buffer the buffer to play back on this Source
+*/
+void SoundSource::loop(const SoundBuffer* buffer, float gain)
+{
+	if (this->buffer && this->retrieveSource())
+	{
+		if (this->bPlay)
+			alSourceStop(this->sourceID);
+
+		alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
+		alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
+		alSourcef (this->sourceID, AL_GAIN, gain);
+
+		alSourcePlay(this->sourceID);
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Play LoopSource", __LINE__);
+		this->bPlay = true;
+	}
+}
+
+
+/**
+* @brief Stops playback of a SoundSource
+*/
 void SoundSource::stop()
 {
-  this->bPlay = false;
-  if (this->sourceID != 0)
-  {
-    this->bPlay = false;
-    if (this->sourceID != 0)
-    {
-      alSourceStop(this->sourceID);
-      if (DEBUG_LEVEL >= 3)
-        SoundEngine::checkError("StopSource", __LINE__);
-      alSourcei(this->sourceID, AL_BUFFER, 0);
-      if (!this->resident)
-        SoundEngine::getInstance()->pushALSource(this->sourceID);
-      this->sourceID = 0;
-    }
-  }
+	this->bPlay = false;
+	if (this->sourceID != 0)
+	{
+		this->bPlay = false;
+		if (this->sourceID != 0)
+		{
+			alSourceStop(this->sourceID);
+			if (DEBUG_LEVEL >= 3)
+				SoundEngine::checkError("StopSource", __LINE__);
+			alSourcei(this->sourceID, AL_BUFFER, 0);
+			if (!this->resident)
+				SoundEngine::getInstance()->pushALSource(this->sourceID);
+			this->sourceID = 0;
+		}
+	}
 }
 
-  /**
-   * @brief Pauses Playback of a SoundSource
-   */
-  void SoundSource::pause()
-  {
-    alSourcePause(this->sourceID);
-    if (DEBUG_LEVEL >= 3)
-      SoundEngine::checkError("Pause Source", __LINE__);
-  }
-
-
-  /**
-   * @brief Rewinds Playback of a SoundSource
-   */
-  void SoundSource::rewind()
-  {
-    alSourceRewind(this->sourceID);
-
-    if (DEBUG_LEVEL >= 3)
-      SoundEngine::checkError("Rewind Source", __LINE__);
-  }
-
-
-  /**
-   * @brief sets the RolloffFactor of the Sound emitted from the SoundSource
-   * @param rolloffFactor The Factor described
-   *
-   * this tells openAL how fast the Sounds decay outward from the Source
-   */
-  void SoundSource::setRolloffFactor(ALfloat rolloffFactor)
-  {
-    alSourcef(this->sourceID, AL_ROLLOFF_FACTOR, rolloffFactor);
-
-    if (DEBUG_LEVEL >= 3)
-      SoundEngine::checkError("Set Source Rolloff-factor", __LINE__);
-  }
-
-
-  /**
-   * @brief sets the Positional this Source should be attached to.
-   * @param sourceNode the Source this is attached to.
-   * If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels.
-   */
-  void SoundSource::setSourceNode(const PNode* sourceNode)
-  {
-    this->sourceNode = sourceNode;
-  }
-
-  /**
-   * @brief retrieve a Source.
-   */
-  bool SoundSource::retrieveSource()
-  {
-    if (this->sourceID != 0)
-      return true;
-    else
-    {
-      SoundEngine::getInstance()->popALSource(this->sourceID);
-      if (this->sourceID != 0)
-      {
-        if (unlikely(this->sourceNode == NULL))
-          resetSource(this->sourceID);
-        return true;
-      }
-    }
-    return false;
-  }
-
-
-  /**
-   * @brief reset an alSource to its default Values.
-   */
-  void SoundSource::resetSource(ALuint sourceID)
-  {
-    alSource3f(sourceID, AL_POSITION,        0.0, 0.0, 0.0);
-    alSource3f(sourceID, AL_VELOCITY,        0.0, 0.0, 0.0);
-    alSource3f(sourceID, AL_DIRECTION,       0.0, 0.0, 0.0);
-    alSourcef (sourceID, AL_ROLLOFF_FACTOR,  0.0          );
-    //alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE      );
-    alSourcef (sourceID, AL_GAIN,            SoundEngine::getInstance()->getEffectsVolume());
-  }
+	/**
+	* @brief Pauses Playback of a SoundSource
+	*/
+	void SoundSource::pause()
+	{
+		alSourcePause(this->sourceID);
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Pause Source", __LINE__);
+	}
+
+
+	/**
+	* @brief Rewinds Playback of a SoundSource
+	*/
+	void SoundSource::rewind()
+	{
+		alSourceRewind(this->sourceID);
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Rewind Source", __LINE__);
+	}
+
+
+	/**
+	* @brief sets the RolloffFactor of the Sound emitted from the SoundSource
+	* @param rolloffFactor The Factor described
+	*
+	* this tells openAL how fast the Sounds decay outward from the Source
+	*/
+	void SoundSource::setRolloffFactor(ALfloat rolloffFactor)
+	{
+		alSourcef(this->sourceID, AL_ROLLOFF_FACTOR, rolloffFactor);
+
+		if (DEBUG_LEVEL >= 3)
+			SoundEngine::checkError("Set Source Rolloff-factor", __LINE__);
+	}
+
+
+	/**
+	* @brief sets the Positional this Source should be attached to.
+	* @param sourceNode the Source this is attached to.
+	* If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels.
+	*/
+	void SoundSource::setSourceNode(const PNode* sourceNode)
+	{
+		this->sourceNode = sourceNode;
+	}
+
+	/**
+	* @brief retrieve a Source.
+	*/
+	bool SoundSource::retrieveSource()
+	{
+		if (this->sourceID != 0)
+			return true;
+		else
+		{
+			SoundEngine::getInstance()->popALSource(this->sourceID);
+			if (this->sourceID != 0)
+			{
+				if (unlikely(this->sourceNode == NULL))
+					resetSource(this->sourceID);
+				return true;
+			}
+		}
+		return false;
+	}
+
+
+	/**
+	* @brief reset an alSource to its default Values.
+	*/
+	void SoundSource::resetSource(ALuint sourceID)
+	{
+		alSource3f(sourceID, AL_POSITION,        0.0, 0.0, 0.0);
+		alSource3f(sourceID, AL_VELOCITY,        0.0, 0.0, 0.0);
+		alSource3f(sourceID, AL_DIRECTION,       0.0, 0.0, 0.0);
+		alSourcef (sourceID, AL_ROLLOFF_FACTOR,  0.0          );
+		//alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE      );
+		alSourcef (sourceID, AL_GAIN,            SoundEngine::getInstance()->getEffectsVolume());
+	}
 }
Index: branches/atmospheric_engine/src/lib/sound/sound_source.h
===================================================================
--- branches/atmospheric_engine/src/lib/sound/sound_source.h	(revision 8050)
+++ branches/atmospheric_engine/src/lib/sound/sound_source.h	(revision 8052)
@@ -29,6 +29,8 @@
     void play();
     void play(const SoundBuffer* buffer);
+    void play(const SoundBuffer* buffer, float gain);
     void loop();
     void loop(const SoundBuffer* buffer);
+    void loop(const SoundBuffer* buffer, float gain);
     void stop();
     void pause();
