- 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.
- Python概率統(tǒng)計
- Cassandra Design Patterns(Second Edition)
- Visual Basic程序設(shè)計教程
- Building an RPG with Unity 2018
- Spring快速入門
- .NET 3.5編程
- Python極簡講義:一本書入門數(shù)據(jù)分析與機器學習
- Learning Concurrency in Kotlin
- Python圖形化編程(微課版)
- Java Web開發(fā)就該這樣學
- Python+Tableau數(shù)據(jù)可視化之美
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- IDA Pro權(quán)威指南(第2版)
- Learning Nessus for Penetration Testing
- Elasticsearch Blueprints