/*********************************************************************//**
*	\brief Frustum.
*		Frustum se pouziva k orezavani vykreslovanych polygonu, tak
*	aby jejich pocet byl co nejmensi.
*                                                                        
*
*	\author Michal Jirous
*	\date 19.02.2009
*	\file game_frustum.h
**********************************************************************/    


#ifndef __GAME_FRUSTUM_H__
#define __GAME_FRUSTUM_H__

#include "algebraic.h"
#include <SDL/SDL_opengl.h>

/** @brief Vycet rovin frustum. */
enum FrustumPlanes
{
	FRONT = 0,
	BACK,
	LEFT,
	RIGHT,
	TOP,
	BOTTOM	
};

/** @brief Objekt frustum. */
class Frustum
{
	void update( float w, float h);		/*!< @brief Tento update probiha pouze pri zmene viewportu. */
	float m_fNear, m_fFar;
	float	lastHalfFov,		/*!< @brief Posledni znama hodnota FOV. */
			lastFar;		/*!< @brief Posledni znama hodnota vzdalenost predni roviny. */
	Plane m_Planes[6];		/*!< @brief Vysledne roviny frustum. */
	Plane m_StaticPlanes;	/*!< @brief Left,right,top,bootom planes. */

	GLfloat leftPlaneStatic[4],rightPlaneStatic[4],topPlaneStatic[4],bottomPlaneStatic[4];
public:
	float m_fHalfFov, m_fHalfWFov;
	Frustum();
	
	
	
	void updateFrustumPlanes( const Vector &vecDir, const Point &vecPosition, float near, float far, float fov, float w, float h );
	bool isBoundsInsideFrustum( const BoundingBox &bounds ) const;
};

#endif /*__GAME_FRUSTUM_H__*/

