public IEnumerator GetShadowVolumeRenderableIterator( ShadowTechnique shadowTechnique, Light light, HardwareIndexBuffer indexBuffer,
bool extrudeVertices, float extrusionDistance, ulong flags )
{
Debug.Assert( indexBuffer != null, "Only external index buffers are supported right now" );
Debug.Assert( indexBuffer.Type == IndexType.Size16, "Only 16-bit indexes supported for now" );
// Calculate the object space light details
Vector4 lightPos = light.GetAs4DVector();
Matrix4 world2Obj = parentNode.FullTransform.Inverse();
lightPos = world2Obj * lightPos;
// We need to search the edge list for silhouette edges
if ( edgeList == null )
{
throw new Exception( "You enabled stencil shadows after the buid process! In " +
"Region.GetShadowVolumeRenderableIterator" );
}
// Init shadow renderable list if required
bool init = shadowRenderables.Count == 0;
RegionShadowRenderable esr = null;
//bool updatedSharedGeomNormals = false;
for ( int i = 0; i < edgeList.EdgeGroups.Count; i++ )
{
EdgeData.EdgeGroup group = (EdgeData.EdgeGroup)edgeList.EdgeGroups[ i ];
if ( init )
{
// Create a new renderable, create a separate light cap if
// we're using a vertex program (either for this model, or
// for extruding the shadow volume) since otherwise we can
// get depth-fighting on the light cap
esr = new RegionShadowRenderable( this, indexBuffer, group.vertexData, vertexProgramInUse || !extrudeVertices );
shadowRenderables.Add( esr );
}
else
{
esr = (RegionShadowRenderable)shadowRenderables[ i ];
}
// Extrude vertices in software if required
if ( extrudeVertices )
{
ExtrudeVertices( esr.PositionBuffer, group.vertexData.vertexCount, lightPos, extrusionDistance );
}
}
return (IEnumerator)shadowRenderables;
}