blender坐標系梳理
一、 目的
理解Blender三維建模軟件建模坐標系,obj輸出方式,以及與OpenGL坐標系的關系。
二、Blender坐標系解析
0. 建模坐標系
在Blender中, 建模坐標系如下圖\((R,F,U)\)(向右,向前,向上)所示:

在建模坐標系中, 各軸用列向量方式表示為:
\[R=e_1=\begin{pmatrix}1\\0\\0\end{pmatrix}, F=e_2=\begin{pmatrix}0\\1\\0\end{pmatrix}, U=e_3=\begin{pmatrix}0\\0\\1\end{pmatrix} \]
1. Blender中obj輸出坐標說明
1.0 基本定義
設點在建模坐標系\((R,F,U)\)下的坐標為\(\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}\),在輸出坐標系\((X,Y,Z)\)下的坐標為\(\begin{pmatrix}x\\y\\z\end{pmatrix}\),輸出坐標系到建模坐標系的轉換矩陣為\(M\),則有
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=M\begin{pmatrix}x\\y\\z\end{pmatrix} \]
\[\begin{pmatrix}x\\y\\z\end{pmatrix}=M^{-1}\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix} \]
1.1 (向上:Z,向前:Y)輸出
此輸出方式下,輸出坐標系即為建模坐標系,
\[X=R=e_1, Y=F=e_2, Z=U=e_3 \]
建模坐標\(\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}\)與輸出坐標\(\begin{pmatrix}x\\y\\z\end{pmatrix}\)的轉換關系為
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=xe_1 + ye_2 + ze_3 = (e_1,e_2,e_3)\begin{pmatrix}x\\y\\z\end{pmatrix}=\begin{pmatrix}x\\y\\z\end{pmatrix} \]
即
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=\begin{pmatrix}x\\y\\z\end{pmatrix} \]
轉換矩陣及其逆矩陣為
\[M = (e_1,e_2,e_3)=\begin{pmatrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 &1\end{pmatrix}= E_3 \]
\[M^{-1} = M^T = M = E_3 \]
1.2 (向上: Z,向前: -Y)輸出
此輸出方式中, 輸出坐標系軸在建模坐標系中為:
\[X=-R=-e_1, Y=-F=-e_2, Z=U=e_3 \]
建模坐標\(\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}\)與輸出坐標\(\begin{pmatrix}x\\y\\z\end{pmatrix}\)的轉換關系為
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=x(-e_1) + y(-e_2) + ze_3 =(-e_1,-e_2,e_3)\begin{pmatrix}x\\y\\z\end{pmatrix} \]
轉換矩陣及其逆矩陣為
\[M = (-e_1,-e_2,e_3)=\begin{pmatrix}-1 & 0 & 0\\0 & -1 & 0\\0 & 0 &1\end{pmatrix} \]
\[M^{-1} = M^T = M \]
1.3 (向上: Y,向前: -Z)輸出(OpenGL坐標系)
此輸出方式中,輸出坐標系與建模坐標系的關系為:
\[X=R=e_1, Y=U=e_3, Z=-F=-e_2 \]
建模坐標\(\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}\)與輸出坐標\(\begin{pmatrix}x\\y\\z\end{pmatrix}\)的轉換關系為
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=x(e_1) + y(e_3) + z(-e_2) =(e_1,e_3,-e_2)\begin{pmatrix}x\\y\\z\end{pmatrix} \]
轉換矩陣及其逆矩陣為
\[M = (e_1,e_3,-e_2)=\begin{pmatrix}1 & 0 & 0\\0 & 0 & -1\\0 & 1 &0\end{pmatrix} \]
\[M^{-1} = M^T = \begin{pmatrix}1 & 0 & 0\\0 & 0 & 1\\0 & -1 &0\end{pmatrix} \]
1.4 (向上: Y,向前: Z)
此輸出方式中,輸出坐標系與建模坐標系的關系為:
\[X=-R=-e_1, Y=U=e_3, Z=F=e_2 \]
建模坐標\(\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}\)與輸出坐標\(\begin{pmatrix}x\\y\\z\end{pmatrix}\)的轉換關系為
\[\begin{pmatrix}x_o\\y_o\\z_o\end{pmatrix}=x(-e_1) + y(e_3) + z(e_2) =(-e_1,e_3,e_2)\begin{pmatrix}x\\y\\z\end{pmatrix} \]
轉換矩陣及其逆矩陣為
\[M = (-e_1,e_3,e_2)=\begin{pmatrix}-1 & 0 & 0\\0 & 0 & 1\\0 & 1 &0\end{pmatrix} \]
\[M^{-1} = M^T = M = \begin{pmatrix}-1 & 0 & 0\\0 & 0 & 1\\0 & 1 &0\end{pmatrix} \]