public void Build( bool stencilShadows, int logLevel )
{
// Create a node
node = sceneMgr.RootSceneNode.CreateChildSceneNode( name, center );
node.AttachObject( this );
// We need to create enough LOD buckets to deal with the highest LOD
// we encountered in all the meshes queued
for ( ushort lod = 0; lod < lodValues.Count; ++lod )
{
LODBucket lodBucket = new LODBucket( this, lod, (float)lodValues[ lod ] );
lodBucketList.Add( lodBucket );
// Now iterate over the meshes and assign to LODs
// LOD bucket will pick the right LOD to use
IEnumerator iter = queuedSubMeshes.GetEnumerator();
while ( iter.MoveNext() )
{
QueuedSubMesh qsm = (QueuedSubMesh)iter.Current;
lodBucket.Assign( qsm, lod );
}
// now build
lodBucket.Build( stencilShadows, logLevel );
}
// Do we need to build an edge list?
if ( stencilShadows )
{
EdgeListBuilder eb = new EdgeListBuilder();
//int vertexSet = 0;
foreach ( LODBucket lod in lodBucketList )
{
foreach ( MaterialBucket mat in lod.MaterialBucketMap.Values )
{
// Check if we have vertex programs here
Technique t = mat.Material.GetBestTechnique();
if ( null != t )
{
Pass p = t.GetPass( 0 );
if ( null != p )
{
if ( p.HasVertexProgram )
{
vertexProgramInUse = true;
}
}
}
foreach ( GeometryBucket geom in mat.GeometryBucketList )
{
// Check we're dealing with 16-bit indexes here
// Since stencil shadows can only deal with 16-bit
// More than that and stencil is probably too CPU-heavy
// in any case
if ( geom.IndexData.indexBuffer.Type != IndexType.Size16 )
{
throw new AxiomException( "Only 16-bit indexes allowed when using stencil shadows" );
}
eb.AddVertexData( geom.VertexData );
eb.AddIndexData( geom.IndexData );
}
}
}
edgeList = eb.Build();
}
}