Frustum creation again

Started by
-1 comments, last by Velochy 21 years, 9 months ago
quite frankly i wasnt sure aobut the other algorithms and i dont use things i cant comprehend.. so i came up with this piece of code:
      
// This is the best lineup for culling, not the logical lineup(so im not completely crazy just yet

#define FU_FAR 0

#define FU_UP 1

#define FU_LEFT 2

#define FU_RIGHT 3

#define FU_DOWN 4

#define FU_NEAR 5

plane::cPlane(point3 Normal, point3 PointOnPlane); 

typedef class cFustrum
{
	plane sides[6];

	void Create(point3 pos, point3 dir, float hzfov, float zNear, float zFar, float aspect) //dir has to be normalized,fov is horizontal fov, aspect is horiz/vert

	{
		float vefov=hzfov/aspect;
		float hfpi=PI/2; //90 degrees - useful for gettign normal straight away

		point3 convert=cPoint3(0,0,1)-dir;

		sides[FU_LEFT]=cPlane(cPoint3(sin(-(hzfov-hfpi)), 0, cos(-(hzfov-hfpi)))-convert,pos);
		sides[FU_RIGHT]=cPlane(cPoint3(-sin(-(hzfov-hfpi)), 0, cos(-(hzfov-hfpi)))-convert,pos);
		sides[FU_UP]=cPlane(cPoint3(0, sin(-(hzfov-hfpi)), cos(-(hzfov-hfpi)))-convert,pos);
		sides[FU_DOWN]=cPlane(cPoint3(0, -sin(-(hzfov-hfpi)), cos(-(hzfov-hfpi)))-convert,pos);

		sides[FU_FAR]=cPlane(dir,zFar);
		sides[FU_NEAR]=cPlane(dir,zNear);
		
		return;
	}

} Frustum;
      
one question - Will it work? [edited by - Velochy on July 23, 2002 8:09:12 AM] [edited by - Velochy on July 24, 2002 10:28:51 AM]

This topic is closed to new replies.

Advertisement