Prechádzať zdrojové kódy

Merge 7/29 mcclure create_lua branch with Ivan Polycode

mcc 13 rokov pred
rodič
commit
175c1eeb6b

+ 7 - 1
Core/Contents/Include/PolyCamera.h

@@ -64,9 +64,12 @@ namespace Polycode {
 			*/					
 			bool canSee(SceneEntity *entity);
 			
-			void setOrthoMode(bool mode);
+			void setOrthoMode(bool mode, Number orthoSizeX = 1.0, Number orthoSizeY = 1.0);
 			bool getOrthoMode();
 			
+			Number getOrthoSizeX();
+			Number getOrthoSizeY();
+						
 			/**
 			* Sets the field of view (FOV) for the camera. The larger the field of view, the more the camera can see, the smaller it is, the more zoomed in it is.
 			* @param fov The new FOV value.
@@ -125,6 +128,9 @@ namespace Polycode {
 			
 		protected:
 		
+			Number orthoSizeX;
+			Number orthoSizeY;
+					
 			Number exposureLevel;
 			bool orthoMode;
 			Number fov;

+ 4 - 1
Core/Contents/Include/PolyCoreServices.h

@@ -146,7 +146,9 @@ namespace Polycode {
 			* @see Config
 			*/																													
 			Config *getConfig();
-		
+			
+			bool drawScreensFirst;
+					
 			~CoreServices();
 		
 		protected:
@@ -155,6 +157,7 @@ namespace Polycode {
 					
 		private:
 		
+		
 			static CoreServices* overrideInstance;
 			static std::map <long, CoreServices*> instanceMap;
 			static CoreMutex *renderMutex;

+ 3 - 6
Core/Contents/Include/PolyGLRenderer.h

@@ -126,7 +126,7 @@ namespace Polycode {
 		void drawArrays(int drawType);		
 				
 		void setOrthoMode(Number xSize=0.0f, Number ySize=0.0f);
-		void _setOrthoMode();
+		void _setOrthoMode(Number orthoSizeX, Number orthoSizeY);
 		void setPerspectiveMode();
 		
 		void enableBackfaceCulling(bool val);
@@ -181,10 +181,7 @@ namespace Polycode {
 		void drawScreenQuad(Number qx, Number qy);
 				
 		void pushMatrix();
-		void popMatrix();
-		
-		bool test2DCoordinate(Number x, Number y, Polycode::Polygon *poly, const Matrix4 &matrix, bool billboardMode);
-		
+		void popMatrix();		
 		
 		Vector3 Unproject(Number x, Number y);
 		
@@ -202,7 +199,7 @@ namespace Polycode {
 		int verticesToDraw;
 		
 		GLdouble sceneProjectionMatrix[16];
-	
+		GLdouble sceneProjectionMatrixOrtho[16];	
 		
 	};
 }

+ 2 - 0
Core/Contents/Include/PolyImage.h

@@ -237,6 +237,8 @@ namespace Polycode {
 			* @return Pointer to raw image data.
 			*/						
 			char *getPixels();
+			
+			void premultiplyAlpha();
 		
 			static const int IMAGE_RGB = 0;
 			static const int IMAGE_RGBA = 1;

+ 3 - 1
Core/Contents/Include/PolyLabel.h

@@ -34,7 +34,7 @@ namespace Polycode {
 	class _PolyExport Label : public Image {
 		public:
 			
-			Label(Font *font, const String& text, int size, int antiAliasMode);
+			Label(Font *font, const String& text, int size, int antiAliasMode, bool premultiplyAlpha = false);
 			virtual ~Label();
 			void setText(const String& text);
 			const String& getText() const;
@@ -52,6 +52,8 @@ namespace Polycode {
 			
 		protected:
 
+			bool premultiplyAlpha;
+
 			Number currentTextWidth;
 			Number currentTextHeight;
 			int antiAliasMode;

+ 2 - 0
Core/Contents/Include/PolyMaterialManager.h

@@ -77,6 +77,8 @@ namespace Polycode {
 			Shader *setShaderFromXMLNode(TiXmlNode *node);
 			Shader *createShaderFromXMLNode(TiXmlNode *node);
 		
+			bool premultiplyAlphaOnLoad;
+		
 		private:
 			std::vector<Texture*> textures;
 			std::vector<Material*> materials;

+ 7 - 3
Core/Contents/Include/PolyRenderer.h

@@ -103,7 +103,7 @@ namespace Polycode {
 				
 		virtual void loadIdentity() = 0;		
 		virtual void setOrthoMode(Number xSize=0.0f, Number ySize=0.0f) = 0;
-		virtual void _setOrthoMode() = 0;
+		virtual void _setOrthoMode(Number orthoSizeX, Number orthoSizeY) = 0;
 		virtual void setPerspectiveMode() = 0;
 		
 		virtual void setTexture(Texture *texture) = 0;		
@@ -212,7 +212,7 @@ namespace Polycode {
 		
 		void addShaderModule(PolycodeShaderModule *module);
 		
-		virtual bool test2DCoordinate(Number x, Number y, Polygon *poly, const Matrix4 &matrix, bool billboardMode) = 0;
+		virtual bool test2DCoordinateInPolygon(Number x, Number y, Polygon *poly, const Matrix4 &matrix, bool testBackfacing, bool ortho, bool billboardMode);
 		
 		virtual Matrix4 getProjectionMatrix() = 0;
 		virtual Matrix4 getModelviewMatrix() = 0;
@@ -223,7 +223,8 @@ namespace Polycode {
 		static const int BLEND_MODE_NORMAL = 0;
 		static const int BLEND_MODE_LIGHTEN = 1;
 		static const int BLEND_MODE_COLOR = 2;
-		
+		static const int BLEND_MODE_PREMULTIPLIED = 3;
+				
 		static const int FOG_LINEAR = 0;
 		static const int FOG_EXP = 1;
 		static const int FOG_EXP2 = 2;
@@ -290,6 +291,9 @@ namespace Polycode {
 		bool shadersEnabled;
 		Number fov;
 		
+		Number orthoSizeX;
+		Number orthoSizeY;
+				
 		bool lightingEnabled;
 		
 		bool orthoMode;

+ 1 - 1
Core/Contents/Include/PolySceneLabel.h

@@ -46,7 +46,7 @@ namespace Polycode {
 			* @param scale Scale to multiply pixel size by for the actual world size of the label.
 			* @param Anti-aliasing mode. Can be Label::ANTIALIAS_FULL or Label::ANTIALIAS_NONE.
 			*/			
-			SceneLabel(const String& fontName, const String& text, int size, Number scale, int amode);
+			SceneLabel(const String& fontName, const String& text, int size, Number scale, int amode, bool premultiplyAlpha = false);
 			virtual ~SceneLabel();			
 		
 			/**

+ 3 - 1
Core/Contents/Include/PolySceneSound.h

@@ -44,7 +44,7 @@ namespace Polycode {
 	*/	
 	class _PolyExport SceneSound : public SceneEntity {
 		public:
-			SceneSound(const String& fileName, Number referenceDistance, Number maxDistance);
+			SceneSound(const String& fileName, Number referenceDistance, Number maxDistance, bool directionalSound = false);
 			virtual ~SceneSound();			
 			void Update();
 			
@@ -54,6 +54,8 @@ namespace Polycode {
 			Sound *getSound();
 			
 		protected:
+		
+			bool directionalSound;
 			Sound *sound;
 	};
 	

+ 1 - 1
Core/Contents/Include/PolyScreenLabel.h

@@ -42,7 +42,7 @@ namespace Polycode {
 			* @param size Size in pixels.
 			* @param Anti-aliasing mode.
 			*/
-			ScreenLabel(const String& text, int size, const String& fontName = "sans", int amode = 0);
+			ScreenLabel(const String& text, int size, const String& fontName = "sans", int amode = 0, bool premultiplyAlpha = false);
 			virtual ~ScreenLabel();		
 		
 			/**

+ 1 - 1
Core/Contents/Include/PolySoundManager.h

@@ -38,7 +38,7 @@ namespace Polycode {
 		~SoundManager();
 		
 		void setListenerPosition(Vector3 position);
-		void setListenerOrientation(Vector3 orientation);	
+		void setListenerOrientation(Vector3 orientation, Vector3 upVector);	
 		void initAL();
 		
 		/**

+ 12 - 1
Core/Contents/Source/PolyCamera.cpp

@@ -85,7 +85,9 @@ bool Camera::isSphereInFrustrum(Vector3 pos, Number fRadius) {
     return true;
 }
 
-void Camera::setOrthoMode(bool mode) {
+void Camera::setOrthoMode(bool mode, Number orthoSizeX, Number orthoSizeY) {
+	this->orthoSizeX = orthoSizeX;
+	this->orthoSizeY = orthoSizeY;
 	orthoMode = mode;
 }			
 
@@ -93,6 +95,15 @@ bool Camera::getOrthoMode() {
 	return orthoMode;
 }
 
+Number Camera::getOrthoSizeX() {
+	return orthoSizeX;
+}
+
+Number Camera::getOrthoSizeY() {
+	return orthoSizeY;
+}
+
+
 void Camera::buildFrustrumPlanes() {
 
 	Matrix4 p; 

+ 17 - 6
Core/Contents/Source/PolyCoreServices.cpp

@@ -64,6 +64,7 @@ CoreServices* CoreServices::getInstance() {
 
 //#ifdef _WINDOWS
 		overrideInstance = new CoreServices;
+		overrideInstance->drawScreensFirst = false;
 		Logger::log("Creating new core services instance...\n");
 		return overrideInstance;
 //#else
@@ -211,12 +212,22 @@ void CoreServices::Update(int elapsed) {
 	timerManager->Update();
 	tweenManager->Update();
 	materialManager->Update(elapsed);
-	renderer->setPerspectiveMode();
-	sceneManager->UpdateVirtual();
-	renderer->clearScreen();
-	sceneManager->Update();
-//	renderer->setOrthoMode();
-	screenManager->Update();
+		
+	if(drawScreensFirst) {
+		renderer->clearScreen();	
+		renderer->setPerspectiveMode();
+		sceneManager->UpdateVirtual();
+		renderer->clearScreen();					
+		screenManager->Update();
+		renderer->setPerspectiveMode();
+		sceneManager->Update();	
+	} else {
+		renderer->setPerspectiveMode();
+		sceneManager->UpdateVirtual();
+		renderer->clearScreen();		
+		sceneManager->Update();
+		screenManager->Update();	
+	}	
 }
 
 SoundManager *CoreServices::getSoundManager() {

+ 10 - 41
Core/Contents/Source/PolyGLRenderer.cpp

@@ -265,45 +265,6 @@ Vector3 OpenGLRenderer::projectRayFrom2DCoordinate(Number x, Number y) {
 	return dirVec;
 }
 
-bool OpenGLRenderer::test2DCoordinate(Number x, Number y, Polycode::Polygon *poly, const Matrix4 &matrix, bool billboardMode) {
-	GLdouble nearPlane[3],farPlane[3];
-	
-	GLdouble mv[16];
-	Matrix4 camInverse = cameraMatrix.inverse();	
-	Matrix4 cmv;
-	cmv.identity();
-	cmv = cmv * camInverse;
-	
-	for(int i=0; i < 16; i++) {
-		mv[i] = cmv.ml[i];
-	}
-	
-	GLint vp[4];
-	glGetIntegerv( GL_VIEWPORT, vp );
-	
-	gluUnProject(x, yRes - y, 0.0, mv, sceneProjectionMatrix, vp,  &nearPlane[0], &nearPlane[1], &nearPlane[2]);
-	gluUnProject(x, yRes - y, 1.0, mv, sceneProjectionMatrix, vp,  &farPlane[0], &farPlane[1], &farPlane[2]);
-	
-	Vector3 nearVec(nearPlane[0], nearPlane[1], nearPlane[2]);
-	Vector3 farVec(farPlane[0], farPlane[1], farPlane[2]);
-		
-	Vector3 dirVec = farVec - nearVec;	
-	dirVec.Normalize();
-	
-	Vector3 hitPoint;
-	
-	Matrix4 fullMatrix = matrix;
-	
-	if(poly->getVertexCount() == 3) {
-		return rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(2)), &hitPoint);
-	} else if(poly->getVertexCount() == 4) {
-		return (rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(2)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(0)), &hitPoint) ||
-				rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(3)), fullMatrix *  (*poly->getVertex(2)), &hitPoint));
-	} else {
-		return false;
-	}
-}
-
 void OpenGLRenderer::enableDepthWrite(bool val) {
 	if(val)
 		glDepthMask(GL_TRUE);
@@ -438,6 +399,9 @@ void OpenGLRenderer::setBlendingMode(int blendingMode) {
 		case BLEND_MODE_COLOR:
 				glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
 		break;
+		case BLEND_MODE_PREMULTIPLIED:
+			glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+		break;
 		default:
 			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 		break;
@@ -490,14 +454,19 @@ void OpenGLRenderer::setFogProperties(int fogMode, Color color, Number density,
 }
 
 
-void OpenGLRenderer::_setOrthoMode() {
+void OpenGLRenderer::_setOrthoMode(Number orthoSizeX, Number orthoSizeY) {
+	this->orthoSizeX = orthoSizeX;
+	this->orthoSizeY = orthoSizeY;
+	
 	if(!orthoMode) {
 		glMatrixMode(GL_PROJECTION);
 		glPushMatrix();
 		glLoadIdentity();
-		glOrtho(-1,1,-1,1,nearPlane,farPlane);
+		glOrtho(-orthoSizeX*0.5,orthoSizeX*0.5,-orthoSizeY*0.5,orthoSizeY*0.5,-farPlane,farPlane);
 		orthoMode = true;
 	}
+	glGetDoublev( GL_PROJECTION_MATRIX, sceneProjectionMatrixOrtho);
+		
 	glMatrixMode(GL_MODELVIEW);	
 	glLoadIdentity();	
 }

+ 12 - 1
Core/Contents/Source/PolyImage.cpp

@@ -644,7 +644,18 @@ bool Image::saveImage(const String &fileName) {
 	return savePNG(fileName);
 }
 
-
+void Image::premultiplyAlpha() {
+	for(int x=0; x < width; x++) {
+		for(int y=0; y < height; y++) {
+			unsigned int *imageData32 = (unsigned int*)imageData;	
+			Color col =  Color(imageData32[x+(y*width)]);
+			col.r *= col.a;
+			col.g *= col.a;			
+			col.b *= col.a;						
+			imageData32[x+(y*width)] = col.getUint();
+		}
+	}
+}
 
 bool Image::savePNG(const String &fileName) {
 

+ 17 - 7
Core/Contents/Source/PolyLabel.cpp

@@ -28,10 +28,11 @@ using namespace Polycode;
 #define NORMAL_FT_FLAGS FT_LOAD_TARGET_LIGHT
 
 
-Label::Label(Font *font, const String& text, int size, int antiAliasMode) : Image() {
+Label::Label(Font *font, const String& text, int size, int antiAliasMode, bool premultiplyAlpha) : Image() {
 		setPixelType(Image::IMAGE_RGBA);
 		this->font = font;
 		this->size = size;
+		this->premultiplyAlpha = premultiplyAlpha;
 		imageData = NULL;
 		this->antiAliasMode = antiAliasMode;
 		currentTextWidth = 0;
@@ -186,12 +187,21 @@ void Label::setText(const String& text) {
 					if(!(j%slot->bitmap.width) && j !=0)
 						lineoffset += (textWidth*4)-(slot->bitmap.width * 4);
 
-						imageData[xoff+lineoffset] = 255;
-						imageData[xoff+lineoffset+1] =  255;
-						imageData[xoff+lineoffset+2] =  255;
-						
-						if(imageData[xoff+lineoffset+3] == 0)
-							imageData[xoff+lineoffset+3] =  slot->bitmap.buffer[j];
+						int newVal = imageData[xoff+lineoffset+3] + slot->bitmap.buffer[j];
+						if(newVal > 255)
+							newVal = 255;
+						imageData[xoff+lineoffset+3] = newVal;
+													
+						if(premultiplyAlpha) {
+							imageData[xoff+lineoffset] = (int)(255.0 * ((Number)imageData[xoff+lineoffset+3])/255.0);
+							imageData[xoff+lineoffset+1] =  (int)(255.0 * ((Number)imageData[xoff+lineoffset+3])/255.0);
+							imageData[xoff+lineoffset+2] =  (int)(255.0 * ((Number)imageData[xoff+lineoffset+3])/255.0);
+						} else {
+							imageData[xoff+lineoffset] = 255;
+							imageData[xoff+lineoffset+1] =  255;
+							imageData[xoff+lineoffset+2] =  255;						
+						} 	
+							
 						xoff += 4;
 				}
 			break;

+ 4 - 1
Core/Contents/Source/PolyMaterialManager.cpp

@@ -35,7 +35,7 @@ using namespace Polycode;
 using std::vector;
 
 MaterialManager::MaterialManager() {
-	
+	premultiplyAlphaOnLoad = false;
 }
 
 MaterialManager::~MaterialManager() {
@@ -93,6 +93,9 @@ Texture *MaterialManager::createTextureFromFile(const String& fileName, bool cla
 	
 	Image *image = new Image(fileName);
 	if(image->isLoaded()) {
+		if(premultiplyAlphaOnLoad) {
+			image->premultiplyAlpha();
+		}
 		newTexture = createTexture(image->getWidth(), image->getHeight(), image->getPixels(), clamp, createMipmaps);
 	} else {
 		Logger::log("Error loading image, using default texture.\n");

+ 69 - 0
Core/Contents/Source/PolyRenderer.cpp

@@ -77,8 +77,77 @@ void Renderer::setExposureLevel(Number level) {
 	exposureLevel = level;
 }
 
+
+bool Renderer::test2DCoordinateInPolygon(Number x, Number y, Polycode::Polygon *poly, const Matrix4 &matrix, bool ortho, bool testBackfacing, bool billboardMode) {
+
+	Vector3 dirVec;
+	Vector3 origin;
+	
+	if(ortho) {
+		origin = Vector3(((x/(Number)xRes)*orthoSizeX) - (orthoSizeX*0.5), (((yRes-y)/(Number)yRes)*orthoSizeY) - (orthoSizeY*0.5), 0.0);
+		origin = cameraMatrix * origin;
+
+		dirVec = Vector3(0.0, 0.0, -1.0);
+		dirVec = cameraMatrix.rotateVector(dirVec);	
+	} else {
+		dirVec = projectRayFrom2DCoordinate(x, y);
+		origin = cameraMatrix.getPosition();	
+	}
+	
+	Vector3 hitPoint;
+	
+	Matrix4 fullMatrix = matrix;
+	
+	if(billboardMode) {
+		Matrix4 camInverse = cameraMatrix.inverse();
+		fullMatrix = fullMatrix * camInverse;
+		
+		fullMatrix.m[0][0] = 1;
+		fullMatrix.m[0][1] = 0;
+		fullMatrix.m[0][2] = 0;
+
+		fullMatrix.m[1][0] = 0;
+		fullMatrix.m[1][1] = 1;
+		fullMatrix.m[1][2] = 0;
+
+		fullMatrix.m[2][0] = 0;
+		fullMatrix.m[2][1] = 0;
+		fullMatrix.m[2][2] = 1;		
+		
+		origin = camInverse * origin;
+		dirVec = camInverse.rotateVector(dirVec);
+	}
+	
+	bool retStatus = false;	
+	
+	
+	if(poly->getVertexCount() == 3) {
+		retStatus = rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(2)), &hitPoint);
+		if(testBackfacing && !retStatus) {
+			retStatus = rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(2)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(0)), &hitPoint);
+		
+		}
+	} else if(poly->getVertexCount() == 4) {
+		retStatus = (rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(2)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(0)), &hitPoint) ||
+				rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(3)), fullMatrix *  (*poly->getVertex(2)), &hitPoint));
+		if(testBackfacing && !retStatus) {
+			retStatus = (rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(2)), &hitPoint) ||
+				rayTriangleIntersect(origin, dirVec, fullMatrix * (*poly->getVertex(2)), fullMatrix  * (*poly->getVertex(3)), fullMatrix *  (*poly->getVertex(0)), &hitPoint));
+		
+		}				
+	} else {
+		retStatus = false;
+	}
+	
+	return retStatus;
+}
+
 bool Renderer::rayTriangleIntersect(Vector3 ray_origin, Vector3 ray_direction, Vector3 vert0, Vector3 vert1, Vector3 vert2, Vector3 *hitPoint)
 {
+
+//	printf("TESTING RAY\nORIGIN: %f,%f,%f\nDIR: %f,%f,%f\nVERT0: %f,%f,%f\nnVERT1: %f,%f,%f\nnVERT2: %f,%f,%f\n", ray_origin.x, ray_origin.y, ray_origin.z, ray_direction.x, ray_direction.y, ray_direction.z, vert0.x, vert0.y, vert0.z, vert1.x, vert1.y, vert1.z, vert2.x, vert2.y, vert2.z);	
+
+
 	Number t,u,v;
 	t = 0; u = 0; v = 0;
 	

+ 5 - 5
Core/Contents/Source/PolyScene.cpp

@@ -225,13 +225,13 @@ void Scene::Render(Camera *targetCamera) {
 		}
 		CoreServices::getInstance()->getRenderer()->addLight(light->getLightImportance(), position, direction, light->getLightType(), light->lightColor, light->specularLightColor, light->getConstantAttenuation(), light->getLinearAttenuation(), light->getQuadraticAttenuation(), light->getIntensity(), light->getSpotlightCutoff(), light->getSpotlightExponent(), light->areShadowsEnabled(), matrixPtr, shadowMapTexture);
 	}	
-	
-	targetCamera->doCameraTransform();
-	targetCamera->buildFrustrumPlanes();
-	
+
 	if(targetCamera->getOrthoMode()) {
-		CoreServices::getInstance()->getRenderer()->_setOrthoMode();
+		CoreServices::getInstance()->getRenderer()->_setOrthoMode(targetCamera->getOrthoSizeX(), targetCamera->getOrthoSizeY());
 	}
+		
+	targetCamera->doCameraTransform();
+	targetCamera->buildFrustrumPlanes();
 	
 	CoreServices::getInstance()->getRenderer()->enableFog(fogEnabled);	
 	if(fogEnabled) {

+ 2 - 2
Core/Contents/Source/PolySceneLabel.cpp

@@ -31,8 +31,8 @@
 
 using namespace Polycode;
 
-SceneLabel::SceneLabel(const String& fontName, const String& text, int size, Number scale, int amode) : ScenePrimitive(ScenePrimitive::TYPE_PLANE, 1, 1) {
-	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode);
+SceneLabel::SceneLabel(const String& fontName, const String& text, int size, Number scale, int amode, bool premultiplyAlpha) : ScenePrimitive(ScenePrimitive::TYPE_PLANE, 1, 1) {
+	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	this->scale = scale;
 	setText(text);
 	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;

+ 15 - 14
Core/Contents/Source/PolySceneSound.cpp

@@ -37,18 +37,17 @@ SceneSoundListener::~SceneSoundListener() {
 void SceneSoundListener::Update() {
 	Matrix4 finalMatrix = getConcatenatedMatrix();
 	CoreServices::getInstance()->getSoundManager()->setListenerPosition(finalMatrix.getPosition());
-	
-	Vector3 direction;
-	direction.x = 0;		
-	direction.y = 0;
-	direction.z = -1;
-	direction = finalMatrix.rotateVector(direction);
-	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction);
 
+	Vector3 upVector = Vector3(finalMatrix.ml[4], finalMatrix.ml[5], finalMatrix.ml[6]);
+	Vector3 direction = Vector3( -finalMatrix.ml[8], -finalMatrix.ml[9], -finalMatrix.ml[10]);
+	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction, upVector);
 }
 
 
-SceneSound::SceneSound(const String& fileName, Number referenceDistance, Number maxDistance) : SceneEntity() {
+SceneSound::SceneSound(const String& fileName, Number referenceDistance, Number maxDistance, bool directionalSound) : SceneEntity() {
+
+	this->directionalSound = directionalSound;
+	
 	sound = new Sound(fileName);
 	sound->setIsPositional(true);
 	sound->setPositionalProperties(referenceDistance, maxDistance);
@@ -62,12 +61,14 @@ void SceneSound::Update() {
 	Matrix4 finalMatrix = getConcatenatedMatrix();
 	sound->setSoundPosition(finalMatrix.getPosition());
 	
-	Vector3 direction;
-	direction.x = 0;		
-	direction.y = 0;
-	direction.z = -1;
-	direction = finalMatrix.rotateVector(direction);
-	sound->setSoundDirection(direction);
+	if(directionalSound) {
+		Vector3 direction;
+		direction.x = 0;		
+		direction.y = 0;
+		direction.z = -1;
+		direction = finalMatrix.rotateVector(direction);
+		sound->setSoundDirection(direction);
+	}
 	
 }
 

+ 2 - 2
Core/Contents/Source/PolyScreenLabel.cpp

@@ -32,8 +32,8 @@
 
 using namespace Polycode;
 
-ScreenLabel::ScreenLabel(const String& text, int size, const String& fontName, int amode) : ScreenShape(ScreenShape::SHAPE_RECT,1,1) {
-	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode);
+ScreenLabel::ScreenLabel(const String& text, int size, const String& fontName, int amode, bool premultiplyAlpha) : ScreenShape(ScreenShape::SHAPE_RECT,1,1) {
+	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	dropShadowImage = NULL;
 	texture = NULL;
 	setText(text);		

+ 4 - 2
Core/Contents/Source/PolyScreenSound.cpp

@@ -37,13 +37,15 @@ ScreenSoundListener::~ScreenSoundListener() {
 void ScreenSoundListener::Update() {
 	Matrix4 finalMatrix = getConcatenatedMatrix();
 	CoreServices::getInstance()->getSoundManager()->setListenerPosition(finalMatrix.getPosition());
-	
+
+	Vector3 upVector = Vector3(0.0, 0.0, 1.0);
+		
 	Vector3 direction;
 	direction.x = 0;		
 	direction.y = 0;
 	direction.z = -1;
 	direction = finalMatrix.rotateVector(direction);
-	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction);
+	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction, upVector);
 
 }
 

+ 10 - 2
Core/Contents/Source/PolySoundManager.cpp

@@ -97,8 +97,16 @@ void SoundManager::setListenerPosition(Vector3 position) {
 	alListener3f(AL_POSITION, position.x, position.y, position.z);
 }
 
-void SoundManager::setListenerOrientation(Vector3 orientation) {
-	alListener3f(AL_ORIENTATION, orientation.x, orientation.y, orientation.z);
+void SoundManager::setListenerOrientation(Vector3 orientation, Vector3 upVector) {
+	ALfloat ori[6];
+	ori[0] = orientation.x;
+	ori[1] = orientation.y;
+	ori[2] = orientation.z;
+	
+	ori[3] = upVector.x;
+	ori[4] = upVector.y;
+	ori[5] = upVector.z;	
+	alListenerfv(AL_ORIENTATION,ori);
 }
 
 SoundManager::~SoundManager() {