public EntityShadowRenderable( Entity parent,
HardwareIndexBuffer indexBuffer,
VertexData vertexData,
bool createSeparateLightCap,
SubEntity subEntity,
bool isLightCap )
{
this.parent = parent;
// Save link to vertex data
this.currentVertexData = vertexData;
// Initialize render op
this.renderOperation.indexData = new IndexData();
this.renderOperation.indexData.indexBuffer = indexBuffer;
this.renderOperation.indexData.indexStart = 0;
// index start and count are sorted out later
// Create vertex data which just references position component (and 2 component)
this.renderOperation.vertexData = new VertexData();
this.renderOperation.vertexData.vertexDeclaration =
HardwareBufferManager.Instance.CreateVertexDeclaration();
this.renderOperation.vertexData.vertexBufferBinding =
HardwareBufferManager.Instance.CreateVertexBufferBinding();
// Map in position data
this.renderOperation.vertexData.vertexDeclaration.AddElement( 0,
0,
VertexElementType.Float3,
VertexElementSemantic.Position );
this.originalPosBufferBinding =
vertexData.vertexDeclaration.FindElementBySemantic( VertexElementSemantic.Position ).Source;
this.positionBuffer = vertexData.vertexBufferBinding.GetBuffer( this.originalPosBufferBinding );
this.renderOperation.vertexData.vertexBufferBinding.SetBinding( 0, this.positionBuffer );
// Map in w-coord buffer (if present)
if ( vertexData.hardwareShadowVolWBuffer != null )
{
this.renderOperation.vertexData.vertexDeclaration.AddElement( 1,
0,
VertexElementType.Float1,
VertexElementSemantic.TexCoords,
0 );
this.wBuffer = vertexData.hardwareShadowVolWBuffer;
this.renderOperation.vertexData.vertexBufferBinding.SetBinding( 1, this.wBuffer );
}
// Use same vertex start as input
this.renderOperation.vertexData.vertexStart = vertexData.vertexStart;
if ( isLightCap )
{
// Use original vertex count, no extrusion
this.renderOperation.vertexData.vertexCount = vertexData.vertexCount;
}
else
{
// Vertex count must take into account the doubling of the buffer,
// because second half of the buffer is the extruded copy
this.renderOperation.vertexData.vertexCount = vertexData.vertexCount * 2;
if ( createSeparateLightCap )
{
// Create child light cap
this.lightCap = new EntityShadowRenderable( parent,
indexBuffer,
vertexData,
false,
subEntity,
true );
}
}
}