/*!
	@file RuEntity_DecalShadow.h

	Copyright (c) 2004-2006 All rights reserved
*/

#ifndef _RUENTITY_DECALSHADOW_H_
#define _RUENTITY_DECALSHADOW_H_

#include "../../Scene/Base/RuEntityBase.h"
#include "../../Scene/Base/RuEntityModel.h"

#pragma unmanaged

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

/*!
	Decal entity.

	@version 2006.03.16
*/
class CRuEntity_DecalShadow : public IRuEntity_Renderable, public IRuEntityEventListener
{
	ruRTTI_DECLARE
	ruHEAP_DECLARE
	ruCLASSGUID_DECLARE

protected:
	INT32									m_maximumDecalFaces;						//!< Maximum number of faces to enumerate for the decal
	REAL									m_enumerationPadding;						//!< How much extra distance to pad geometry enumeration

	CRuVector3								m_shadowDirection;							//!< Shadow projection direction, specified in world frame
	REAL									m_shadowZoneSize;							//!< Size by which to extend the shadowed zone
																						//!< Enumeration center is moved out along light vector by this value

	// Runtime
	CRuEntity*								m_caster;									//!< Caster object
	CRuEntity*								m_receiver;									//!< Receiver object
	CRuSphere								m_decalEnumerationBounds;					//!< Bounds of last mesh enumeration, specified in world frame

	// Decal mesh
	CRuDynamicMesh*							m_mesh;										//!< Mesh object
	CRuMaterial*							m_material;									//!< Material object

public:
											CRuEntity_DecalShadow();
	virtual									~CRuEntity_DecalShadow();

	void									SetCaster(CRuEntity *caster);
	void									SetReceiver(CRuEntity *receiver);

	// Base class implementation
	virtual IRuObject*						Clone(IRuObject *clonedObject = NULL);
	virtual BOOL							SerializeFrom(IRuStream *stream);
	virtual BOOL							SerializeTo(IRuStream *stream);

	// Base interface
	virtual BOOL							Update(REAL elapsedTime);

	// IRuEntity_Renderable interface
	virtual INT32							GetNumMeshes() const;
	virtual BOOL							GetMesh(INT32 meshIndex, IRuMesh **meshOut, IRuMaterial **materialOut);

	// IRuEntityEventListener implementation
	virtual BOOL							HandleEvent(CRuEntity *entity, INT32 eventID, INT32 eventParameter0, INT32 eventParameter1, const char *eventString, REAL eventDuration, void *userData);
};

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

ruOBJECTMODULE_DEFINE(CRuObjectModule_Entity_DecalShadow, CRuEntity_DecalShadow)

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

#pragma managed

#endif
