/*
	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 LIGHT_H
#define LIGHT_H

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

#include <cmath>

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   Light
// Purpose:      Simple class that describes a light.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class Light
{
    //--------------------------------------------------------------------------
    // LightScene manages all lights. Needs private access.
    //--------------------------------------------------------------------------

    friend class LightScene;

 public:

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

        Light();    // Default constructor:

        // Setting of light attributes:

        void reset();       // resets light attributes to their defaults

        void setColor       // sets the light's color
        (
            float r,
            float g,
            float b
        );

        void setPosition    // sets the light's position: ignored for directional lights
        (
            float x,
            float y,
            float z
        );

        void setDirection   // sets the light's direction: ignored for positonal lights
        (
            float x,
            float y,
            float z
        );

        void setStrenght    ( float strenght    );   // Set the how strong the light is: bigger values mean light will affect objects further away
        void setDirectional ( bool  directional );   // Set whether the light is a directional light: default is false meaing light is positional

        // Attribute retrieval

        void getPosition  ( float * position );    // get the xyz position of the light and store to array given
        void getColor     ( float * color    );    // get the rgb position of the light and store to array given

        inline float getStrenght()    { return strenght;    }   // get the strenght of the light
        inline bool  isDirectional()  { return pos[3] == 0; }   // tell whether the light is a directional or positonal light

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

 protected:

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

        float pos[4];       // light position: x,y,z and w. w is zero for directional lights and 1 for positional lights.
        float col[4];       // light color: r,g,b,a
        float strenght;     // strenght of light source

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

 private:

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

        LightScene * scene;  // LightScene the light belongs to

}; // end of: class Light{}

#endif // end of: ifndef LIGHT_H
