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

		Camera.h

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

		Author:	Jerome Bignon
		Date:	06/21/99

		Revision History

		when		who			what & why
		==========	==========	======================================================
		7/27/99		jdt			Added #include vector4.h, IsProjectionAffine, and private vars
		7/13/99		cph			removed unused member vars
		7/13/99		cph			added GetStandardCameraInfo() based on conical camera

*****************************************************************************************/
#ifndef __CAMERA__
#define __CAMERA__  

#if CP_PRAGMA_ONCE
#pragma once
#endif
 
#include "BasicCameraLightGel.h"
#include "Vector4.h"  // for PreProject3DTo2D()
#include "APITypes.h"
#include "CameraDef.h"
#include "RenderTypes.h"

// Define the Camera CLSID ( see the CameraDef.h file to get the R_CLSID_Camera value )

extern const MCGUID CLSID_Camera;

struct CameraData 
{
	real fZoomCoef;
};

// Conical Camera Object :
class Camera : public TBasicCamera
{
	public :  
		Camera();
		STANDARD_RELEASE;

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

		// I3DExCamera methods
		virtual MCCOMErr MCCOMAPI SetTransform			(const TTransform3D& transform);

		virtual boolean  MCCOMAPI CreateRay				(const TVector2& screenPosition, 
														 TVector3& resultOrigin, 
														 TVector3& resultDirection) const;

		virtual boolean	 MCCOMAPI CreateRay				(const TVector2& screenPosition,
														 const TVector2& screenDerivate,
														 Ray3D &ray) const;

		virtual boolean  MCCOMAPI PreProject3DTo2D		(const TVector3& cameraPosition, TVector4& projectedPosition) const;
		virtual boolean  MCCOMAPI Project3DTo2D			(const TVector3& cameraPosition, TVector3& screenPosition) const;

		virtual uint32	 MCCOMAPI GetPrimitiveID		() const;
		
		virtual	boolean  MCCOMAPI IsProjectionAffine	(void) const;

		virtual void	 MCCOMAPI GetStandardCameraInfo	(TStandardCameraInfo& cameraInfo) const;

		virtual real32	MCCOMAPI GetScalingFactor() const {return 1;}
		virtual void	MCCOMAPI SetScalingFactor(real32 inValue) {}

	private :
		TTransform3D	fTransform; // Transformation Data (Local to Global and Global to Local)
		CameraData		fData;      // Camera Data Zoom and Angle

		real			fCOP; // center of projection

		real			fHalfWidth;
		real			fInvHalfWidth;
	
		TVector3		fCameraOrigin;
		TVector3		fXCameraDirection;
		TVector3		fYCameraDirection;
		TVector3		fZCameraDirection;

};
                          
#endif