- 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.
- Visual C++數字圖像模式識別技術詳解
- 深入淺出Spring Boot 2.x
- Flask Web開發入門、進階與實戰
- Django:Web Development with Python
- 薛定宇教授大講堂(卷Ⅳ):MATLAB最優化計算
- NGINX Cookbook
- Kotlin開發教程(全2冊)
- 精通MySQL 8(視頻教學版)
- Visual FoxPro 6.0程序設計
- 零基礎學Python編程(少兒趣味版)
- Mastering Leap Motion
- 前端架構設計
- Learning SaltStack(Second Edition)
- 編程改變生活:用PySide6/PyQt6創建GUI程序(進階篇·微課視頻版)
- C# 4.0權威指南