博客
关于我
OpenGL之视图矩阵View Matrix
阅读量:348 次
发布时间:2019-03-04

本文共 1240 字,大约阅读时间需要 4 分钟。

OpenGL矩阵中有一个重要的矩阵,视图矩阵。

把物体从世界坐标系转化到视点坐标系的矩阵称为视图矩阵。

记录一下用过的经验。

视图矩阵有三组向量,分别是视点,观察点和Up向量。

视点,即眼睛观察的位置,x轴表示从x轴侧看,y轴表示从y轴斜看,z轴从z轴方向看.

z轴一般决定远近,物体的大小,值远大,观测的距离就越远,图形显示效果看着就越小。
x轴,y轴决定了物体的角度。

观察点,修改x,y轴,图像会沿x,y轴移动。z轴的值必须小于视点z轴的值,否则看不见图像。

Up向量,如果拿着相机,这就是我们的头部要指向的地方。范围为0.0f-1.0f,如果z轴为0,设置x轴和y轴,会使图像沿着z轴旋转。

/*** Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;* it positions things relative to our eye.*/private float[] mViewMatrix = new float[16];// Position the eye behind the origin.final float eyeX = 0.0f;final float eyeY = 0.0f;final float eyeZ = 20f;// We are looking toward the distancefinal float centerX = 0.0f;final float centerY = 0.0f;final float centerZ = 19.9f;// Set our up vector. This is where our head would be pointing were we holding the camera.final float upX = 0.5f;final float upY = 1.0f;final float upZ = 0.0f;// Set the view matrix. This matrix can be said to represent the camera position.// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);

转载地址:http://fdre.baihongyu.com/

你可能感兴趣的文章
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 添加列,修改列,删除列
查看>>
mysql 添加索引
查看>>