Beispiel #1
0
static void DrawSkyBox( const shader_t* shader )
{
//	Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );

	for (int i = 0; i < 6; ++i)
	{
		int sky_mins_subd[2], sky_maxs_subd[2];

		if ( ( sky_mins_st[i][0] >= sky_maxs_st[i][0] ) || ( sky_mins_st[i][1] >= sky_maxs_st[i][1] ) ) {
			continue;
		}

		sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][0] );
		sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_mins_st[i][1] );
		sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][0] );
		sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS * Com_Clamp( -1, 1, sky_maxs_st[i][1] );

		//
		// iterate through the subdivisions
		//
		for (int t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; ++t)
		{
			for (int s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; ++s)
			{
				MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
							i, s_skyTexCoords[t][s], s_skyPoints[t][s] );
			}
		}

		DrawSkySide( shader->sky.outerbox[i], sky_mins_subd, sky_maxs_subd );
	}
}
Beispiel #2
0
static void DrawSkyBox( shader_t *shader )
{
	int		i;

	sky_min = GFIXED_0;
	sky_max = GFIXED_1;

	Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );

	for (i=0 ; i<6 ; i++)
	{
		int sky_mins_subd[2], sky_maxs_subd[2];
		int s, t;

		sky_mins[0][i] = FIXED_FLOOR( sky_mins[0][i] * GFIXED(HALF_SKY_SUBDIVISIONS ,0)) / GFIXED(HALF_SKY_SUBDIVISIONS,0);
		sky_mins[1][i] = FIXED_FLOOR( sky_mins[1][i] * GFIXED(HALF_SKY_SUBDIVISIONS ,0)) / GFIXED(HALF_SKY_SUBDIVISIONS,0);
		sky_maxs[0][i] = FIXED_CEIL( sky_maxs[0][i] * GFIXED(HALF_SKY_SUBDIVISIONS ,0)) / GFIXED(HALF_SKY_SUBDIVISIONS,0);
		sky_maxs[1][i] = FIXED_CEIL( sky_maxs[1][i] * GFIXED(HALF_SKY_SUBDIVISIONS ,0)) / GFIXED(HALF_SKY_SUBDIVISIONS,0);

		if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
			 ( sky_mins[1][i] >= sky_maxs[1][i] ) )
		{
			continue;
		}

		sky_mins_subd[0] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_mins[0][i]);
		sky_mins_subd[1] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_mins[1][i]);
		sky_maxs_subd[0] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_maxs[0][i]);
		sky_maxs_subd[1] = FIXED_INT32SCALE(HALF_SKY_SUBDIVISIONS, sky_maxs[1][i]);

		if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )
			sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;

		if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;

		//
		// iterate through the subdivisions
		//
		for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
		{
			for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
			{
				MakeSkyVec( FIXED_INT32RATIO_G( s - HALF_SKY_SUBDIVISIONS,HALF_SKY_SUBDIVISIONS), 
							FIXED_INT32RATIO_G( t - HALF_SKY_SUBDIVISIONS,HALF_SKY_SUBDIVISIONS), 
							i, 
							s_skyTexCoords[t][s], 
							s_skyPoints[t][s] );
			}
		}

		DrawSkySide( shader->sky.outerbox[sky_texorder[i]],
			         sky_mins_subd,
					 sky_maxs_subd );
	}

}
Beispiel #3
0
static void DrawSkyBox( shader_t *shader )
{
    int		i;

    sky_min = 0.0f;
    sky_max = 1.0f;

    memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );

    for (i=0 ; i<6 ; i++)
    {
        int sky_mins_subd[2], sky_maxs_subd[2];
        int s, t;

        sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
        sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
        sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
        sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;

        if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
                ( sky_mins[1][i] >= sky_maxs[1][i] ) )
        {
            continue;
        }

        sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS;
        sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS;
        sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS;
        sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS;

        if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS )
            sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
        else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS )
            sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
        if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )
            sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;
        else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS )
            sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;

        if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS )
            sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
        else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS )
            sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
        if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS )
            sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;
        else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS )
            sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;

        //
        // iterate through the subdivisions
        //
        for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
        {
            for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
            {
                MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
                            ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS,
                            i,
                            s_skyTexCoords[t][s],
                            s_skyPoints[t][s] );
            }
        }

        DrawSkySide( shader->sky->outerbox[i],
                     sky_mins_subd,
                     sky_maxs_subd );
    }

}
static void DrawSkyBox( shader_t *shader, const float* eye_origin, const float* colorTint )
{
	int		i;
    int     vertexCount = 0;
    skyboxDrawInfo_t skybox;

    memset( &skybox, 0, sizeof( skybox ) );

	sky_min = 0;
	sky_max = 1;

	Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) );

	for (i=0 ; i<6 ; i++)
	{
		int sky_mins_subd[2], sky_maxs_subd[2];
		int s, t;
        skyboxSideDrawInfo_t* skyboxSide = &skybox.sides[i];

		sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
		sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
		sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;
		sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS;

		if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) ||
			 ( sky_mins[1][i] >= sky_maxs[1][i] ) )
		{
			continue;
		}

		sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS;
		sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS;
		sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS;
		sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS;

		if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS )
			sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS;

		if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS;
		if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS;
		else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) 
			sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS;

		//
		// iterate through the subdivisions
		//
		for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ )
		{
			for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ )
			{
				MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, 
							( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, 
							i, 
							s_skyTexCoords[t][s], 
							s_skyPoints[t][s] );
			}
		}

        skyboxSide->image = shader->sky.outerbox[sky_texorder[i]];

		vertexCount = DrawSkySide( 
                     skyboxSide,
                     vertexCount,
			         sky_mins_subd,
					 sky_maxs_subd );
	}

    skybox.vbuffer = s_skyVBuffer;
    skybox.tbuffer = s_skyTBuffer;

    GFX_DrawSkyBox( &skybox, eye_origin, colorTint );
}