官术网_书友最值得收藏!

Frustum

Visually, a frustum looks like a pyramid with the tip cut off. A frustum has six sides; it represents the space that a camera can see. Create the frustum function in mat4.cpp. This function takes left, right, bottom, top, near, and far values:

mat4 frustum(float l, float r, float b,

             float t, float n, float f) {

    if (l == r || t == b || n == f) {

        std::cout << "Invalid frustum\n";

        return mat4(); // Error

    }

    return mat4(

        (2.0f * n) / (r - l),0, 0, 0,

        0,  (2.0f * n) / (t - b), 0, 0,

        (r+l)/(r-l), (t+b)/(t-b), (-(f+n))/(f-n), -1,

        0, 0, (-2 * f * n) / (f - n), 0

    );

}

Important note

The details of deriving the frustum matrix are beyond the scope of this book. For more information on how to derive the function, check out http://www.songho.ca/opengl/gl_projectionmatrix.html.

The frustum function can be used to construct a view frustum, but the function parameters are not intuitive. In the next section, you will learn how to create a view frustum from more intuitive arguments.

主站蜘蛛池模板: 海宁市| 旌德县| 健康| 九龙城区| 平罗县| 四子王旗| 广饶县| 三门县| 汤阴县| 金堂县| 莱芜市| 江源县| 克山县| 公安县| 上蔡县| 耒阳市| 安宁市| 淳化县| 新闻| 额敏县| 周至县| 临朐县| 昌黎县| 三穗县| 竹溪县| 赞皇县| 娄底市| 白山市| 永修县| 霸州市| 昌宁县| 静海县| 宾阳县| 镇巴县| 肇源县| 东方市| 日土县| 交城县| 平顺县| 东阿县| 平顶山市|