- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 120字
- 2021-06-30 14:46:00
Perspective
A perspective matrix is built from a field of view (typically in degrees), an aspect ratio, and near and far distances. It serves as an easy way to create a view frustum.
Implement the perspective function in mat4.cpp. Don't forget to add the function declaration to mat4.h:
mat4 perspective(float fov, float aspect, float n,float f){
float ymax = n * tanf(fov * 3.14159265359f / 360.0f);
float xmax = ymax * aspect;
return frustum(-xmax, xmax, -ymax, ymax, n, f);
}
The perspective function will be used in almost all visual graphics demonstrations throughout the rest of this book. It's a really convenient way of creating a view frustum.
推薦閱讀
- 大學計算機基礎(第三版)
- 案例式C語言程序設計
- Android Jetpack開發:原理解析與應用實戰
- Beginning Java Data Structures and Algorithms
- 計算機圖形學編程(使用OpenGL和C++)(第2版)
- Learning ArcGIS Pro 2
- 三維圖形化C++趣味編程
- Learning ASP.NET Core 2.0
- 算法精粹:經典計算機科學問題的Python實現
- VMware vSphere 6.7虛擬化架構實戰指南
- x86匯編語言:從實模式到保護模式(第2版)
- MATLAB實用教程
- Mastering Apache Maven 3
- Android玩家必備
- Lighttpd源碼分析