【发布时间】:2011-04-28 07:06:28
【问题描述】:
我在http://www.devmaster.net/articles/raytracing_series/part1.php 上学习光线追踪时遇到了这段代码:
void Engine::InitRender()
{
// set first line to draw to
m_CurrLine = 20;
// set pixel buffer address of first pixel
m_PPos = 20 * m_Width;
// screen plane in world space coordinates
m_WX1 = -4, m_WX2 = 4, m_WY1 = m_SY = 3, m_WY2 = -3;
// calculate deltas for interpolation
m_DX = (m_WX2 - m_WX1) / m_Width;
m_DY = (m_WY2 - m_WY1) / m_Height;
m_SY += 20 * m_DY;
// allocate space to store pointers to primitives for previous line
m_LastRow = new Primitive*[m_Width];
memset( m_LastRow, 0, m_Width * 4 );
}
我很困惑作者如何将屏幕坐标映射到世界坐标...
谁能告诉我作者是如何得出这些线的?
或者告诉我如何将屏幕坐标映射到世界坐标?
// screen plane in world space coordinates
m_WX1 = -4, m_WX2 = 4, m_WY1 = m_SY = 3, m_WY2 = -3;
提前谢谢你!
【问题讨论】: