- 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.
- DBA攻堅指南:左手Oracle,右手MySQL
- 軟件界面交互設計基礎
- Android 應用案例開發大全(第3版)
- Unity 2018 Augmented Reality Projects
- 從零開始學Android開發
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)
- Node.js 6.x Blueprints
- Mastering Python
- Clojure編程樂趣
- 小學生C++趣味編程從入門到精通
- Learning ROS for Robotics Programming
- INSTANT Apache Maven Starter
- Building E-Commerce Solutions with WooCommerce(Second Edition)
- 微信小程序開發圖解案例教程:附精講視頻(第3版)
- Python網絡運維自動化