#ifndef __I3DRenderingModule__
#define __I3DRenderingModule__
/****************************************************************************************

		I3DRenderingModule.h

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

		IPropertiesModule definition

		Author:	Emil
		Date:	8/28/98
		

		Revision History

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

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

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "COMTypes.h"
#include "APITypes.h"
#include "MCCountedPtr.h"

class	RenderFilterNeeds;
class	TMCString;
struct	IShRasterLayer;
struct	I3DRenderingCallbacks;
struct	I3DExFinalRenderer;
struct	I3DShCamera;
struct	IShChannel;
struct	I3DRenderHelper;
class	TMCRect;
struct  IMCFile;
template <class T> class TMCCountedPtrArray;

//****** Globally Unique Ids **************************************************
MCDEFINE_GUID(IID_I3DRenderingModule, 0x434054c0, 0x3ec3, 0x11d2, 0x84, 0x8f, 0x0, 0x60, 0x97, 0xb, 0xc5, 0x21);
MCDEFINE_GUID(IID_I3DRenderingCallbacks, 0x434054c1, 0x3ec3, 0x11d2, 0x84, 0x8f, 0x0, 0x60, 0x97, 0xb, 0xc5, 0x21);
MCDEFINE_GUID(IID_I3DBatchQueueModule, 0x305d15a, 0xbd05, 0x4789, 0xb3, 0xd4, 0xd3, 0xa, 0x3, 0x5a, 0x9c, 0x3c);

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

#define kSceneRenderingModuleID 'srnm'

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

/// \addtogroup ExternalInterface
/// \{

/// This is the interface of the rendering module. The is a rendering
/// module attached to each scene document. It controls the rendering
/// properties of the scene.
///
struct I3DRenderingModule : public IMCUnknown
{
	// ****************************************************************************
	//								RenderOneFrame
	// 
	/// \deprecated You should use I3DRenderHelper::RenderArea() instead.
	///
	/// \see GetRenderHelper
	///
	virtual MCCOMErr  MCCOMAPI RenderOneFrame(I3DRenderingCallbacks* callbacks, boolean synch, int32 synchThreadID,
											  uint32 width,uint32 height,RenderFilterNeeds &gbufferNeeds,I3DShCamera *camera=NULL) = 0;

	// ****************************************************************************
	//								GetRenderHelper
	// 
	/// Returns the current renderHelper after initializing it with the current
	/// scene and rendering settings.
	///
	/// This function should not be called when a rendering is in progress!
	/// 
	/// \param renderHelper  A pointer to the renderHelper that is returned.
	/// 
	virtual MCCOMErr  MCCOMAPI GetRenderHelper(I3DRenderHelper **renderHelper)=0;

	// ****************************************************************************
	//								Abort
	// 
	/// Kills any on going rendering.
	/// 
	virtual MCCOMErr  MCCOMAPI Abort()=0;

	// ****************************************************************************
	//								Abort
	// 
	/// Kills any on going rendering and waits for it to finish.
	/// 
	virtual void MCCOMAPI AbortAndWait() = 0;

	// ****************************************************************************
	//								GetRasterLayer
	// 
	/// Returns a pointer to the raster layer containing the rendered data.
	/// A valid pointer will be returned only when called during the rendering. It
	/// is recommended to use I3DRenderHelper::GetRasterLayer() instead.
	/// 
	/// \param rasterLayer  A pointer to the raster Layer.
	/// 
	virtual MCCOMErr  MCCOMAPI GetRasterLayer(IShRasterLayer ** rasterLayer) = 0;
	
	// ****************************************************************************
	//								GetGBuffers
	// 
	/// Returns an array of pointers to the GBuffers. It
	/// is recommended to use I3DRenderHelper::GetGBuffers() instead.
	/// 
	/// \param gBuffers  The array of the GBuffers.
	/// 
	virtual MCCOMErr  MCCOMAPI GetGBuffers(TMCCountedPtrArray<IShChannel> &gBuffers)=0;

	// ****************************************************************************
	//								GetSize
	// 
	/// Returns the size of the rendering. To calculate the size in pixels, use the
	/// following code:
	///
	/// \code
	///
	/// pixelH = width * dpi / 72;
	/// pixelV = height * dpi / 72;
	///
	/// \endcode
	///
	/// \param width   Width of the image.
	/// \param height  Height of the image.
	/// \param dpi     Pixels per inch.
	/// 
	virtual MCCOMErr  MCCOMAPI GetSize(real & width, real & height, real & dpi) = 0;

	// ****************************************************************************
	//								SetSize
	// 
	/// Sets the size of the rendering. To calculate the size in pixels, use the
	/// following code:
	///
	/// \code
	///
	/// pixelH = width * dpi / 72;
	/// pixelV = height * dpi / 72;
	///
	/// \endcode
	/// 
	/// \param width   Width of the image.
	/// \param height  Height of the image.
	/// \param dpi     Pixels per inch.
	/// 
	virtual MCCOMErr  MCCOMAPI SetSize(real width, real height, real dpi) = 0;

	// ****************************************************************************
	//								GetPixelSize
	// 
	/// Returns the size of the rendered image in pixels.
	/// 
	/// \param width   Width of the image in pixels.
	/// \param height  Height of the image in pixels.
	/// 
	virtual MCCOMErr  MCCOMAPI GetPixelSize(uint32 & width, uint32 & height) = 0;
	
	// ****************************************************************************
	//								SetPixelSize
	// 
	/// Sets the size of the rendered image in pixels.
	/// 
	/// \param width   Width of the image in pixels.
	/// \param height  Height of the image in pixels.
	///
	virtual MCCOMErr  MCCOMAPI SetPixelSize(uint32 width, uint32 height) = 0;

	// ****************************************************************************
	//								GetKeepProportions
	// 
	/// Returns true if the "Keep Proportions" checkbox is checked.
	/// 
	/// 
	virtual boolean   MCCOMAPI GetKeepProportions() = 0;
	
	
	// ****************************************************************************
	//								SetKeepProportions
	// 
	/// Sets the state of the "Keep Proportions" checkbox.
	/// 
	/// \param keepProportions  True if the checkbox is checked.
	/// 
	virtual void      MCCOMAPI SetKeepProportions(boolean keepProportions) = 0;

	// ****************************************************************************
	//								GetPixelAspectRatio
	// 
	/// Returns the pixel aspect ration.
	/// 
	virtual real      MCCOMAPI GetPixelAspectRatio() = 0;
	
	// ****************************************************************************
	//								SetPixelAspectRatio
	// 
	/// Sets the pixel aspect ration.
	/// 
	/// \param pixelAspectRatio  The pixel aspect ratio.
	/// 
	virtual void      MCCOMAPI SetPixelAspectRatio(real pixelAspectRatio) = 0;

	// ****************************************************************************
	//								GetRenderingCamera
	// 
	/// Returns the rendering camera.
	/// 
	/// \param camera  A pointer to the rendering camera.
	/// 
	virtual void      MCCOMAPI GetRenderingCamera(I3DShCamera** camera) = 0;
	
	// ****************************************************************************
	//								SetRenderingCamera
	// 
	/// Sets the rendering camera.
	/// 
	/// \param camera  A pointer to the rendering camera.
	/// 
	virtual void      MCCOMAPI SetRenderingCamera(I3DShCamera* camera) = 0;

	// ****************************************************************************
	//								GetRenderingCameraByName
	// 
	/// Returns the name of the rendering camera.
	/// 
	/// \param cameraName  The name of the rendering camera.
	/// 
	virtual void      MCCOMAPI GetRenderingCameraByName(TMCString & cameraName) = 0;
	
	// ****************************************************************************
	//								SetRenderingCameraByName
	// 
	/// Sets the rendering camera.
	/// 
	/// \param cameraName  The name of the rendering camera.
	/// 
	virtual void      MCCOMAPI SetRenderingCameraByName(const TMCString & cameraName) = 0;

	// ****************************************************************************
	//								GetFieldRendering
	// 
	/// Returns the Field Rendering Settings.
	/// 
	virtual int32     MCCOMAPI GetFieldRendering() = 0;
	
	// ****************************************************************************
	//								SetFieldRendering
	// 
	/// Sets the Field Rendering Settings.
	/// 
	/// \param fieldRendering  0 means no field rendering, 1 means odd dominance, 2 means even dominance.
	/// 
	virtual void      MCCOMAPI SetFieldRendering(int32 fieldRendering) = 0;
	
	// ****************************************************************************
	//								GetUseSMP
	// 
	/// Returns true if the rendering should use preemptive threads.
	/// 
	/// 
	virtual boolean   MCCOMAPI GetUseSMP() = 0;
	
	// ****************************************************************************
	//								SetUseSMP
	// 
	/// Sets whether the rendering should use preemptive threads.
	/// 
	/// \param useSMP  True if the rendering should use preemptive threads.
	/// 
	virtual void      MCCOMAPI SetUseSMP(boolean useSMP) = 0;

	// ****************************************************************************
	//								GetRenderer
	// 
	/// Returns a pointer to the current final renderer.
	/// 
	/// \param renderer  A pointer to the current final renderer.
	/// 
	virtual void	  MCCOMAPI GetRenderer(I3DExFinalRenderer**renderer) = 0;
	
	// ****************************************************************************
	//								SetRenderer
	// 
	/// Sets the current final renderer.
	/// 
	/// \param renderer  A pointer to the new final renderer
	/// 
	virtual MCCOMErr  MCCOMAPI SetRenderer(I3DExFinalRenderer* renderer) = 0;

	
	// ****************************************************************************
	//								GetOutputOption
	// 
	/// Returns the output status: 
	///  - 1 save in default location.
	///  - 2 save as specified by SetOutputFileName.
	/// 
	virtual int32	  MCCOMAPI GetOutputOption() = 0;
	
	// ****************************************************************************
	//								SetOutputOption
	// 
	/// Sets the output status.
	///  
	/// \param option  The output status:
	///					- 1 save in default location.
	///					- 2 save as specified by SetOutputFileName.
	///
	virtual MCCOMErr  MCCOMAPI SetOutputOption(int32 option) = 0;

	// ****************************************************************************
	//								GetOutputFileName
	// 
	/// Returns The pathname of the output image file.
	/// 
	/// \param fileName  The pathname of the output image file.
	/// 
	virtual void	  MCCOMAPI GetOutputFileName(TMCString & fileName) = 0;
	
	// ****************************************************************************
	//								SetOutputFileName
	// 
	/// Sets the pathname of the output image file.
	/// 
	/// \param fileName  The pathname of the output image file.
	/// 
	virtual MCCOMErr  MCCOMAPI SetOutputFileName(const TMCString & fileName) = 0;

	// ****************************************************************************
	//								GetImageFileTypeID
	// 
	/// Returns the file format of the rendered image.
	/// 
	virtual IDType	  MCCOMAPI GetImageFileTypeID() = 0;
	
	// ****************************************************************************
	//								SetImageFileTypeID
	// 
	/// Sets the file format of the rendered image.
	/// 
	/// \param fileTypeID  The file format of the rendered image.
	/// 
	virtual MCCOMErr  MCCOMAPI SetImageFileTypeID(IDType fileTypeID) = 0;

	// ****************************************************************************
	//								GetRenderMovie
	// 
	/// Returns true if the render should render a movie (by opposition to the current frame).
	/// 
	virtual boolean   MCCOMAPI GetRenderMovie() = 0;
	
	// ****************************************************************************
	//								SetRenderMovie
	// 
	/// Specifies whether the render should render a movie (by opposition to the current frame).
	/// 
	/// \param renderMovie  True if a movie should be rendered.
	/// 
	virtual void      MCCOMAPI SetRenderMovie(boolean renderMovie) = 0;
	
	// ****************************************************************************
	//								GetMovieFileTypeID
	// 
	/// Returns the file format of the movie that is rendered.
	/// 
	virtual IDType	  MCCOMAPI GetMovieFileTypeID() = 0;
	
	
	// ****************************************************************************
	//								SetMovieFileTypeID
	// 
	/// Sets the file format of the movie that is rendered.
	/// 
	/// \param fileTypeID  The file format of the movie that is rendered.
	/// 
	virtual MCCOMErr  MCCOMAPI SetMovieFileTypeID(IDType fileTypeID) = 0;

	// ****************************************************************************
	//								GetBeginTime
	// 
	/// Returns the time of the beginning of the rendering of a movie.
	/// 
	virtual MicroTick MCCOMAPI GetBeginTime() = 0;
	
	// ****************************************************************************
	//								SetBeginTime
	// 
	/// Sets the time of the beginning of the rendering of a movie.
	/// 
	/// \param beginTime  The time of the beginning of the rendering of a movie.
	/// 
	virtual void      MCCOMAPI SetBeginTime(MicroTick beginTime) = 0;

	// ****************************************************************************
	//								GetEndTime
	// 
	/// Returns the time of the end of the rendering of a movie.
	/// 
	/// 
	virtual MicroTick MCCOMAPI GetEndTime() = 0;
	
	// ****************************************************************************
	//								SetEndTime
	// 
	/// Sets the time of the end of the rendering of a movie.
	/// 
	/// \param endTime  The time of the end of the rendering of a movie.
	/// 
	virtual void      MCCOMAPI SetEndTime(MicroTick endTime) = 0;

	// ****************************************************************************
	//								GetFramesPerSecond
	// 
	/// Returns the frame rate.
	/// 
	virtual real32    MCCOMAPI GetFramesPerSecond() = 0;
	
	// ****************************************************************************
	//								SetFramesPerSecond
	// 
	/// Sets the frame rate.
	/// 
	/// \param fps  the frame rate.
	/// 
	virtual void      MCCOMAPI SetFramesPerSecond(real32 fps) = 0;

	// ****************************************************************************
	//								GetAutoSwitchToMovie
	// 
	/// Returns true if the application automatically switch to movie when the
	/// time is changed.
	/// 
	virtual boolean   MCCOMAPI GetAutoSwitchToMovie() = 0;

	// ****************************************************************************
	//								SetAutoSwitchToMovie
	// 
	/// Sets whether the application automatically switch to movie when the
	/// time is changed.
	/// 
	virtual void	  MCCOMAPI SetAutoSwitchToMovie(boolean autoSwitch) = 0;

	// ****************************************************************************
	//								IsRendering
	// 
	/// Returns true if a rendering is in progress
	/// 
	virtual boolean	  MCCOMAPI IsRendering() = 0;

	// ****************************************************************************
	//								GetAlphaSettings
	// 
	/// Returns the current settings for alpha channel rendering.
	/// 
	/// \param useAlphaChannel        true if the alpha channel should be filled
	/// \param usePremultipliedAlpha  true if the pre multiplied should be used
	/// 
	virtual void	  MCCOMAPI GetAlphaSettings(boolean& useAlphaChannel,boolean& usePremultipliedAlpha) = 0;
	
	// ****************************************************************************
	//								SetAlphaSettings
	// 
	/// Specifies the current settings for alpha channel rendering.
	/// 
	/// \param useAlphaChannel        true if the alpha channel should be filled
	/// \param usePremultipliedAlpha  true if the pre-multiplied should be used
	/// 
	virtual void	  MCCOMAPI SetAlphaSettings(boolean useAlphaChannel,boolean usePremultipliedAlpha) = 0;
};

/// \}

/// \addtogroup ExternalInterface
/// \{

// ****************************************************************************
//								I3DRenderingCallbacks
// 
/// This interface is used in connection with I3DRenderHelper. You can derive
/// your own class from this interface and pass it to I3DRenderHelper::RenderArea
/// to get callbacks. To make it easier you can derive from TCountedRenderingCallbacks
/// that provides a default implementation for most of the methods.
///
/// <P>Returning an error within these calls will abort the rendering.</P>
///
struct I3DRenderingCallbacks : public IMCUnknown
{

	// ****************************************************************************
	//								UpdateProgress
	// 
	/// Called each time the rendering progress bar should be updated.
	/// 
	/// \param progress     Between 0 and progressMax.
	/// \param progressMax  The value of the progres when the rendering is finished.
	/// 
	virtual MCCOMErr MCCOMAPI UpdateProgress(real progress, real progressMax) = 0;
	
	// ****************************************************************************
	//								RectCompleted
	// 
	/// Called each time a tile is completely rendered.
	/// 
	/// \param rect  The rectangle of the tile in the image in pixels.
	/// 
	virtual MCCOMErr MCCOMAPI RectCompleted(const TMCRect & rect) = 0;
	
	// ****************************************************************************
	//								BeginAnimation
	// 
	/// Called at the begining of the rendering of an animation.
	/// 
	virtual MCCOMErr MCCOMAPI BeginAnimation() = 0;
	
	// ****************************************************************************
	//								EndAnimation
	// 
	/// Called at the end of the rendering of an animation.
	/// 
	virtual MCCOMErr MCCOMAPI EndAnimation() = 0;
	
	// ****************************************************************************
	//								BeginFrame
	// 
	/// Called at the beginning of the rendering of one frame.
	/// 
	/// \param frameNumber  The number of the frame.
	/// 
	virtual MCCOMErr MCCOMAPI BeginFrame(uint32 frameNumber) = 0;
	
	// ****************************************************************************
	//								EndFrame
	// 
	/// Called at the end of the rendering of one frame.
	/// 
	/// \param frameNumber  The number of the frame.
	/// 
	virtual MCCOMErr MCCOMAPI EndFrame(uint32 frameNumber) = 0;
	
	// ****************************************************************************
	//								BeginRendering
	// 
	/// Called at the beginning of the rendering.
	/// 
	virtual MCCOMErr MCCOMAPI BeginRendering() = 0;
	
	// ****************************************************************************
	//								EndRendering
	// 
	/// Called at the emd of the rendering.
	/// 
	virtual MCCOMErr MCCOMAPI EndRendering() = 0;

	// ****************************************************************************
	//								SetRenderHelper
	// 
	/// Sets the renderHelper used for the current rendering
	/// 
	virtual void MCCOMAPI SetRenderHelper(I3DRenderHelper* renderHelper) = 0 ;
};

/// \}

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

/// \addtogroup ExternalInterface
/// \{

//******************************************************************
//					I3DBatchQueueModule
//
/// The interface for the batch queue module.
///
struct I3DBatchQueueModule : public IMCUnknown
{	
	virtual void MCCOMAPI OpenBatchQueueFile(IMCFile* file, boolean quitAppWhenDone) = 0;
};

/// \}

#endif
