Ejemplo n.º 1
0
void uiGeoscapeNode::draw (uiNode_t* node)
{
    vec2_t screenPos;

    geoscapeNode = node;
    UI_MAPEXTRADATA(node).flatgeoscape = cl_3dmap->integer == 0;
    UI_MAPEXTRADATA(node).radarOverlay = Cvar_GetValue("geo_overlay_radar");
    UI_MAPEXTRADATA(node).nationOverlay = Cvar_GetValue("geo_overlay_nation");
    UI_MAPEXTRADATA(node).xviOverlay = Cvar_GetValue("geo_overlay_xvi");
    UI_MAPEXTRADATA(node).ambientLightFactor = cl_3dmapAmbient->value;
    UI_MAPEXTRADATA(node).mapzoommin = cl_mapzoommin->value;
    UI_MAPEXTRADATA(node).mapzoommax = cl_mapzoommax->value;

    UI_GetNodeAbsPos(node, UI_MAPEXTRADATA(node).mapPos);
    Vector2Copy(node->box.size, UI_MAPEXTRADATA(node).mapSize);
    if (!UI_MAPEXTRADATACONST(node).flatgeoscape) {
        /* remove the left padding */
        UI_MAPEXTRADATA(node).mapSize[0] -= UI_MAPEXTRADATACONST(node).paddingRight;
    }

    /* Draw geoscape */
    UI_GetNodeScreenPos(node, screenPos);
    UI_PushClipRect(screenPos[0], screenPos[1], node->box.size[0], node->box.size[1]);

    if (UI_MAPEXTRADATACONST(node).smoothRotation) {
        if (UI_MAPEXTRADATACONST(node).flatgeoscape)
            smoothTranslate(node);
        else
            smoothRotate(node);
    }

    geoscapeData_t& data = *UI_MAPEXTRADATA(node).geoscapeData;
    data.geoscapeNode = node;
    GAME_DrawMap(&data);
    if (!data.active)
        return;

    const char* map = data.map;
    date_t& date = data.date;

    /* Draw the map and markers */
    if (UI_MAPEXTRADATACONST(node).flatgeoscape) {
        /* the last q value for the 2d geoscape night overlay */
        static float lastQ = 0.0f;

        /* the sun is not always in the plane of the equator on earth - calculate the angle the sun is at */
        const float q = (date.day % DAYS_PER_YEAR + (float)(date.sec / (SECONDS_PER_HOUR * 6)) / 4) * 2 * M_PI / DAYS_PER_YEAR - M_PI;
        if (lastQ != q) {
            calcAndUploadDayAndNightTexture(node, q);
            lastQ = q;
        }
        R_DrawFlatGeoscape(UI_MAPEXTRADATACONST(node).mapPos, UI_MAPEXTRADATACONST(node).mapSize, (float) date.sec / SECONDS_PER_DAY,
                           UI_MAPEXTRADATACONST(node).center[0], UI_MAPEXTRADATACONST(node).center[1], 0.5 / UI_MAPEXTRADATACONST(node).zoom, map,
                           data.nationOverlay, data.xviOverlay, data.radarOverlay, r_dayandnightTexture, r_xviTexture, r_radarTexture);

        GAME_DrawMapMarkers(node);
    } else {
        bool disableSolarRender = false;
        if (UI_MAPEXTRADATACONST(node).zoom > 3.3)
            disableSolarRender = true;

        R_EnableRenderbuffer(true);

        R_Draw3DGlobe(UI_MAPEXTRADATACONST(node).mapPos, UI_MAPEXTRADATACONST(node).mapSize, date.day, date.sec,
                      UI_MAPEXTRADATACONST(node).angles, UI_MAPEXTRADATACONST(node).zoom, map, disableSolarRender,
                      UI_MAPEXTRADATACONST(node).ambientLightFactor, UI_MAPEXTRADATA(node).nationOverlay,
                      UI_MAPEXTRADATA(node).xviOverlay, UI_MAPEXTRADATA(node).radarOverlay, r_xviTexture, r_radarTexture,
                      true);

        GAME_DrawMapMarkers(node);

        R_DrawBloom();
        R_EnableRenderbuffer(false);
    }

    UI_PopClipRect();
}
Ejemplo n.º 2
0
/**
 * @sa R_BeginFrame
 * @sa R_EndFrame
 */
void R_RenderFrame (void)
{
	R_Setup3D();

	/* activate wire mode */
	if (r_wire->integer)
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	if (!(refdef.rendererFlags & RDF_NOWORLDMODEL)) {
		int tile;
		if (r_threads->integer) {
			while (r_threadstate.state != THREAD_RENDERER)
				Sys_Sleep(0);

			r_threadstate.state = THREAD_CLIENT;
		} else {
			R_SetupFrustum();

			/* draw brushes on current worldlevel */
			R_GetLevelSurfaceLists();
		}

		R_UpdateSustainedLights();

		R_CheckError();

		for (tile = 0; tile < r_numMapTiles; tile++) {
			const model_t *mapTile = r_mapTiles[tile];
			const mBspModel_t *bsp = &mapTile->bsp;

			R_AddBspRRef(bsp, vec3_origin, vec3_origin, false);
		}

		R_GetEntityLists();

		R_EnableFog(true);

		R_RenderOpaqueBspRRefs();
		R_RenderOpaqueWarpBspRRefs();
		R_DrawOpaqueMeshEntities(r_opaque_mesh_entities);

		R_RenderAlphaTestBspRRefs();

		R_EnableBlend(true);
		R_RenderMaterialBspRRefs();

		R_EnableFog(false);

		R_RenderBlendBspRRefs();
		R_RenderBlendWarpBspRRefs();
		R_DrawBlendMeshEntities(r_blend_mesh_entities);

		R_EnableFog(true);
		R_RenderFlareBspRRefs();
		R_EnableFog(false);

		if (r_debug_lights->integer) {
			int i;

			for (i = 0; i < refdef.numStaticLights; i++) {
				const light_t *l = &refdef.staticLights[i];
				R_AddCorona(l->origin, l->radius, l->color);
			}
			for (i = 0; i < refdef.numDynamicLights; i++) {
				const light_t *l = &refdef.dynamicLights[i];
				R_AddCorona(l->origin, l->radius, l->color);
			}
		}

		R_DrawCoronas();
		R_EnableBlend(false);

		for (tile = 0; tile < r_numMapTiles; tile++) {
			R_DrawBspNormals(tile);
		}

		R_Color(NULL);
		R_DrawSpecialEntities(r_special_entities);
		R_DrawNullEntities(r_null_entities);
		R_DrawEntityEffects();
	} else {
		glClear(GL_DEPTH_BUFFER_BIT);

		R_GetEntityLists();

		R_RenderOpaqueBspRRefs();
		R_RenderOpaqueWarpBspRRefs();
		R_DrawOpaqueMeshEntities(r_opaque_mesh_entities);
		R_RenderAlphaTestBspRRefs();

		R_EnableBlend(true);

		R_RenderMaterialBspRRefs();

		R_RenderBlendBspRRefs();
		R_RenderBlendWarpBspRRefs();
		R_DrawBlendMeshEntities(r_blend_mesh_entities);

		R_RenderFlareBspRRefs();

		R_EnableBlend(false);

		R_Color(NULL);
		R_DrawSpecialEntities(r_special_entities);
		R_DrawNullEntities(r_null_entities);
		R_DrawEntityEffects();
	}

	R_EnableBlend(true);

	R_DrawParticles();

	R_EnableBlend(false);

	/* leave wire mode again */
	if (r_wire->integer)
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	R_DrawBloom();

	R_DrawBoundingBoxes();

	R_ResetArrayState();

	/* go back into 2D mode for hud and the like */
	R_Setup2D();

	R_CheckError();
}