/****************************************************************************************

	Light.h

	Copyright (c)1990 - 1999 MetaCreations. All rights reserved.

	Author:	Jerome Bignon

	Date:	06/22/99

	Revision History

	when		who			what & why
	=========== ===========	=============================================================

****************************************************************************************/

#ifndef __Light__
#define __Light__  

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include	"BasicCameraLightGel.h"
#include	"APITypes.h"
#include	"MCColorRGBA.h"
#include	"LightDef.h"

// Define the Light CLSID ( see the LightDef.h file to get the R_CLSID_Light value )

extern const MCGUID CLSID_Light;


// Light Data structure                            
struct LightData
{
	int16			fHorApertureAngle;    // Angular Limits of the light source
	int16			fVerApertureAngle;    //
	real32			fIntensity;           // Light source intensity 
	int16			fNbBeamsHorizontally; // Number of Beams Horizontally and Vertically
	int16			fNbBeamsVertically;   //
	TMCColorRGBA	fLightColor;          // Default color
	int16			fBeamAperture;        // Angular Limit of the singular Beam
};

 
// Beams Light Object :
class Light : public TBasicLight
{
	public :  
		Light();
		STANDARD_RELEASE;

		// IExDataExchanger methods :
		virtual void*				MCCOMAPI     GetExtensionDataBuffer	();
		virtual int32				MCCOMAPI	 GetParamsBufferSize	() const	{ return sizeof(fData);}
		virtual MCCOMErr			MCCOMAPI     ExtensionDataChanged();
		virtual int16				MCCOMAPI     GetResID();

		// I3DExLightsource methods
		virtual MCCOMErr 	MCCOMAPI SetTransform			(TTransform3D* transform);
		virtual MCCOMErr	MCCOMAPI GetDirection			(const TVector3 &point,TVector3 &resultDirection,real &resultDistance);
		virtual boolean 	MCCOMAPI GetColor				(const TVector3 &point,const TVector3 &direction,const real distance,TMCColorRGB &result,real &shadowCoef);
		virtual boolean 	MCCOMAPI IsVisibleInPerspective	();
		virtual uint32 		MCCOMAPI GetPrimitiveID			();
		// virtual MCCOMErr 	MCCOMAPI ForEachShadowBuffer	(ForEachShadowBufferCallback proc,void* priv);
		// virtual MCCOMErr	MCCOMAPI GetLightParameter		(int32 keyword, void* parameter) { return MC_S_OK; }
		virtual MCCOMErr	MCCOMAPI GetLightInfo			(boolean& hasLightCone,boolean& hasLightSphere,real& halfAngle,TTransform3D& transform);
		// virtual boolean		MCCOMAPI GetUVfromDirection		(TVector2& uv,const TVector3& direction) const;
		virtual LightTraceElement*	MCCOMAPI GetNewTrace	(int16* 	nb);

		// retrieve a standard description of the light for use in the interactive renderer

	private :
		TTransform3D fTransform;      // Transformation Data (Local to Global and Global to Local)
		LightData    fData;           // Light Data (see definition of LightData structure)
		real		 fHorAng,fVerAng; // real Value of the angle data.
		real         fBeamLimit;      // Limit of the single beam (cosinus)
		real         fBeamAngle;      //  and in degree 
};
                          


#endif
