protected void SetMesh( Mesh mesh )
{
this.mesh = mesh;
if ( mesh.HasSkeleton && mesh.Skeleton != null )
{
this.skeletonInstance = new SkeletonInstance( mesh.Skeleton );
this.skeletonInstance.Load();
}
else
{
this.skeletonInstance = null;
}
this.subEntityList.Clear();
this.BuildSubEntities();
this.lodEntityList.Clear();
// Check if mesh is using manual LOD
if ( mesh.IsLodManual )
{
for ( int i = 1; i < mesh.LodLevelCount; i++ )
{
MeshLodUsage usage = mesh.GetLodLevel( i );
// manually create entity
Entity lodEnt = new Entity( string.Format( "{0}Lod{1}", this.name, i ), usage.ManualMesh );
this.lodEntityList.Add( lodEnt );
}
}
this.animationState.RemoveAllAnimationStates();
// init the AnimationState, if the mesh is animated
if ( this.HasSkeleton )
{
this.numBoneMatrices = this.skeletonInstance.BoneCount;
this.boneMatrices = new Matrix4[ this.numBoneMatrices ];
}
if ( this.HasSkeleton || mesh.HasVertexAnimation )
{
mesh.InitAnimationState( this.animationState );
this.PrepareTempBlendedBuffers();
}
this.ReevaluateVertexProcessing();
// LOD default settings
this.meshLodFactorTransformed = 1.0f;
// Backwards, remember low value = high detail
this.minMeshLodIndex = 99;
this.maxMeshLodIndex = 0;
// Material LOD default settings
this.materialLodFactor = 1.0f;
this.maxMaterialLodIndex = 0;
this.minMaterialLodIndex = 99;
// Do we have a mesh where edge lists are not going to be available?
//if ( ( ( this.sceneMgr.ShadowTechnique == ShadowTechnique.StencilAdditive )
// || ( this.sceneMgr.ShadowTechnique == ShadowTechnique.StencilModulative ) ) &&
// !mesh.IsEdgeListBuilt && !mesh.AutoBuildEdgeLists )
//{
// this.CastShadows = false;
//}
}