这是我的视口类,用于我非常简单的光线跟踪器。
public sealed class ViewPort
{
public readonly Rectangle3D Rectangle;
public readonly int Width;
public readonly int Height;
public Bitmap Image { get; private set; }
public ViewPort(Rectangle3D rec, int width, int height)
{
this.Rectangle = rec;
this.Width = width;
this.Height = height;
this.Image = new Bitmap(this.Width, this.Height);
}
public bool TryRecord(Ray ray)
{
Point3D cross;
if (this.Rectangle.Intersect(ray, out cross))
{
this.Image.SetPixel(cross...,ray.Light);
}
else
{
return false;
}
}
}
好的,那么现在我该如何将三维点映射成二维图像呢?非常感谢您的帮助。非常感谢。
对于这类事情,最好是查看Scratchapixel.com,它详细解释了所有这些概念。在网上搜索一下,我相信你会发现这个惊人的资源:
http://scratchapixel.com/lessons/3d-basic-lessons/lesson-1-writing-a-simple-raytracer/