📄 glfrustum.h
字号:
// Frustum.h: Interface of the class CFrustum.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FRUSTRUM_H__CA0D0C57_056C_44F8_8AFD_AFDE66FD2451__INCLUDED_)
#define AFX_FRUSTRUM_H__CA0D0C57_056C_44F8_8AFD_AFDE66FD2451__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
///////////////////////////////////////////////////////////
// For more informations on frustum culling visit //
// http://www.markmorley.com/opengl/frustumculling.html //
// This class is based on the this tutorial and its code //
///////////////////////////////////////////////////////////
#include <windows.h>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <gl/gl.h>
#include <gl/glu.h>
//#include "vector.h"
// Return values of the various location functions
#define FULL_OUTSIDE 0
#define PARTIAL_INSIDE 1
#define FULL_INSIDE 2
typedef float vec3[3]; /* x, y, z */
typedef struct BBOX
{
vec3 min;
vec3 max;
vec3 min_apex;
vec3 min_left;
vec3 min_center;
vec3 min_right;
vec3 max_apex;
vec3 max_left;
vec3 max_center;
vec3 max_right;
} BBOX;
class CFrustum
{
public:
bool TriangleInFrustum(float A[3], float B[3], float C[3]);
bool LineInFrustum(float A[3], float B[3]);
bool CubeInFrustum(float fPoint[3], float fSize);
bool SphereInFrustum(float fPoint[3], float fRadius);
bool PointInFrustum( float x, float y, float z );
bool PolygonInFrustum(BBOX *bbox);
bool Polygon2(vec3 point1, vec3 point2, vec3 point3);
void UpdateFrustum();
int CubeLocation(float fPoint[], float fSize);
int SphereLocation(float fPoint[3], float fRadius);
bool RightParallelepipedInFrustum(float fMin[3], float fMax[3]);
int cull_frustum( BBOX *bbox );
bool CubeFrustumD3D( float x, float y, float z, float size );
void CalculateFrustum(vec3 CameraPos, vec3 Cdir,
float Aspect, float Fov, float zNear, float zFar);
CFrustum();
virtual ~CFrustum();
// The six frustum planes
float frustum[6][4];
};
#endif // !defined(AFX_FRUSTRUM_H__CA0D0C57_056C_44F8_8AFD_AFDE66FD2451__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -