 
#ifndef __CULLING_H__
#define __CULLING_H__
 
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
  
/* For DLL using these function :*/
#include "cpa_expt.h" 
#include "GLD.h"
#include "POS.h"
 
/*
 =======================================================================================
    define
 =======================================================================================
 */
 
#define GEO_C_lCullingOut				0x00
#define GEO_C_lCullingLeft			0x01
#define GEO_C_lCullingRight			0x02
#define GEO_C_lCullingUp				0x04
#define GEO_C_lCullingDown			0x08
#define GEO_C_lCullingNear			0x10
#define GEO_C_lCullingFar				0x20
#define GEO_C_lCullingIntersect	0x40 /*not in nor out, but the exact intersected planes are not known*/
#define GEO_C_lCullingIn				0x7f /*In means inside all planes*/
 
/*
 =======================================================================================
    globals 
 =======================================================================================
 */
 
extern MTH_tdxReal	GEO_g_xZFar;
extern MTH_tdxReal	GEO_g_xZFarTransparencyZone;
extern MTH_tdxReal  GEO_g_xOoZFarTransparencyZone;
extern MTH_tdxReal	GEO_g_xZFarTransparencyLevel;
 
/*
 =======================================================================================
    Functions
 =======================================================================================
 */
 
/*
 * ZFar parameters access functions
 */
extern CPA_EXPORT MTH_tdxReal GEO_xGetZFar( void );
extern CPA_EXPORT void        GEO_vSetZFar( MTH_tdxReal _xZ );
extern CPA_EXPORT MTH_tdxReal GEO_xGetZFarTransparencyZone( void );
extern CPA_EXPORT void        GEO_vSetZFarTransparencyZone( MTH_tdxReal _xZ );
extern CPA_EXPORT MTH_tdxReal GEO_xGetZFarTransparencyLevel( void );
 
 
	
/*
 ***************************************************************************************
  pre compute camera parameters for faster culling
  compute clipping plane normal in global system axis to avoid object transformation 
  from global to camera system axis
 ***************************************************************************************
 */
extern CPA_EXPORT void GEO_fn_vComputeCameraParametersForCulling( GLD_tdstViewportAttributes *p_stVpt, MTH_tdxReal _xZFar );
 
/**********************************************************************************************/
/* Name: GEO_lCullingSphere 1.0*/
/* Goal: Return 1 if the sphere is visible.*/
/**********************************************************************************************/
extern CPA_EXPORT long GEO_lCullingSphere 
(
	GLD_tdstViewportAttributes	*p_stVpt ,
	MTH3D_tdstVector			*p_stSphereCenter , 
	MTH_tdxReal					xRadius,
	POS_tdstCompletePosition	*p_stMatrix,
	long _lCullingresult
);
 
/**********************************************************************************************/
/* Name: GEO_lCullingSphere 1.0*/
/* Goal: Return 1 if the sphere is visible.*/
extern CPA_EXPORT long GEO_lCullingGlobalSphere
(
	GLD_tdstViewportAttributes	*_p_stVpt,
	MTH3D_tdstVector			*_p_stSphereCenter,
 	MTH_tdxReal					_xRadius,
	long _lCullingresult
);
 
  
/**********************************************************************************************/
/* Name: GEO_lCullingBox 1.0*/
/* Goal: Return 1 if aligned box is visible.*/
/**********************************************************************************************/
extern CPA_EXPORT long GEO_lCullingBox
(
	GLD_tdstViewportAttributes	*p_stVpt,
	MTH3D_tdstVector			*p_stMin,
	MTH3D_tdstVector			*p_stMax,
	long _lCullingresult
);
 
/**********************************************************************************************/
/* Name: GEO_lCullingSphereNoMMM*/
/* Goal: Return 1 if the sphere is visible.*/
/**********************************************************************************************/
extern CPA_EXPORT long GEO_lCullingSphereNoMMM 
(
	GLD_tdstViewportAttributes	*p_stVpt ,
	MTH3D_tdstVector			*p_stShereCenter , 
	MTH_tdxReal					xRadius,
	POS_tdstCompletePosition	*p_stMatrix,
	long _lCullingresult
);
  
 
#ifdef __cplusplus
} /*extern "C"*/
#endif
 
#endif /*__CULLING_H__ */
