/*
	Rogue Trader.
	Copyright (c) 2007, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef BACKROUNDSCENE_H
#define BACKROUNDSCENE_H

//##############################################################################
// C Includes
//##############################################################################

#include <Windows.h>
#include <gl/gl.h>
#include "MathLibrary.h"

//##############################################################################
// Forward references
//##############################################################################

class GLWindow;
class GLTexture;
class GLTextureManager;
class Camera;

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   BackgroundScene
// Purpose:      Class that represents a background scene. Randomnly generates
//               a space background and dust particles that inhabit the scene.
//               Handles drawing and creation of all these things. This class
//               is one of the base classes that contribute to the GameScene
//               class.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class BackgroundScene
{

 public:

        //----------------------------------------------------------------------
        // Functions
        //----------------------------------------------------------------------

        // BackgroundScene constructor: takes sun color, planet light color and planet texture

        BackgroundScene( float * starColor , float * planetLightColor , const GLTexture * planetTexture );

        // BackgroundScene destructor: frees all resources used

        ~BackgroundScene();

        void drawBackground ( Camera * camera );    // Draw the space background from a camera's perspective
        void drawDust       ( Camera * camera );    // Draw 3D space dust from the cameras perspective
        void drawLensFlare  ( Camera * camera );    // Draw the sun's lens flare

        // Get the star and planet light colors (RGB components) and save to given arrays

        void getStarColor           ( float * color );
        void getPlanetLightColor    ( float * color );

        // Get the sun light and planet light direction (XYZ components ) and save to the given arrays

        void getStarLightDir    ( float * direction );
        void getPlanetLightDir  ( float * direction );

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 protected:

        //----------------------------------------------------------------------
        // Constants
        //----------------------------------------------------------------------

        // Settings for the billboarded sprites that represent the planet and the star

        static const float  PLANET_SIZE;        // size of the planet sprite
        static const float  PLANET_POS_X;       // planet sprite position: x
        static const float  PLANET_POS_Y;       // planet sprite position: y
        static const float  PLANET_POS_Z;       // planet sprite position: z

        static const float  STAR_SIZE;           // size of the star sprite
        static const float  STAR_POS_X;          // star sprite position: x
        static const float  STAR_POS_Y;          // star sprite position: y
        static const float  STAR_POS_Z;          // star sprite position: z

        // Settings for the light directions of the light given off by the planet and the star

        static const float  PLANET_LIGHT_DIR_X;
        static const float  PLANET_LIGHT_DIR_Y;
        static const float  PLANET_LIGHT_DIR_Z;

        static const float  STAR_LIGHT_DIR_X;
        static const float  STAR_LIGHT_DIR_Y;
        static const float  STAR_LIGHT_DIR_Z;

        // Dust particle settings:

        static const float    DUST_BOX_SIZE;        // size of the 'box' the dust particles are contained in
        static const unsigned NUM_DUST_PARTICLES;   // number of dust particles in the scene

        //----------------------------------------------------------------------
        // Variables
        //----------------------------------------------------------------------

        // color of the sun

        float starColor[3];

        // color of the planet light:

        float planetLightColor[3];

        // Dust particle display list

        GLuint dlistDust;

        // Planet and sun textures

        const GLTexture * texPlanet;    // Texture for the planet
        const GLTexture * texStar;      // Texture for the sun

        // Skybox textures for the space background

        GLTexture * texSkyBoxFr;    // front    face
        GLTexture * texSkyBoxBk;    // back     face
        GLTexture * texSkyBoxLr;    // left     face
        GLTexture * texSkyBoxRt;    // right    face
        GLTexture * texSkyBoxTp;    // top      face
        GLTexture * texSkyBoxBt;    // bottom   face

}; // end of: class BackgroundScene{}

//##############################################################################
// C++ includes
//##############################################################################

#include "GLWindow.h"
#include "GLTexture.h"
#include "GLTextureManager.h"
#include "Camera.h"

#endif // end of: ifndef BACKROUND_H
