protected void RenderStaticGeometry()
{
// Check should we be rendering
if ( !SpecialCaseRenderQueueList.IsRenderQueueToBeProcessed( worldGeometryRenderQueueId ) )
return;
if ( level == null )
{
LogManager.Instance.Write( "BSPSceneManager [Warning]: Skip RenderStaticGeometry, no level was set!" );
return;
}
// no world transform required
targetRenderSystem.WorldMatrix = Matrix4.Identity;
// Set view / proj
targetRenderSystem.ViewMatrix = cameraInProgress.ViewMatrix;
targetRenderSystem.ProjectionMatrix = cameraInProgress.ProjectionMatrix;
ColorEx bspAmbient = ColorEx.White;
if ( level.BspOptions.ambientEnabled )
{
bspAmbient = new ColorEx( ambientColor.r * level.BspOptions.ambientRatio,
ambientColor.g * level.BspOptions.ambientRatio,
ambientColor.b * level.BspOptions.ambientRatio );
}
LayerBlendModeEx ambientBlend = new LayerBlendModeEx();
ambientBlend.blendType = LayerBlendType.Color;
ambientBlend.operation = LayerBlendOperationEx.Modulate;
ambientBlend.source1 = LayerBlendSource.Texture;
ambientBlend.source2 = LayerBlendSource.Manual;
ambientBlend.colorArg2 = bspAmbient;
// For each material in turn, cache rendering data & render
IEnumerator mapEnu = matFaceGroupMap.Keys.GetEnumerator();
bool passIsSet = false;
while ( mapEnu.MoveNext() )
{
// Get Material
Material thisMaterial = (Material)mapEnu.Current;
List<BspStaticFaceGroup> faceGrp = matFaceGroupMap[ thisMaterial ];
// if one face group is a quake shader then the material is a quake shader
bool isQuakeShader = faceGrp[ 0 ].isQuakeShader;
// Empty existing cache
renderOp.indexData.indexCount = 0;
// lock index buffer ready to receive data
unsafe
{
uint* pIdx = (uint*)renderOp.indexData.indexBuffer.Lock( BufferLocking.Discard );
for ( int i = 0; i < faceGrp.Count; i++ )
{
// Cache each
int numElems = CacheGeometry( (IntPtr)pIdx, faceGrp[ i ] );
renderOp.indexData.indexCount += numElems;
pIdx += numElems;
}
// Unlock the buffer
renderOp.indexData.indexBuffer.Unlock();
}
// Skip if no faces to process (we're not doing flare types yet)
if ( renderOp.indexData.indexCount == 0 )
continue;
if ( isQuakeShader )
{
for ( int i = 0; i < thisMaterial.GetTechnique( 0 ).PassCount; i++ )
{
SetPass( thisMaterial.GetTechnique( 0 ).GetPass( i ) );
targetRenderSystem.Render( renderOp );
}
passIsSet = false;
}
else if ( !passIsSet )
{
int i;
for ( i = 0; i < thisMaterial.GetTechnique( 0 ).PassCount; i++ )
{
SetPass( thisMaterial.GetTechnique( 0 ).GetPass( i ) );
// for ambient lighting
if ( i == 0 && level.BspOptions.ambientEnabled )
{
targetRenderSystem.SetTextureBlendMode( 0, ambientBlend );
}
targetRenderSystem.Render( renderOp );
}
// if it's only 1 pass then there's no need to set it again
passIsSet = ( i > 1 ) ? false : true;
}
else
{
Pass pass = thisMaterial.GetTechnique( 0 ).GetPass( 0 );
// Get the plain geometry texture
TextureUnitState geometryTex = pass.GetTextureUnitState( 0 );
targetRenderSystem.SetTexture( 0, true, geometryTex.TextureName );
if ( pass.TextureUnitStageCount > 1 )
{
// Get the lightmap
TextureUnitState lightmapTex = pass.GetTextureUnitState( 1 );
targetRenderSystem.SetTexture( 1, true, lightmapTex.TextureName );
}
targetRenderSystem.Render( renderOp );
}
}
//if(showNodeAABs)
// targetRenderSystem.Render(aaBGeometry);
}