Exemplo n.º 1
0
        // 渲染流程;
        private void _Render(List <IShape> shapes, List <IPosLight> lights)
        {
            if (!_inited || null == shapes || null == lights || _height == 0 || _width == 0)
            {
                return;
            }
            // 清屏;
            _Clear();
            // 按队列排序形状列表(未实现);
            _SortShapeList(shapes);
            // 更新view proj矩阵;
            _camera.UpdateMatrixs();
            // 收集顶点进行坐标变换,得到其在屏幕上的位置;
            int shapeCount = shapes.Count;

            for (int i = 0; i < shapeCount; ++i)
            {
                IShape shape = shapes[i];
                if (null == shape || !shape.Enabled)
                {
                    continue;
                }
                // 计算旋转位移和缩放;
                Matrix4 worldMat = shape.BuildWorldMatrix();
                // 合并变换;
                var transformMat = worldMat * _camera.viewMatrix * _camera.projMatrix;
                // 收集顶点准备进行绘制;
                shape.CollectVertex(transformMat, _width, _height, _renderMode, lights, _SetPixel);
            }
            // 将像素点光栅化到图片上;
            _Present();
        }