- 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.
推薦閱讀
- Spring Boot開發(fā)與測試實(shí)戰(zhàn)
- Rust實(shí)戰(zhàn)
- 算法訓(xùn)練營:入門篇(全彩版)
- Practical Data Science Cookbook(Second Edition)
- Programming ArcGIS 10.1 with Python Cookbook
- Java Web程序設(shè)計(jì)
- Java 9模塊化開發(fā):核心原則與實(shí)踐
- Drupal 8 Module Development
- Unreal Engine 4 Shaders and Effects Cookbook
- Webpack實(shí)戰(zhàn):入門、進(jìn)階與調(diào)優(yōu)
- CRYENGINE Game Development Blueprints
- Learning VMware vSphere
- Python預(yù)測分析實(shí)戰(zhàn)
- R語言實(shí)戰(zhàn)(第2版)
- 體驗(yàn)之道:從需求到實(shí)踐的用戶體驗(yàn)實(shí)戰(zhàn)