Beispiel #1
0
/*
* R_BeginOcclusionPass
*/
void R_BeginOcclusionPass( void )
{
	assert( OCCLUSION_QUERIES_ENABLED( ri ) );

	r_occludersQueued = qfalse;
	r_occlusionEntity = r_worldent;
	memset( r_queriesBits, 0, sizeof( r_queriesBits ) );

	R_LoadIdentity();

	R_BackendResetPassMask();

	R_ClearSurfOcclusionQueryKeys();

	qglDisable( GL_TEXTURE_2D );
}
Beispiel #2
0
/*
=============
R_ShadowPassDrawWorld
=============
*/
static void R_ShadowPassDrawWorld( const plight_t *pl )
{
	if( pl->flags & CF_NOWORLD_PROJECTION )
		return;	// no worldlight, no worldshadows

	// restore worldmodel
	RI.currententity = GET_ENTITY( 0 );
	RI.currentmodel = RI.currententity->model;

	tr.modelorg = RI.vieworg;

	R_LoadIdentity();
	R_RecursiveLightNode( worldmodel->nodes, pl->frustum, pl->clipflags );
	R_LightStaticBrushes( pl );

	R_DrawShadowChains();
}
Beispiel #3
0
/*
=============
R_TranslateForEntity
=============
*/
void R_TranslateForEntity( cl_entity_t *e )
{
	float	scale = 1.0f;

	if( e == clgame.entities || R_StaticEntity( e ))
	{
		R_LoadIdentity();
		return;
	}

	if( e->model->type != mod_brush && e->curstate.scale > 0.0f )
		scale = e->curstate.scale;

	Matrix4x4_CreateFromEntity( RI.objectMatrix, vec3_origin, e->origin, scale );
	Matrix4x4_ConcatTransforms( RI.modelviewMatrix, RI.worldviewMatrix, RI.objectMatrix );

	pglMatrixMode( GL_MODELVIEW );
	GL_LoadMatrix( RI.modelviewMatrix );
	tr.modelviewIdentity = false;
}
Beispiel #4
0
/*
=================
R_ShadowPassDrawBrushModel
=================
*/
void R_ShadowPassDrawBrushModel( cl_entity_t *e, const plight_t *pl )
{
	Vector	mins, maxs;
	model_t	*clmodel;
	bool	rotated;

	clmodel = e->model;

	if( e->angles != g_vecZero )
	{
		for( int i = 0; i < 3; i++ )
		{
			mins[i] = e->origin[i] - clmodel->radius;
			maxs[i] = e->origin[i] + clmodel->radius;
		}
		rotated = true;
	}
	else
	{
		mins = e->origin + clmodel->mins;
		maxs = e->origin + clmodel->maxs;
		rotated = false;
	}

	if( R_CullBox( mins, maxs, RI.clipFlags ))
		return;

	if( RI.params & ( RP_SKYPORTALVIEW|RP_PORTALVIEW|RP_SCREENVIEW ))
	{
		if( rotated )
		{
			if( R_VisCullSphere( e->origin, clmodel->radius ))
				return;
		}
		else
		{
			if( R_VisCullBox( mins, maxs ))
				return;
		}
	}

	if( rotated ) R_RotateForEntity( e );
	else R_TranslateForEntity( e );

	if( rotated ) tr.modelorg = RI.objectMatrix.VectorITransform( RI.vieworg );
	else tr.modelorg = RI.vieworg - e->origin;

	// accumulate lit surfaces
	msurface_t *psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
	for( int i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ )
	{
		float *v;
		int k;

		if( psurf->flags & (SURF_DRAWTILED|SURF_PORTAL|SURF_REFLECT))
			continue;

		R_AddToGrassChain( psurf, pl->frustum, pl->clipflags, false );

		if( R_CullSurfaceExt( psurf, pl->frustum, 0 ))
			continue;

		// draw depth-mask on transparent textures
		if( psurf->flags & SURF_TRANSPARENT )
		{
			pglEnable( GL_ALPHA_TEST );
			pglEnable( GL_TEXTURE_2D );
			pglAlphaFunc( GL_GREATER, 0.0f );
			GL_Bind( GL_TEXTURE0, psurf->texinfo->texture->gl_texturenum );
		}

		pglBegin( GL_POLYGON );
		for( k = 0, v = psurf->polys->verts[0]; k < psurf->polys->numverts; k++, v += VERTEXSIZE )
		{
			if( psurf->flags & SURF_TRANSPARENT )
				pglTexCoord2f( v[3], v[4] );
			pglVertex3fv( v );
		}
		pglEnd();

		if( psurf->flags & SURF_TRANSPARENT )
		{
			pglDisable( GL_ALPHA_TEST );
			pglDisable( GL_TEXTURE_2D );
		}
	}

	R_LoadIdentity();	// restore worldmatrix
}