#ifndef __I3DEXENVIRONMENT__
#define __I3DEXENVIRONMENT__
/****************************************************************************************

		I3DExEnvironment.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		I3DExAtmosphericShader definition                                         
		I3DExBackgroundShader definition                                          
		I3DExBackdrop definition     
		I3DExAmbientLight definition     

		Author:	Ray Dream
		Date:	3/2/98

		Revision History

		when		who					what & why
		==========	================	======================================================
		08/25/99	cph					Added family ids
		08/11/99	Guillaume&Christy	Added inheritance to all the Basic* classes
		07/06/99	Pierre-E			modification of the identifier in the methods SegmentFilter
										and DirectionFilter: filterOut --> inOutFilter

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

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "IExtension.h"
#include "ShaderTypes.h"
#include "InterfaceIDs.h"
#include "I3dExRenderFeature.h"

//****** Globally Unique Ids *************************************************

MCDEFINE_GUID2(IID_I3DExAtmosphericShader, R_IID_I3DExAtmosphericShader);
MCDEFINE_GUID2(IID_I3DExBackground, R_IID_I3DExBackground);
MCDEFINE_GUID2(IID_I3DExBackdrop, R_IID_I3DExBackdrop);
MCDEFINE_GUID2(IID_I3DExAmbientLight, R_IID_I3DExAmbientLight);


//****** Family Id *************************************************

const FourCharT kAmbientLightFamilyID		= kRID_AmbientLightFamilyID;
const FourCharT kAtmosphericShaderFamilyID	= kRID_AtmosphericShaderFamilyID;
const FourCharT kBackdropFamilyID			= kRID_BackdropFamilyID;
const FourCharT kBackgroundFamilyID			= kRID_BackgroundFamilyID;


/// \addtogroup ExternalInterface
/// \{

/*****************************************************************************\
*  I3DExAtmosphericShader                                                     *
*                                                                             *
*  Atmospheric Shader                                                         *
*                                                                             *
\*****************************************************************************/

/// The atmospheric shader is used to create effects such as fog, clouds, sky...
/// It filters the light beams and can modify them at will.
///
///
/// <P>There are two interfaces to access a component: The shell interface (ISh. or I3DSh.) and
/// the external interface (IEx. or I3DEx.) . You can get one from the other using QueryInterface.</P>
///
/// <P>Whenever it is possible you should use the Shell interface to access the component
/// because the Shell will make sure that the parameter map of the external component is valid.
/// This is especially important if the component is animated. For more information on components
/// see the Overview of the SDK.</P>
///
struct I3DExAtmosphericShader: public IMCUnknown
{
	/// Calculates the effect of the atmosphere on a finite line segment on a ray.
	///
	/// \param ray              The ray that should be filtered
	/// \param tmin             The beginning of the segment on the ray
	/// \param tmax	            The end of the segmenet on the ray
	///
	/// \param inOutFilter		On input this is the color of the light coming from end in the direction
	///							of beg. On output it should contained the color of the light seen through beg
	///							once the light has been filtered by the atmosphere.
	///
	/// \param raytracer		Pointer to the raytracer
	///
	/// \param indirectLight	True if the ray is used to calculate indirect lighting.
	///
	/// \param isShadowRay   	True if the ray is used to calculate shadows (object -> light source)
	///
	/// \param isSunLightShadowCasting	True if the ray is used to calculate shadows from the sun light
	///
	virtual MCCOMErr MCCOMAPI SegmentTraceRay	(const Ray3D&			ray,
												 const real64&			tmin,
												 const real64&			tmax,
												 TMCColorRGBA&			inOutFilter,
												 TColorRGBLinearEffect*	outLinearEffect,
												 TColorRGBLinearEffect*	outVolumeLinearEffect,
												 I3DExRaytracer*		raytracer,
												 boolean				isShadowRay,
												 boolean				indirectLight,
												 boolean				isSunLightShadowCasting,
												 boolean				oldShadowFiltering) = 0;

	/// Calculates the effect of the atmosphere on an infinite ray.
	///
	/// \param ray				The ray in Global Coordinates
	/// \param inOutFilter		On input it contains the color of the Background. On output it contains the
	///							color of the light filtered through the atmosphere.
	/// \param raytracer		Pointer to the raytracer
	/// \param indirectLight	True if the ray is used to calculate indirect lighting.
	///
	virtual MCCOMErr MCCOMAPI DirectionTraceRay	(const Ray3D&			ray,
												 TMCColorRGBA&			inOutFilter,
												 TColorRGBLinearEffect*	outLinearEffect,
												 TColorRGBLinearEffect*	outVolumeLinearEffect,
												 I3DExRaytracer*		raytracer,
												 boolean				indirectLight) = 0;

	/// Called before the scene is rendered
	/// 
	virtual MCCOMErr MCCOMAPI PrepareRender			() = 0;

	/// Called after the scene is rendered
	/// 
	virtual MCCOMErr MCCOMAPI EndRender				() = 0;

	// ****************************************************************************
	//								GetLightInfo
	// 
	///  Return info about the sun or the moon light
	/// 
	/// \param info  The info about the light position, color...
	/// \param lightType Looking for the sun or for the moon.
	/// 
	virtual void		MCCOMAPI GetLightInfo(TAtmosphericLightInfo& info,EAtmosphericLightType lightType) = 0;

	// ****************************************************************************
	//								SetLightInfo
	/// 
	/// \param info  The info about the sun or moon light position, color...
	/// \param lightType kMoonLight or kSunLight
	/// 
	virtual void		MCCOMAPI SetLightInfo(TAtmosphericLightInfo& info,EAtmosphericLightType lightType) = 0;

};

/*****************************************************************************\
*  I3DExBackground                                                            *
*                                                                             *
*  Background                                                                 *
*                                                                             *
\*****************************************************************************/

/// Backgrounds are 3D environments that can be reflected on the 3D objects surfaces
/// (like a sky). The background is also used for refractive objects. The background
/// can be considered as texture mapped on an infinite sphere.
///
/// <P>There are two interfaces to access a component: The shell interface (ISh. or I3DSh.) and
/// the external interface (IEx. or I3DEx.) . You can get one from the other using QueryInterface.</P>
///
/// <P>Whenever it is possible you should use the Shell interface to access the component
/// because the Shell will make sure that the parameter map of the external component is valid.
/// This is especially important if the component is animated. For more information on components
/// see the Overview of the SDK.</P>
///
struct I3DExBackground: public IMCUnknown
{
	/// Returns the color of the background in a particular direction.
	///
	/// \param resultColor The color in the given direction.
	/// \param fullAreaDone Not used.
	/// \param direction A unit vector defining the direction on the unit sphere
	///
	virtual MCCOMErr MCCOMAPI GetBackgroundColor	(TMCColorRGB& resultColor,boolean& fullAreaDone,const TVector3& direction) = 0;
};

/*****************************************************************************\
*  I3DExBackdrop                                                              *
*                                                                             *
*  Backdrop Shader                                                            *
*                                                                             *
\*****************************************************************************/

/// Backdrops are image at infinity (behind every objects) in the axis of the camera.
/// Remember that backdrops are like composing the rendered image with another background image.
/// Backdrops are not reflected on reflective objects. Use backgrounds for this.
///	You need to use the screenMinMax coordinates because the uv coordinates that
/// are given to you might be outside the production frame
/// (for example when the marquee rendering tools are used in the interactive preview).
///
/// <P>There are two interfaces to access a component: The shell interface (ISh. or I3DSh.) and
/// the external interface (IEx. or I3DEx.) . You can get one from the other using QueryInterface.</P>
///
/// <P>Whenever it is possible you should use the Shell interface to access the component
/// because the Shell will make sure that the parameter map of the external component is valid.
/// This is especially important if the component is animated. For more information on components
/// see the Overview of the SDK.</P>
///
struct I3DExBackdrop: public IMCUnknown
{
	/// Returns the color of the backdrop at a particular location of the screen.
	///
	/// \param color The color that is returned.
	/// \param fullAreaDone For future use.
	/// \param screenMinMax The coordinates of the production frame in screen coordinates
	/// \param uv The coordinates of the point on the screen
	///
	virtual MCCOMErr MCCOMAPI GetBackdropColor		(TMCColorRGB& color,boolean& fullAreaDone,const TBBox2D& screenMinMax,const TVector2& uv) = 0;
};

/*****************************************************************************\
*  I3DExAmbientLight                                                          *
*                                                                             *
*  Ambient Light                                                              *
*                                                                             *
\*****************************************************************************/

/// This is the interface for ambient light plugins. An ambient light is a light
/// that shines in every direction and this does not cast any shadows.
///
/// <P>There are two interfaces to access a component: The shell interface (ISh. or I3DSh.) and
/// the external interface (IEx. or I3DEx.) . You can get one from the other using QueryInterface.</P>
///
/// <P>Whenever it is possible you should use the Shell interface to access the component
/// because the Shell will make sure that the parameter map of the external component is valid.
/// This is especially important if the component is animated. For more information on components
/// see the Overview of the SDK.</P>
///
struct I3DExAmbientLight: public IMCUnknown
{
	/// Returns the color of the ambient light.
	///
	/// \param resultColor A pointer to the color returned.
	///
	virtual MCCOMErr MCCOMAPI GetColor				(TMCColorRGB* resultColor) = 0;
};

/// \}

#endif
