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 var lightPos = light.GetAs4DVector(); var world2Obj = parentNode.FullTransform.Inverse(); lightPos = world2Obj * lightPos; // We need to search the edge list for silhouette edges if (this.edgeList == null) { throw new Exception("You enabled stencil shadows after the buid process! In " + "Region.GetShadowVolumeRenderableIterator"); } // Init shadow renderable list if required var init = this.shadowRenderables.Count == 0; RegionShadowRenderable esr = null; //bool updatedSharedGeomNormals = false; for (var i = 0; i < this.edgeList.EdgeGroups.Count; i++) { var group = (EdgeData.EdgeGroup) this.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, this.vertexProgramInUse || !extrudeVertices); this.shadowRenderables.Add(esr); } else { esr = (RegionShadowRenderable)this.shadowRenderables[i]; } // Extrude vertices in software if required if (extrudeVertices) { ExtrudeVertices(esr.PositionBuffer, group.vertexData.vertexCount, lightPos, extrusionDistance); } } return((IEnumerator)this.shadowRenderables); }
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 var lightPos = light.GetAs4DVector(); var world2Obj = parentNode.FullTransform.Inverse(); lightPos = world2Obj*lightPos; // We need to search the edge list for silhouette edges if ( this.edgeList == null ) { throw new Exception( "You enabled stencil shadows after the buid process! In " + "Region.GetShadowVolumeRenderableIterator" ); } // Init shadow renderable list if required var init = this.shadowRenderables.Count == 0; RegionShadowRenderable esr = null; //bool updatedSharedGeomNormals = false; for ( var i = 0; i < this.edgeList.EdgeGroups.Count; i++ ) { var group = (EdgeData.EdgeGroup)this.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, this.vertexProgramInUse || !extrudeVertices ); this.shadowRenderables.Add( esr ); } else { esr = (RegionShadowRenderable)this.shadowRenderables[ i ]; } // Extrude vertices in software if required if ( extrudeVertices ) { ExtrudeVertices( esr.PositionBuffer, group.vertexData.vertexCount, lightPos, extrusionDistance ); } } return (IEnumerator)this.shadowRenderables; }