public Scena(string sciezkaTlo, Drawing.Size rozmiar, double odlegosc, double minOdleglosc) { Rozmiar = rozmiar; srodek = new Vector2D(rozmiar.Width / 2, rozmiar.Height / 2); BackBuffer = new byte[4 * rozmiar.Width * rozmiar.Height]; tlo = ToByteArray(sciezkaTlo); tlo.CopyTo(BackBuffer, 0); Swiat = new List <WavefrontObj>(); Kamera = new Kamera(); Odleglosc = odlegosc; zBufor = new double[rozmiar.Width, rozmiar.Height]; CzyscZBuffor(); MinOdleglosc = minOdleglosc; }
public static Vector3D[] RzutPerspektywiczny(this Vector3D[] wierzcholki, double d, Vector2D c, Kamera kamera) { var punktyRzut = new Vector3D[wierzcholki.Length]; for (int i = 0; i < wierzcholki.Length; ++i) { punktyRzut[i] = RzutPerspektywiczny(wierzcholki[i], d, c, kamera); } return(punktyRzut); }
public static Vector3D RzutPerspektywiczny(this Vector3D punkt, double d, Vector2D c, Kamera kamera) { var Proj = new DenseMatrix(4, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 / d, 1 }); var p = new DenseVector(new double[] { punkt.X, punkt.Y, punkt.Z, 1 }) * kamera.LookAt * Proj; return(new Vector3D(p[0] / p[3] + c.X, p[1] / p[3] + c.Y, p[2] + d /* kalibracja */)); }