frustum class / particle generator

I am working on a sim of moving through a field of objects. when an object disappears behind you, another is supposed to appear in front no matter which way the camera has turned. i am using a frustum class that calculates the parameters of the viewable area but i can’t seem to figure out the math after the camera has been turned.

this is the part that generates and displays objects
for ( int i = 0; i < NUM_STARS; i++ )



glTranslatef( g_xyz[i][0], g_xyz[i][1], g_xyz[i][2] );

if (g_color==GL_TRUE)

        glColor3fv( g_colors[i] );


	glColor3f( 255,255,255);

glPointSize(g_pointsize); //sets the pixel size of the stars

glBegin(GL_POINTS);			// render with points

glVertex2i(0,0);			//display a point at current x,y,z



GLfloat lowest, highest, range;

GLfloat xp,yp,zp;


Vec3 star(g_xyz[i][1], g_xyz[i][0],g_xyz[i][2]);

Vec3 pos(xp, yp, zp);

Vec3 dist;


GLfloat rPos=sqrt(xp*xp+yp*yp+zp*zp);


Vec3 a( g_xyz[i][0], g_xyz[i][1], g_xyz[i][2] );

GLfloat tmp;

if (camera.pointInFrustum(a) == CCamera::OUTSIDE) 

//if star is outside of frustum then recalc to somewhere inside ? ...



if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }


	g_xyz[i][0] = -(lowest+int(range*rand()/(RAND_MAX + 1.0))); 

	lowest=camera.fbl.y; highest=camera.ftl.y; 

if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }


	g_xyz[i][1] = -(lowest+int(range*rand()/(RAND_MAX + 1.0))); 


if (lowest> highest){tmp=lowest;lowest=highest;highest=tmp; }


	g_xyz[i][2] = lowest+int(range*rand()/(RAND_MAX + 1.0)); 



the project files are at

this isn’t a coder forum. Please post coding questions down below in the developer section.

(If a point leaves the view frustum it’ll be behind at least 1 frustum plane (signed dist to plane < 0). Simplify things a bit by just testing near/far planes which are just translates along the view direction. Otherwise either project the point for a test against the (unit) cube or transform your frustum into world/view space for a point test against the planes of the view pyramid. Heck simpler still you could just test the point against a sphere or an AABB of max radius centered on the view. Or better still, …)

i have forward and back working pretty much. but it is turning that seems to be the problem. i was attempting a sphere when something went horribly wrong - my math isn’t very good

I will try the developer forum