/**
* 3D Hud Class
* @version 12-26-03
* @author Joseph 'Pcjoe' Florencio
*/

#ifndef TDHUD
#define TDHUD

class C3DHud
{
public:
	/*
	* Constructor
	* @param model_s *pModel: Model
	* @param vec3_t vecMaxs: Upper left corner on screen
	* @param vec3_t vecMins: Lower right corner on screen
	*/
	C3DHud( model_s *pModel, vec3_t vecMaxs, vec3_t vecMins );
	C3DHud( char *pModel, vec3_t vecMaxs, vec3_t vecMins );
	C3DHud() { }

	/*
	* Set Animation
	* @param char *pAnim: Sequence we're setting
	*/
	void SetAnimation( char *pAnim );

	/*
	* Advance Frame
	*/
	void AdvanceFrame( void );

	/*
	* Stop Animation
	*/
	void StopAnimation( void );

	/*
	* Resize 2D (Also used to reset origin
	* @param vec3_t vecMaxs: New maxs we're resizing to
	* @param vec3_t vecMins: New mins we're resizing to
	* @param float flTime: How fast we're resizing to the new size
	*/
	void Resize2D( vec3_t vecMaxs, vec3_t vecMins, float flTime );

	/*
	* Set Entity/Player Model
	* @param model_s *pModel: Model
	* @param char *pModel: Model
	*/
	void SetPlayerModel( char *pModel );
	void SetModel( char *pModel );
	void SetModel( model_s *pModel );

	/*
	* Get Model
	*/
	model_s *GetModel( void ) { return m_pModel; }

	/*
	* Set/Fade Renderamt
	* @param float flRenderamt: New render amount
	* @param float flTime: How fast we're fading
	*/
	void SetrenderAmt( float flRenderamt, float flTime );

	/*
	* Show model
	*/
	void Show( void ) { m_blRender = true; }

	/*
	* Hide model ( dont render )
	*/
	void Hide( void ) { m_blRender = false; }

	/*
	* Can Render
	* @return bool: If we can render
	*/
	bool CanRender( void ) { return m_blRender; }

	/*
	* Get 2d maxs/mins (includes transition)
	*/
	void GetMaxsMins( vec3_t &vecMaxs, vec3_t &vecMins );

	/*
	* Get Render Amt
	*/
	float GetRenderAmt( void );

	/*
	* Handle Transition
	*/
	float HandleTrans( float &flStart, float &flEnd, bool &blDone );

	/*
	* Get 2d/3d Height/Width
	*/
	float Get2DHeight( void ) { return (m_vec2DMaxs.y - m_vec2DMins.y); }
	float Get2DWidth( void ) { return (m_vec2DMaxs.x - m_vec2DMins.x); }
	float Get3DHeight( void ) { return (m_vec3DMaxs.z - m_vec3DMins.z); };
	float Get3DWidth( void ) { return (m_vec3DMaxs.x - m_vec3DMins.x); };

	/*
	* Convert 2d to workable
	*/
	void Convert2D( float &x, float &y );

	/*
	* Setup Entity Before Render
	*/
	void SetupEntBeforeRender( void );

	/*
	* After Render Check
	*/
	void AfterRenderCheck( void );

	/*
	* Remove Entity
	*/
	C3DHud *Remove( void );

	/*
	* Get next link in linked list
	*/
	C3DHud *GetNext( void ) { return m_pNext; }

	TEMPENTITY *m_pTempEntity;
private:
	model_s	*m_pModel;		// Model
	vec3_t	m_vec2DMaxs;	// Upper Left corner on screen
	vec3_t	m_vec2DMins;	// Lower Right corner on screen
	vec3_t	m_vec3DMaxs;	// Maxs of model
	vec3_t	m_vec3DMins;	// Mins of model

	bool	m_blRendered;		// Have we rendered the temp entity for this frame?
	bool	m_blRender;			// If we should render this temp ent or "hide" it
	bool	m_blFirstPass;		// Rendered atleast once
	bool	m_blAnimating;		// If the model is set to animate
	int		m_iSequence;		// Sequence we're animating on
	float	m_flFrame;			// Frame we're on in the animation
	float	m_flRenderAmt;		// Transparency of model (255 = solid)
	
	C3DHud *m_pNext;

	// Transition varibles
	vec3_t	m_vecTrans2DMaxs;	// Maxs
	vec3_t	m_vecTrans2DMins;	// Mins
	float	m_flTrans2DBBoxT;	// Trans time for bbox
	float	m_flTrans2DBBoxTS;	// Start time for trans of bbox
	float	m_flTransRAmtT;		// Trans time for render amt
	float	m_flTransRAmtTS;	// Start time for trans of render amt
	float	m_flTransRAmt;		// Trans value for render amt
};

#endif