- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 257字
- 2021-06-30 14:45:59
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.
- Implementing VMware Horizon 7(Second Edition)
- Objective-C Memory Management Essentials
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- PyTorch自動駕駛視覺感知算法實戰
- 華為HMS生態與應用開發實戰
- 趣學Python算法100例
- Java加密與解密的藝術
- 基于Swift語言的iOS App 商業實戰教程
- Python數據分析從0到1
- Mastering ROS for Robotics Programming
- 從零開始:C語言快速入門教程
- Python計算機視覺與深度學習實戰
- 測試工程師Python開發實戰
- Java語言GUI程序設計
- GitHub Essentials