Example #1
0
void CCCameraBase::update()
{
#if defined PROFILEON
    CCProfiler profile( "CCCameraBase::update()" );
#endif
    
    if( updatedPosition )
    {
        updatedPosition = false;
    }
    
    if( updateFOV )
    {
        updateFOV = false;
        scanFOVBounds();
    }
    
	CCMatrixLoadIdentity( modelViewMatrix );
    if( frameBufferID == -1 )
    {
        CCMatrixRotate( modelViewMatrix, CCAppManager::GetOrientation().current, 0.0f, 0.0f, 1.0f );
    }
    GluLookAt( modelViewMatrix,
			   rotatedPosition.x, rotatedPosition.y, rotatedPosition.z,	// Position
			   lookAt.x, lookAt.y, lookAt.z,                            // Looking At
			   0.0f, 1.0f, 0.0f );										// Up
	
    GLSetPushMatrix( modelViewMatrix );
	
    ExtractFrustum();
	
    updateVisibleObjects();
}
void CCCameraBase::update()
{
#if defined PROFILEON
    CCProfiler profile( "CCCameraBase::update()" );
#endif
    
    if( updatedPosition )
    {
        updatedPosition = false;
    }
    
    if( updateFOV )
    {
        updateFOV = false;
        scanFOVBounds();
    }
    
	CCMatrixLoadIdentity( modelViewMatrix );
    CCMatrixRotate( modelViewMatrix, gEngine->renderer->orientation.current, 0.0f, 0.0f, 1.0f );
    GluLookAt( modelViewMatrix,
			   rotatedPosition.x, rotatedPosition.y, rotatedPosition.z,	// Position
			   lookAt.x, lookAt.y, lookAt.z,                            // Looking At
			   0.0f, 1.0f, 0.0f );										// Up
	
    GLSetPushMatrix( modelViewMatrix );
	
    ExtractFrustum();
	
    updateVisibleObjects();
}
Example #3
0
void content()
{
	extern bool SphereInFrustum (float,float,float,float);

	glClear (GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

	// extract frustum parameter of current camera
	extern void ExtractFrustum();
	ExtractFrustum();

	int nshow = 0;
	for (int i = 0; i < NSPHERES; i++) {
		if (! cull || SphereInFrustum (pos[i][0], pos[i][1],pos[i][2], radius[i])) {
			++nshow;
			glPushMatrix();
				glTranslatef (pos[i][0], pos[i][1], pos[i][2]);
				glutSolidSphere (radius[i], 120,120); 
			glPopMatrix();
		}
	}


	BEGIN_2D_OVERLAY (10,10);
	glDisable(GL_LIGHTING);
	glColor3f (1,1,0);
	if (cull) 	
		drawstr (1,1, "cull [%d|%d]", NSPHERES-nshow, NSPHERES);
	else
		drawstr (1,1, "no cull");
	END_2D_OVERLAY();

	content_count++;
	glutSwapBuffers();
}
void TextureMain::draw2DCalibrationFull() {
    ExtractFrustum();
    GLuint queries[textureModel->TotalFaces];
    GLuint sampleCount;
    glGenQueriesARB(textureModel->TotalFaces, queries);
    glDisable(GL_BLEND);
    glDepthFunc(GL_LESS);
    glDepthMask(GL_TRUE);
    for (int i = 0; i < textureModel->TotalFaces; i++) {
        int index = i * 3;
        if (PointInFrustum(textureModel->Faces_Triangles[index * 3], textureModel->Faces_Triangles[index * 3 + 1], textureModel->Faces_Triangles[index * 3 + 2])) {
            glBeginQueryARB(GL_SAMPLES_PASSED_ARB, queries[i]);
            draw2DElement(i);
            glEndQueryARB(GL_SAMPLES_PASSED_ARB);
        }
    }
    glEnable(GL_BLEND);
    glDepthFunc(GL_EQUAL);
    glDepthMask(GL_FALSE);

    for (int i = 0; i < textureModel->TotalFaces; i++) {
        int index = i * 3;
        if (PointInFrustum(textureModel->Faces_Triangles[index * 3], textureModel->Faces_Triangles[index * 3 + 1], textureModel->Faces_Triangles[index * 3 + 2])) {
            glGetQueryObjectuivARB(queries[i], GL_QUERY_RESULT_ARB, &sampleCount);
            if (sampleCount > 0) {
                if (textureIndex > 0) {
                    faces[textureIndex][i] = sampleCount;
                }
                draw2DElement(i);
            }
        }
    }
    glDisable(GL_BLEND);
    glDepthFunc(GL_LESS);
    glDepthMask(GL_TRUE);
}
Example #5
0
void Frustum::Create()
{
    ExtractFrustum();
}