public Vector(StreamReader infile) { x = infile.ReadFloat(); y = infile.ReadFloat(); z = infile.ReadFloat(); //infile.Pass(')'); /// todo? }
/// <summary> /// Create image based on size from stream /// </summary> /// <param name="infile"></param> public Image(StreamReader infile) { // read width and height Width = (int)infile.ReadFloat(); Height = (int)infile.ReadFloat(); // clamp width and height Width = Width < 1 ? 1 : (Width > 10000 ? 10000 : Width); Height = Height < 1 ? 1 : (Height > 10000 ? 10000 : Height); pixels = new Vector[Width, Height]; for (int i = 0; i < Width; ++i) for (int j = 0; j < Height; ++j) pixels[i, j] = new Vector(); }
/// standard object services --------------------------------------------------- public Camera(StreamReader infile) { // read and condition view definition ViewPosition = new Vector(infile); viewDirection = new Vector(infile); viewAngle = infile.ReadFloat(); viewDirection = viewDirection.Unitize(); if (viewDirection.IsZero()) viewDirection = new Vector(0.0f, 0.0f, 1.0f); if (viewAngle < 10) viewAngle = 10; if (viewAngle > 160) viewAngle = 160; viewAngle *= (float)(Math.PI / 180); // make other directions of frame up = new Vector(0.0f, 1.0f, 0.0f); right = up.Cross(viewDirection).Unitize(); if (!right.IsZero()) up = viewDirection.Cross(right).Unitize(); else { up = new Vector(0.0f, 0.0f, viewDirection[1] < 0.0f ? 1.0f : -1.0f); right = up.Cross(viewDirection).Unitize(); } } // Camera