/// <summary>
 /// Renders the model with a particular set of animation layers
 /// </summary>
 public void Render( IRenderContext context, AnimationLayer[] layers, ModelInstance.ReferencePoint[] refPoints )
 {
     if ( m_RaiseRootMeshToFloor )
     {
         ModelMesh.FrameInfo frame = m_RootMesh.GetAnimationFrame( layers );
         Graphics.Renderer.Translate( TransformType.LocalToWorld, 0, -frame.MinBounds.Y, 0 );
     }
     m_RootMesh.Render( context, layers, refPoints );
 }
        /// <summary>
        /// Renders this mesh using the given context and animation setup
        /// </summary>
        public void Render( IRenderContext context, AnimationLayer[] layers, ModelInstance.ReferencePoint[] refPoints )
        {
            //	Determine the current animation frame
            int currentFrame = DefaultFrame;
            if ( layers != null )
            {
                currentFrame = ( layers[ ( int )Part ].CurrentAnimationFrame );
            }

            //	DrawMeshBounds( layers );

            //	Assign texture sampler parameters
            //	TODO: This should be part of the render technique
            ITexture2d lastTexture = null;
            for ( int surfaceIndex = 0; surfaceIndex < m_Surfaces.Length; ++surfaceIndex )
            {
                Surface curSurface = m_Surfaces[ surfaceIndex ];

                if ( curSurface.Texture != lastTexture )
                {
                    if ( lastTexture != null )
                    {
                        Graphics.Renderer.UnbindTexture( lastTexture );
                    }
                    Graphics.Renderer.BindTexture( curSurface.Texture );
                    lastTexture = curSurface.Texture;
                }
                if ( m_TextureParameter != null )
                {
                    m_TextureParameter.Set( curSurface.Texture );
                }

                m_SurfaceRenderer.CurrentSurface	= curSurface;
                m_SurfaceRenderer.CurrentFrame		= curSurface.SurfaceFrames[ currentFrame ];

                m_Technique.Apply( context, m_SurfaceRenderer );
            }
            if ( lastTexture != null )
            {
                Graphics.Renderer.UnbindTexture( lastTexture );
            }

            foreach ( NestedPart nestedPart in m_NestedParts )
            {
                FrameInfo curFrame = FrameInfoList[ currentFrame ];
                Tag transformTag = curFrame.Tags[ nestedPart.m_TransformTagIndex ];

                Matrix44 transform = transformTag.Transform;
                Graphics.Renderer.PushTransform( TransformType.LocalToWorld, transform );

                ModelMesh nestedMesh = m_Model.GetPartMesh( nestedPart.m_Part );
                if ( nestedMesh != null )
                {
                    nestedMesh.Render( context, layers, refPoints );
                }
                ModelInstance.ReferencePoint refPt = refPoints[ ( int )nestedPart.m_Part ];
                if ( refPt != null )
                {
                    refPt.Render( context );
                }

                Graphics.Renderer.PopTransform( TransformType.LocalToWorld );
            }
        }