当前位置:网站首页>OpenGL - Coordinate Systems
OpenGL - Coordinate Systems
2022-07-05 09:12:00 【农场主er】
从顶点坐标到我们最终看到的效果,中间要经历多个坐标系的转换:
对于我们来讲,只需要关注三个矩阵即可:Vclip=Mprojection⋅Mview⋅Mmodel⋅Vlocal
Mmodel
:将局部坐标转为世界坐标的矩阵,注意此时的平移是以物体本身的坐标系为基准的Mview
:将世界坐标以摄像机的视角进行转换,比如向右平移,实际上视图会向左平移Mprojection
:对观察坐标进行投影
Camera/View space
通过view matrix
,将世界坐标系相对摄像机的位置和方向进行转换,就可以得到view space
。摄像机在世界坐标系的位置定义如下:
glm::vec3 cameraPos = glm::vec3(0.0f, 0.0f, 3.0f);
glm::vec3 cameraTarget = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 cameraDirection = glm::normalize(cameraPos - cameraTarget);
glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f);
glm::vec3 cameraRight = glm::normalize(glm::cross(up, cameraDirection));
glm::vec3 cameraUp = glm::cross(cameraDirection, cameraRight);
有了位置信息之后,可以计算出LookAt matrix
:
利用glm
可以更便捷的构造出该矩阵:
glm::mat4 view;
// Position Target Up
view = glm::lookAt(glm::vec3(0.0f, 0.0f, 3.0f),
glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f));
Walk around
Look around
Euler angles
俯仰角(pitch)
是描述我们如何往上或往下看的角,可以在第一张图中看到。第二张图展示了偏航角(yaw)
,表示我们往左和往右看的程度。滚转角(roll)
代表我们如何翻滚摄像机,通常在太空飞船的摄像机中使用。
鼠标左右移动改变了yaw
,上下移动改变了pitch
,变换的坐标可以计算为:
glm::vec3 direction;
// yaw 在xz平面, pitch 在yz平面
direction.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
direction.y = sin(glm::radians(pitch));
direction.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
Zoom
Camera Class
边栏推荐
- AdaBoost use
- Pearson correlation coefficient
- Characteristic Engineering
- 什么是防火墙?防火墙基础知识讲解
- 迁移学习和域自适应
- Multiple linear regression (sklearn method)
- TF coordinate transformation of common components of ros-9 ROS
- The combination of deep learning model and wet experiment is expected to be used for metabolic flux analysis
- scipy. misc. imread()
- ROS learning 1- create workspaces and function packs
猜你喜欢
Huber Loss
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Node collaboration and publishing
3D reconstruction open source code summary [keep updated]
Global configuration tabbar
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
Solutions of ordinary differential equations (2) examples
Wechat H5 official account to get openid climbing account
Wxml template syntax
Shutter uses overlay to realize global pop-up
随机推荐
Introduction Guide to stereo vision (1): coordinate system and camera parameters
Applet global style configuration window
利用请求头开发多端应用
Applet (use of NPM package)
信息與熵,你想知道的都在這裏了
.NET服务治理之限流中间件-FireflySoft.RateLimit
Blue Bridge Cup provincial match simulation question 9 (MST)
Information and entropy, all you want to know is here
Configuration and startup of kubedm series-02-kubelet
Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
. Net service governance flow limiting middleware -fireflysoft RateLimit
混淆矩阵(Confusion Matrix)
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
Understanding rotation matrix R from the perspective of base transformation
2311. 小于等于 K 的最长二进制子序列
TF coordinate transformation of common components of ros-9 ROS
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
Applet (global data sharing)
容易混淆的基本概念 成员变量 局部变量 全局变量