Пример #1
0
void RenderManager::RenderAll()
//  Iterates through all the items in the render list
//  translates the render context to the object's base position then
//  renders the object.
//  Objects are drawn in order, opaque first then transparent, with transparent objects
//  further away being drawn first
{
	BuildProjectionMatrix();
	PrepareLights();
	viewMatrixMade = false;

	DrawSkyBox();
	DrawTerrain();

	std::vector<int>::iterator vit;
	if (opaqueRenderList.size() > 0) {
		for (vit = opaqueRenderList.begin(); vit != opaqueRenderList.end(); vit++) {
			if (!DrawMesh(*vit)) {
				opaqueRenderList.erase(vit);
			}
		}
	}

	DrawWater();

	std::list<int>::iterator lit;
	if (renderList.size() > 0) {
		for (lit = renderList.begin(); lit != renderList.end(); lit++) {
			if (!DrawMesh(*lit)) {
				renderList.erase(lit);
			}
		}
	}
}
Пример #2
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void )
{
	if ( g_bRenderGlowingObjects )
		return;

	if ( r_fastsky->integer ) {
		return;
	}

	if (skyboxportal && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL))
	{
		return;
	}

	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		qglDepthRange( 0.0, 0.0 );
	} else {
		qglDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky->outerbox[0] && tess.shader->sky->outerbox[0] != tr.defaultImage ) {
		qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );

		qglPushMatrix ();
		GL_State( 0 );
		qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]);

		DrawSkyBox( tess.shader );

		qglPopMatrix();
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	if (tess.numIndexes && tess.numVertexes)
	{
		RB_StageIteratorGeneric();
	}

	// draw the inner skybox


	// back to normal depth range
	qglDepthRange( 0.0, 1.0 );

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}
Пример #3
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void ) {
	if ( r_fastsky->integer ) {
		return;
	}

	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		qglDepthRange( 0.0, 0.0 );
	} else {
		qglDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
		mat4_t oldmodelview;
		
		GL_State( 0 );
		//qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);

		{
			// FIXME: this could be a lot cleaner
			mat4_t trans, product;

			Mat4Copy( glState.modelview, oldmodelview );
			Mat4Translation( backEnd.viewParms.or.origin, trans );
			Mat4Multiply( glState.modelview, trans, product );
			GL_SetModelviewMatrix( product );

		}

		DrawSkyBox( tess.shader );

		GL_SetModelviewMatrix( oldmodelview );
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	RB_StageIteratorGeneric();

	// draw the inner skybox


	// back to normal depth range
	qglDepthRange( 0.0, 1.0 );

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}
Пример #4
0
	void GraphicsEngine::RenderWorld(Engine::World* world)
	{
		//if (!g_IsGridComputeSetup)
		{
			glm::mat4 projMatrix;
			world->GetCamera()->GetPerspectiveMat(projMatrix);
			GridComputePass(projMatrix);

			g_IsGridComputeSetup = true;
		}

		////todo : add visibility system outside and iterate on visible objects only
		//// Skybox
		DrawSkyBox(world);

		GraphicsCore::RenderState::EnableDepthRead();
		//{
		//	//Opaque objects
			GraphicsCore::RenderState::EnableDepthWrite();
		//	{
				GraphicsCore::RenderState::EnableBackFaceCulling();
		//		{
					// New renderer:
					// Step 1: Depth pre-pass.
					DepthPrePass(world);

					// Step 2: Light Culling.
					LightCullingPass(world);

					// Step 2: Render the scene.
					DrawOpaqueObjects(world);
		//		}
				GraphicsCore::RenderState::DisableBackFaceCulling();
		//		//-----------------------------------------------------------------------------
		//		//Opaque objects with holes (if we know the information?)
		//		//draw
		//	}
		//	DrawDebugInfo(scene); // for debug only
			GraphicsCore::RenderState::DisableDepthWrite();


		//	//-----------------------------------------------------------------------------
		//	//Alpha
			//GraphicsCore::RenderState::EnableAlphaBlending();
		//	{
		//		//-----------------------------------------------------------------------------
		//		// draw alpha objects
		//		//-----------------------------------------------------------------------------
		//		LowLevelGraphics::LowLevelAPI::SetAlphaBlendFunc();

		//		DrawAlphaObjects(scene);

		//	}
			//GraphicsCore::RenderState::DisableAlphaBlending();
			//}
		GraphicsCore::RenderState::DisableDepthRead();
	}
Пример #5
0
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
    glPushMatrix(); 
        frameCamera.ApplyCameraTransform(); // Move the camera about

        // Sky Box is manually textured
        glActiveTexture(GL_TEXTURE0);
        glDisable(GL_TEXTURE_2D);
        glActiveTexture(GL_TEXTURE1);

        glEnable(GL_TEXTURE_CUBE_MAP);
        glDisable(GL_TEXTURE_GEN_S);
        glDisable(GL_TEXTURE_GEN_T);
        glDisable(GL_TEXTURE_GEN_R);     
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
        DrawSkyBox();
 

        // Use texgen to apply cube map
        glEnable(GL_TEXTURE_GEN_S);
        glEnable(GL_TEXTURE_GEN_T);
        glEnable(GL_TEXTURE_GEN_R);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);

        glPushMatrix();
            glTranslatef(0.0f, 0.0f, -3.0f);    
 
            glActiveTexture(GL_TEXTURE1);
            glMatrixMode(GL_TEXTURE);
            glPushMatrix();
            
            // Invert camera matrix (rotation only) and apply to 
            // texture coordinates
            M3DMatrix44f m, invert;
            frameCamera.GetCameraOrientation(m);
            m3dInvertMatrix44(invert, m);
            glMultMatrixf(invert);
    
            glColor3f(1.0f, 1.0f, 1.0f);
            gltDrawSphere(0.75f, 41, 41);
 
            glPopMatrix();
            glMatrixMode(GL_MODELVIEW);
        glPopMatrix();

    glPopMatrix();
        
    // Do the buffer Swap
    glutSwapBuffers();
    }
Пример #6
0
/*
 * RB_StageIteratorSky
 *
 * All of the visible sky triangles are in tess
 *
 * Other things could be stuck in here, like birds in the sky, etc
 */
void
RB_StageIteratorSky(void)
{
	if(r_fastsky->integer){
		return;
	}

	/* go through all the polygons and project them onto
	 * the sky box to see which blocks on each side need
	 * to be drawn */
	RB_ClipSkyPolygons(&tess);

	/* r_showsky will let all the sky blocks be drawn in
	 * front of everything to allow developers to see how
	 * much sky is getting sucked in */
	if(r_showsky->integer){
		qglDepthRange(0.0, 0.0);
	}else{
		qglDepthRange(1.0, 1.0);
	}

	/* draw the outer skybox */
	if(tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage){
		qglColor3f(tr.identityLight, tr.identityLight, tr.identityLight);

		qglPushMatrix ();
		GL_State(0);
		qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1],
			backEnd.viewParms.or.origin[2]);

		DrawSkyBox(tess.shader);

		qglPopMatrix();
	}

	/* generate the vertexes for all the clouds, which will be drawn
	 * by the generic shader routine */
	R_BuildCloudData(&tess);

	RB_StageIteratorGeneric();

	/* draw the inner skybox */


	/* back to normal depth range */
	qglDepthRange(0.0, 1.0);

	/* note that sky was drawn so we will draw a sun later */
	backEnd.skyRenderedThisView = qtrue;
}
Пример #7
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void ) {
	if ( r_fastsky->integer ) {
		return;
	}

	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		glDepthRangeX( GFIXED_0, GFIXED_0 );
	} else {
		glDepthRangeX( GFIXED_1, GFIXED_1 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
		glColor4X( tr.identityLight, tr.identityLight, tr.identityLight,GFIXED_1 );
		
		glPushMatrix ();
		GL_State( 0 );
		glTranslateX (REINTERPRET_GFIXED(backEnd.viewParms._or.origin[0]), 
              		  REINTERPRET_GFIXED(backEnd.viewParms._or.origin[1]), 
			          REINTERPRET_GFIXED(backEnd.viewParms._or.origin[2]));

		DrawSkyBox( tess.shader );

		glPopMatrix();
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	RB_StageIteratorGeneric();

	// draw the inner skybox


	// back to normal depth range
	glDepthRangeX( GFIXED_0, GFIXED_1);

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}
Пример #8
0
void Terrain::DrawTerrain(Vector CurrentCamera, const Vector viewFrustrum[])
{
	CameraEye = CurrentCamera;	
	ViewFrustrum[0] = viewFrustrum[0];	
	ViewFrustrum[1] = viewFrustrum[1];
	ViewFrustrum[2] = viewFrustrum[2];
	ViewFrustrum[3] = viewFrustrum[3];
	ROAM(TriangleTree.root);
	DrawSkyBox();
	DrawTriangleTree(TriangleTree.root);
	glEnable(GL_BLEND);	
	DrawWater();
	glDisable(GL_BLEND);		
	glFlush();	
}
Пример #9
0
// All of the visible sky triangles are in tess
//	Other things could be stuck in here, like birds in the sky, etc
void RB_StageIteratorSky( void ) {
    if ( r_fastsky->integer ) {
        return;
    }

    // go through all the polygons and project them onto
    // the sky box to see which blocks on each side need
    // to be drawn
    RB_ClipSkyPolygons( &tess );

    // r_showsky will let all the sky blocks be drawn in
    // front of everything to allow developers to see how
    // much sky is getting sucked in
    if ( r_showsky->integer ) {
        qglDepthRange( 0.0, 0.0 );
    } else {
        qglDepthRange( 1.0, 1.0 );
    }

    // draw the outer skybox
    if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
        qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );

        qglPushMatrix();
        GL_State( 0 );
        qglTranslatef ( backEnd.viewParms.or.origin.x, backEnd.viewParms.or.origin.y, backEnd.viewParms.or.origin.z );

        DrawSkyBox( tess.shader );

        qglPopMatrix();
    }

    // generate the vertexes for all the clouds, which will be drawn
    // by the generic shader routine
    R_BuildCloudData( &tess );

    //QTZFIXME: This causes a load of GL errors when postprocessing is active :S
//	RB_StageIteratorGeneric();

    // draw the inner skybox


    // back to normal depth range
    qglDepthRange( 0.0, 1.0 );

    // note that sky was drawn so we will draw a sun later
    backEnd.skyRenderedThisView = qtrue;
}
Пример #10
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void ) {
	if ( r_fastsky->integer ) {
		return;
	}

	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		GFX_SetDepthRange( 0.0, 0.0 );
	} else {
		GFX_SetDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
        float colorTint[] = {
            tr.identityLight,
            tr.identityLight,
            tr.identityLight
        };

		DrawSkyBox( tess.shader, backEnd.viewParms.or.origin, colorTint );
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	RB_StageIteratorGeneric();

	// draw the inner skybox


	// back to normal depth range
	GFX_SetDepthRange( 0.0, 1.0 );

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}
Пример #11
0
void dxModel::Draw(const dxVec3 &vieworigin_, const dxVec3 &viewforward_,
    const dxVec3 &viewright_, const dxVec3 &viewup_)
{
    if (!loaded)
    {
        return;
    }

    framecount++;

	viewleaf = PointInLeaf(vieworigin_);
    MarkLeaves();

    renderer.SetupFrame(vieworigin_, viewforward_, viewright_, viewup_);

    DrawSkyBox();
    DrawWorld();
    DrawEntitiesOnList();
}
Пример #12
0
void render()
{
	static Timer t;
	if(gScene && !gPauseSimulation)  //start the simulation
	{
		gTouchedTris.clear();
		gScene->simulate(t.elapsed_time());
		//printf("%f\n",t.elapsed_time());
		t.reset();
		gScene->flushStream();
		/*ASYNC: in here we can do computations which depend only on the old
	      state of the scene "actors". Writing to the scene is not allowed.
		  Write calls in here are skipped.
		*/
		gScene->fetchResults(NX_RIGID_BODY_FINISHED,true);
	}
	// Clear buffers
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glColor4f(0.0,1.0,1.0,1.0);
	DrawSkyBox(5000.0f);
	//drawPlane(2000.0);
	 //Render all actors
	int nbActors = gScene->getNbActors();
	NxActor** actors = gScene->getActors();
	while(nbActors--)
	{
		NxActor* actor = *actors++;
		if(!actor->userData) continue;

		// Render actor
		glPushMatrix();
		float glMat[16];
		actor->getGlobalPose().getColumnMajor44(glMat);
		glMultMatrixf(glMat);
		NxVec3 color = static_cast<UserData*>(actor->userData)->color;
		glColor4f(color.x,color.y,color.z,1.0f);
		glutSolidCube((static_cast<UserData*>(actor->userData)->size)*2.0f);
		glPopMatrix();
	}
	RenderTerrain();
}
Пример #13
0
void RB_StageIteratorSky()
{
	if ( r_fastsky->integer ) {
		return;
	}

	GL_Program();

	// project all the polygons onto the sky box
	// to see which blocks on each side need to be drawn
	RB_ClipSkyPolygons( &tess );

	CalcSkyBounds();

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		qglDepthRange( 0.0, 0.0 );
	} else {
		qglDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
		qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );
		qglPushMatrix();
		GL_State( 0 );
		qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
		DrawSkyBox( tess.shader );
		qglPopMatrix();
	}

	// generate the vertexes for all the clouds (if any)
	// which will be drawn by the generic shader routine
	R_BuildCloudData( &tess );
	if (tess.numVertexes)
		ARB_StageIterator();

	// back to normal depth range
	qglDepthRange( 0.0, 1.0 );
}
Пример #14
0
void RenderScene(void)
{
	GLUquadric *orbitQuad = gluNewQuadric();
	gluQuadricDrawStyle(orbitQuad , GLU_LINE );


	GLUquadric *planetQuad = gluNewQuadric();

		GLUquadricObj *pObj;	// Quadric Object
	pObj = gluNewQuadric(); 
	gluQuadricNormals(pObj, GLU_SMOOTH);
	GLfloat horizontalMovement=1;
	GLfloat verticalMovement=0;
	horizontalMovement=cos(xRotationAngle*PI/180);
	verticalMovement=-sin(xRotationAngle*PI/180);

	if (lookDown)
	{
		xRotationAngle+=1;
		if (xRotationAngle>=90)
			xRotationAngle=90;
	}
	if (lookUp)
	{
		xRotationAngle-=1;
		if (xRotationAngle<=-90)
			xRotationAngle=-90;
	}
	if (lookRight)
	{
		yRotationAngle+=1;
		if (yRotationAngle>=360)
			yRotationAngle=0;
	}
	if (lookLeft)
	{
		yRotationAngle-=1;
		if (yRotationAngle<=-360)
			yRotationAngle=0;
	}
	if (walkForward)
	{
		zTranslation+=cos(yRotationAngle*PI/180)*horizontalMovement;
		xTranslation-=sin(yRotationAngle*PI/180)*horizontalMovement;
		yTranslation-=verticalMovement;
	}
	if (walkBackward)
	{
		zTranslation-=cos(yRotationAngle*PI/180)*horizontalMovement;
		xTranslation+=sin(yRotationAngle*PI/180)*horizontalMovement;
		yTranslation+=verticalMovement;
	}
	if (strafeRight)
	{
		zTranslation+=cos((yRotationAngle+90)*PI/180);
		xTranslation-=sin((yRotationAngle+90)*PI/180);
	}
	if (strafeLeft)
	{
		zTranslation-=cos((yRotationAngle+90)*PI/180);
		xTranslation+=sin((yRotationAngle+90)*PI/180);
	}

	if (setback)
	{
		zTranslation=0;
		xTranslation=0;
		yTranslation=0;
	}

	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT |  GL_DEPTH_BUFFER_BIT);

		// Reset Model view matrix stack
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	glRotatef(xRotationAngle,1,0,0);
	glRotatef(zRotationAngle,0,0,1);
	glRotatef(yRotationAngle,0,1,0);
	glDisable(GL_LIGHTING);
	glBindTexture(GL_TEXTURE_2D, textureObjects[CUBE_MAP_TEX]);
			DrawSkyBox();
	glEnable(GL_LIGHTING);
			glTranslatef(xTranslation,yTranslation,zTranslation);



	
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	
	
	
	
	glScalef(10,10,10);
	glDisable(GL_LIGHTING);
	//sun
	glEnable(GL_TEXTURE_2D);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor3f(1,1,0);
	glBindTexture(GL_TEXTURE_2D, textureObjects[SUN]); 
	gltDrawSphere(0.65,100,100);//radius .15
	GLfloat lightPos[] = {0.0f,0.0f,0.0f,1.0f};
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
	glEnable(GL_LIGHTING);
	
	//glRotatef(90,1,0,0);
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[ASTERIODS]);
	//glutWireTorus(2,6,0,4);
	
	gltDrawTorus(6,2,6,2);
	glPopMatrix();
	//glRotatef(-90,1,0,0);
	//Draw Jupiter - orange
	glPushMatrix();
	
	glBindTexture(GL_TEXTURE_2D, textureObjects[JUPITER]); 
		makeplanets(249,100,0,JUPITER_INCLINATION,JUPITER_ORBIT,JUPITER_RADIUS,EARTH_RADIUS,JUPITER_PERIOD, jupiter_speed, jupiter_rotation, JUPITER_TILT, EARTH_DEGREES_PER_FRAME);
		
		
		glPopMatrix();

	//Draw Venus - greenish blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[VENUS]); 
		makeplanets(43,146,164,VENUS_INCLINATION,VENUS_ORBIT,VENUS_RADIUS,EARTH_RADIUS,VENUS_PERIOD, venus_speed, venus_rotation, VENUS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Mercury - graywhite
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[MERCURY]); 
		makeplanets(191,164,142,MERCURY_INCLINATION,MERCURY_ORBIT,MERCURY_RADIUS,EARTH_RADIUS,MERCURY_PERIOD, mercury_speed, mercury_rotation, MERCURY_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Uranus - dark blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[URANUS]); 
		makeplanets(120,112,224,URANUS_INCLINATION,URANUS_ORBIT,URANUS_RADIUS,EARTH_RADIUS,URANUS_PERIOD, uranus_speed, uranus_rotation, URANUS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Neptune -light blue
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[NEPTUNE]); 
		makeplanets(53,45,206,NEPTUNE_INCLINATION,NEPTUNE_ORBIT,NEPTUNE_RADIUS,EARTH_RADIUS,NEPTUNE_PERIOD, neptune_speed, neptune_rotation, NEPTUNE_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Mars - pink
	glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textureObjects[MARS]); 
		makeplanets(255,43,43,MARS_INCLINATION,MARS_ORBIT,MARS_RADIUS,EARTH_RADIUS,MARS_PERIOD, mars_speed, mars_rotation, MARS_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();

	//Draw Saturn - yellow whitegl
	glBindTexture(GL_TEXTURE_2D, textureObjects[SATURN]); 
	glPushMatrix();
		makeplanets(255,255,145,SATURN_INCLINATION,SATURN_ORBIT,SATURN_RADIUS,EARTH_RADIUS,SATURN_PERIOD, saturn_speed, saturn_rotation, SATURN_TILT, EARTH_DEGREES_PER_FRAME);
	glPopMatrix();



	//draw the Earth - BLUE GREEN
	glPushMatrix();
	
	glBindTexture(GL_TEXTURE_2D, textureObjects[EARTH]); 
		makeplanets(43,146,164,EARTH_INCLINATION,EARTH_ORBIT,EARTH_RADIUS,EARTH_RADIUS,EARTH_PERIOD, earth_speed, earth_rotation, EARTH_TILT, EARTH_DEGREES_PER_FRAME);
	glRotatef(-90,1,0,0);
		glBindTexture(GL_TEXTURE_2D, textureObjects[MOON]); 
		makeplanets(191,164,142,MOON_INCLINATION,MOON_ORBIT,MOON_RADIUS,EARTH_RADIUS,MOON_PERIOD, moon_speed, moon_rotation, MOON_TILT, EARTH_DEGREES_PER_FRAME);
	//glBindTexture(GL_TEXTURE_2D, textureObjects[CLOUDS]); 
		//gltDrawSphere(0.8,40,40);
		
	glPopMatrix();

	// Flush drawing commands
	glutSwapBuffers();

	// Set color shading model to flat
	glShadeModel(GL_SMOOTH);


}
Пример #15
0
/*
================
Tess_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void Tess_StageIteratorSky( void )
{
	// log this call
	if ( r_logFile->integer )
	{
		// don't just call LogComment, or we will get
		// a call to va() every frame!
		GLimp_LogComment( va
		                  ( "--- Tess_StageIteratorSky( %s, %i vertices, %i triangles ) ---\n", tess.surfaceShader->name,
		                    tess.numVertexes, tess.numIndexes / 3 ) );
	}

	if ( r_fastsky->integer )
	{
		return;
	}

	// trebor: HACK why does this happen with cg_draw2D 0 ?
	if ( tess.stageIteratorFunc2 == NULL )
	{
		//tess.stageIteratorFunc2 = Tess_StageIteratorGeneric;
		ri.Error( ERR_FATAL, "tess.stageIteratorFunc == NULL" );
	}

	GL_Cull(CT_TWO_SIDED);

	if ( tess.stageIteratorFunc2 == &Tess_StageIteratorDepthFill )
	{
		// go through all the polygons and project them onto
		// the sky box to see which blocks on each side need
		// to be drawn
		Tess_ClipSkyPolygons();

		// generate the vertexes for all the clouds, which will be drawn
		// by the generic shader routine
		BuildCloudData();

		if ( tess.numVertexes || tess.multiDrawPrimitives )
		{
			tess.stageIteratorFunc2();
		}
	}
	else
	{
		if ( tess.stageIteratorFunc2 == &Tess_StageIteratorGBuffer )
		{
			R_BindFBO( tr.geometricRenderFBO );
		}

		// go through all the polygons and project them onto
		// the sky box to see which blocks on each side need
		// to be drawn
		Tess_ClipSkyPolygons();

		// r_showSky will let all the sky blocks be drawn in
		// front of everything to allow developers to see how
		// much sky is getting sucked in

		if ( r_showSky->integer )
		{
			glDepthRange( 0.0, 0.0 );
		}
		else
		{
			glDepthRange( 1.0, 1.0 );
		}

		// draw the outer skybox
		if ( tess.surfaceShader->sky.outerbox && tess.surfaceShader->sky.outerbox != tr.blackCubeImage )
		{
#if 1
			R_BindVBO( tess.vbo );
			R_BindIBO( tess.ibo );

			gl_skyboxShader->BindProgram();

			gl_skyboxShader->SetUniform_ViewOrigin( backEnd.viewParms.orientation.origin );  // in world space

			gl_skyboxShader->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
			gl_skyboxShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] );

			gl_skyboxShader->SetRequiredVertexPointers();

			// bind u_ColorMap
			GL_SelectTexture( 0 );
			GL_Bind( tess.surfaceShader->sky.outerbox );

			DrawSkyBox( tess.surfaceShader );
#endif
		}

		// generate the vertexes for all the clouds, which will be drawn
		// by the generic shader routine
		BuildCloudData();

		if ( tess.numVertexes || tess.multiDrawPrimitives )
		{
			tess.stageIteratorFunc2();
		}

		// Tr3B: TODO draw the inner skybox?

		if ( tess.stageIteratorFunc2 == Tess_StageIteratorGBuffer )
		{
			R_BindNullFBO();
		}

		if ( tess.stageIteratorFunc2 != Tess_StageIteratorDepthFill )
		{
			// back to standard depth range
			glDepthRange( 0.0, 1.0 );

			// note that sky was drawn so we will draw a sun later
			backEnd.skyRenderedThisView = qtrue;
		}
	}
}
Пример #16
0
void render()
{
	static Timer t;
	if(!gMyPhysX.isPaused())
	{
		for (NxU32 i = 0; i < gKinematicActors.size(); i++)
		{
			NxActor* actor = gKinematicActors[i].actor;
			NxVec3 pos = actor->getGlobalPosition();
			pos += gKinematicActors[i].vel * 1.f/60.f;
			actor->moveGlobalPosition(pos);
		}
	}	
	gMyPhysX.simulate(t.elapsed_time());
	t.reset(); 
	// Clear buffers
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glColor4f(0.5,0.9,0.5,1.0);
	DrawSkyBox(SKYEXTENTS);
	drawPlane(SKYEXTENTS);
	// Keep physics & graphics in sync
	for (NxU32 pass = 0; pass < 2; pass++) {
		int nbActors = gMyPhysX.getScene()->getNbActors();
		NxActor** actors = gMyPhysX.getScene()->getActors();
		actors += nbActors;
		while(nbActors--)
		{
			NxActor* actor = *--actors;

			float size;
			bool isTrigger = false;
			bool isKinematic = actor->isDynamic() && actor->readBodyFlag(NX_BF_KINEMATIC);
			NxVec3 color;
			NxF32 alpha = 1;
			if (actor->isDynamic()) {
				if (actor->readBodyFlag(NX_BF_KINEMATIC)) {
					color.set(1,0,0);
				} else {
					color.set(0,1,0);
				}
			} else {
				color.set(0.2f,0.2f,0.2f);
			}

			if (*(int *)(&actor->userData) < 0)
			{
				NxI32 triggerNumber = -(*(NxI32 *)(&actor->userData));
				NxI32 triggerIndex = triggerNumber - 1;
				// This is our trigger
				isTrigger = true;

				size = 10.0f;
				color.z = gNbTouchedBodies[triggerIndex] > 0.5f ? 1.0f:0.0f;
				alpha = 0.5f;
				if (pass == 0)
					continue;
			}
			else
			{
				// This is a normal object
				size = float(*(int *)(&actor->userData));
				if (pass == 1)
					continue;
			}
			float glmat[16];
			glPushMatrix();
			actor->getGlobalPose().getColumnMajor44(glmat);
			glMultMatrixf(glmat);
			glColor4f(color.x, color.y, color.z, 1.0f);
			glutSolidCube(size*2.0f);
			glPopMatrix();

			// Handle shadows
			if( !isTrigger)
			{
				glPushMatrix();

				const static float ShadowMat[]={ 1,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,1 };

				glMultMatrixf(ShadowMat);
				glMultMatrixf(glmat);

				glDisable(GL_LIGHTING);
				glColor4f(0.1f, 0.2f, 0.3f, 1.0f);
				glutSolidCube(size*2.0f);
				glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
				glEnable(GL_LIGHTING);

				glPopMatrix();
			}
		}
	}
}
Пример #17
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void ) {
	int clearBits = 0;

	if ( r_fastsky->integer ) {
		if (r_fastsky->integer == 2  &&  !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) {
			clearBits |= GL_COLOR_BUFFER_BIT;	// FIXME: only if sky shaders have been used
			if (*r_fastSkyColor->string) {
				int v, tr, tg, tb;

				v = r_fastSkyColor->integer;
				tr = (v & 0xff0000) / 0x010000;
				tg = (v & 0x00ff00) / 0x000100;
				tb = (v & 0x0000ff) / 0x000001;

				qglClearColor((float)tr / 255.0, (float)tg / 255.0, (float)tb / 255.0, 1.0);
			} else {
				qglClearColor(0.0f, 0.0f, 0.0f, 1.0f);	// FIXME: get color of sky
			}

			qglClear(clearBits);
		}

		return;
	}

	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		qglDepthRange( 0.0, 0.0 );
	} else {
		qglDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
		qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );

		qglPushMatrix ();
		GL_State( 0 );
		GL_Cull( CT_FRONT_SIDED );
		qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);

		DrawSkyBox( tess.shader );

		qglPopMatrix();
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	if (tess.numVertexes) {
		// yes, sky has cloud stages
		RB_StageIteratorGeneric();
	}

	// draw the inner skybox

	//FIXME not even done

	// back to normal depth range
	qglDepthRange( 0.0, 1.0 );

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}
Пример #18
0
void D3DDrv_DrawSkyBox( const skyboxDrawInfo_t* skybox, const float* eye_origin, const float* colorTint )
{
    DrawSkyBox( &g_DrawState.skyBoxRenderData, skybox, eye_origin, colorTint );
}
Пример #19
0
/*
================
RB_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void RB_StageIteratorSky( void ) {
	if ( r_fastsky->integer ) {
		return;
	}

	// when portal sky exists, only render skybox for the portal sky scene
	if ( skyboxportal && !( backEnd.refdef.rdflags & RDF_SKYBOXPORTAL ) ) {
		return;
	}

	// does the current fog require fastsky?
	if ( backEnd.viewParms.glFog.registered ) {
		if ( !backEnd.viewParms.glFog.drawsky ) {
			return;
		}
	} else if ( glfogNum > FOG_NONE )      {
		if ( !glfogsettings[FOG_CURRENT].drawsky ) {
			return;
		}
	}


	backEnd.refdef.rdflags |= RDF_DRAWINGSKY;


	// go through all the polygons and project them onto
	// the sky box to see which blocks on each side need
	// to be drawn
	RB_ClipSkyPolygons( &tess );

	// r_showsky will let all the sky blocks be drawn in
	// front of everything to allow developers to see how
	// much sky is getting sucked in
	if ( r_showsky->integer ) {
		qglDepthRange( 0.0, 0.0 );
	} else {
		qglDepthRange( 1.0, 1.0 );
	}

	// draw the outer skybox
	if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) {
		qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );

		qglPushMatrix();
		GL_State( 0 );
		qglTranslatef( backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2] );

		DrawSkyBox( tess.shader );

		qglPopMatrix();
	}

	// generate the vertexes for all the clouds, which will be drawn
	// by the generic shader routine
	R_BuildCloudData( &tess );

	RB_StageIteratorGeneric();

	// draw the inner skybox
	// Rafael - drawing inner skybox
	if ( tess.shader->sky.innerbox[0] && tess.shader->sky.innerbox[0] != tr.defaultImage ) {
		qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight );

		qglPushMatrix();
		GL_State( 0 );
		qglTranslatef( backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2] );

		DrawSkyBoxInner( tess.shader );

		qglPopMatrix();
	}
	// Rafael - end

	// back to normal depth range
	qglDepthRange( 0.0, 1.0 );

	backEnd.refdef.rdflags &= ~RDF_DRAWINGSKY;

	// note that sky was drawn so we will draw a sun later
	backEnd.skyRenderedThisView = qtrue;
}