コード例 #1
0
ファイル: ModelMesh.cs プロジェクト: bondehagen/meshellator
        internal void Draw(VertexDeclaration vertexDeclaration, RenderSettings settings, IEnumerable <IDecorator> decorators)
        {
            _device.VertexDeclaration = vertexDeclaration;

            foreach (IDecorator decorator in decorators)
            {
                decorator.OnBeginDrawMesh(this, settings);
            }

            _device.SetStreamSource(0, _vertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes);
            _device.Indices = _indexBuffer;

            _effect.LightDirection = settings.Parameters.LightDirection;
            _effect.View           = settings.ViewMatrix;
            _effect.Projection     = settings.ProjectionMatrix;

            int passes = _effect.Begin();

            for (int i = 0; i < passes; i++)
            {
                _effect.BeginPass(i);

                _device.DrawIndexedPrimitives(
                    PrimitiveType.TriangleList, 0, 0, _numVertices,
                    0, _primitiveCount);

                _effect.EndPass();
            }
            _effect.End();

            foreach (IDecorator decorator in decorators)
            {
                decorator.OnEndDrawMesh(this, settings);
            }
        }