一个3D模型要在显示器屏幕显示,必须顺序经过【世界变换】、【观察变换】和【投影变换】,顺序完成三个变换并在显示器显示的过程被称作绘制流水线。
1、世界变换
搭建3D场景时,首先要使用一个坐标系统来定位所有的3D模型的摆放位置,称为世界坐标系统。
每次在世界空间(3D场景)中放入一个3D模型,都必须根据该模型在世界空间的位置为其指定世界变换矩阵。
可以用以下函数得到世界变换矩阵,将这些变换矩阵相乘可以得到复杂的变换关系,使3D模型完成复杂的运动:
public static Matrix RotationYawPitchRoll(float yaw, float pitch, float roll);
public static Matrix Translation(float x, float y, float z);
public static Matrix RotationY(float yaw);
public static Matrix RotationX(float pitch);
public static Matrix RotationZ(float roll);
public static Matrix Scaling(float x, float y, float z);
public static Matrix Scaling(Vector3 vertex);
2、观察变换
一个观察者在世界空间中进行观察,所看到的部分场景就是要投影到显示器屏幕上的场景。
观察者在世界空间的不同位置所看到的是世界空间不同部分的场景。
摄像坐标系统:
首先,观察者必须在这个坐标系同原点;