コード例 #1
0
ファイル: Drawer.cs プロジェクト: zvladyuha/CG-Seminar5
        public void Draw(WriteableBitmap bitmap, Mesh mesh, bool cutFaces)
        {
            var          projectedVertices = Project(mesh.GetWorldCoordinates());
            var          screenCoordinates = CalculateScreenCoordinates(projectedVertices);
            IList <Face> faces             = null;

            if (cutFaces)
            {
                faces = mesh.GetVisibleFaces(0, 0, 15);
            }
            else
            {
                faces = mesh.Faces;
            }
            for (var i = 0; i < faces.Count; ++i)
            {
                for (var j = 0; j < faces[i].Indices.Count; ++j)
                {
                    var x1 = screenCoordinates[faces[i].Indices[j], 0];
                    var y1 = screenCoordinates[faces[i].Indices[j], 1];
                    var x2 = screenCoordinates[faces[i].Indices[(j + 1) % faces[i].Indices.Count], 0];
                    var y2 = screenCoordinates[faces[i].Indices[(j + 1) % faces[i].Indices.Count], 1];
                    DrawAlgorithm.DrawLine(bitmap, Colors.Blue, x1, y1, x2, y2);
                }
            }
            //for (var i = 0; i < mesh.Vertices.Height; ++i)
            //{
            //    DrawAlgorithm.SetPixelIfPossible(screenCoordinates[i, 0], screenCoordinates[i, 1], Colors.White, bitmap);
            //}
        }
コード例 #2
0
 private void ClearImage()
 {
     DrawAlgorithm.ResetColor(Colors.Black, m_bitmap);
 }