Exemple #1
0
 public Camera(int bufferWidth, int bufferHeight, float fov, float nearPlane, float farPlane)
 {
     outputBuffer = new TextureBuffer(bufferWidth, bufferHeight);
     MoveTo(new Point3F(0, 0, 0));
     RotateTo(new Angle3F(0, 0, 0));
     perspectiveMatrix = Matrix4.FromPesrpective(fov, nearPlane, farPlane, bufferWidth / bufferHeight);
 }
        public void DrawTriangle(TextureBuffer target, Matrix4 transformationMatrix, ref int[,] zbuffer)
        {
            VertexParam[] transformedCoords = new VertexParam[vertices.Length];
            for (int vertexNum = 0; vertexNum < vertices.Length; vertexNum++)
            {
                transformedCoords[vertexNum] = vertices[vertexNum].position.Transform(transformationMatrix, 1);
            }

            target.DrawTriangle(transformedCoords[0], transformedCoords[1], transformedCoords[2], vertices[0].texture, vertices[1].texture, vertices[2].texture, ref zbuffer);
        }
Exemple #3
0
 public void DrawWire(TextureBuffer target, Matrix4 transformationMatrix, Color color)
 {
     int[,] zbuffer = new int[640, 640];
     for (int i = 0; i < 640; i++)
     {
         for (int j = 0; j < 640; j++)
         {
             zbuffer[i, j] = +2147483647;
         }
     }
     foreach (Triangle triangle in triangles)
     {
         triangle.DrawTriangle(target, transformationMatrix, ref zbuffer);
     }
 }