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

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.

主站蜘蛛池模板: 仙游县| 鹿泉市| 中方县| 江口县| 宁强县| 石门县| 长垣县| 石林| 周宁县| 清原| 那曲县| 靖边县| 石柱| 延庆县| 怀来县| 龙陵县| 军事| 榆树市| 凤冈县| 伊川县| 台前县| 成安县| 武山县| 房山区| 搜索| 罗源县| 阿克苏市| 资溪县| 荔波县| 财经| 新河县| 金乡县| 泰州市| 威信县| 凌源市| 丰台区| 库尔勒市| 天长市| 库尔勒市| 江口县| 西安市|