19,602
edits
m (correcting prev/next types in nav header) |
m (replaced matrix GIF with Math markup; had to change guide colors to suit what's available with Math's Tex implementation) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 103: | Line 103: | ||
;Transform matrices | ;Transform matrices | ||
:Like all matrices in Oni, they are composed of 3 vectors defining rotation/scaling/shearing and a 4th vector defining a translation. | :Like all matrices in Oni, they are composed of 3 vectors defining rotation/scaling/shearing and a 4th vector defining a translation. | ||
:In the above table, the 4 vectors are presented as rows per [[ | :In the above table, the 4 vectors are presented as rows per [[wp:Row-_and_column-major_order|Direct3D convention]], although OpenGL and Oni use them as columns. | ||
:[[ | :[[wp:Transformation_matrix#Affine_transformations|Affine transformations]] use a 4x4 matrix with 4 extra coefficients (in the presentation above, one would add one column on the right): | ||
::Three [[ | ::Three [[wp:3D_projection|projection transform]] coefficients (all of them are zero here); one final coefficient (always 1.0 for an affine transform matrix). | ||
:Alternately, one can think of the 3x4 matrix as a 3x3 rotation/scaling matrix and a position vector: | :Alternately, one can think of the 3x4 matrix as a 3x3 rotation/scaling matrix and a position vector: | ||
::*Let X=(x, y, z) be the position of a vertex in the M3GM | ::*Let X=(x, y, z) be the position of a vertex in the M3GM | ||
Line 156: | Line 156: | ||
VBS code snippets for use with Mod Tool can be found here: | VBS code snippets for use with Mod Tool can be found here: | ||
* [[Mod_Tool/Scripting# | * [[Mod_Tool/Scripting#Euler_rotation_-.3E_quaternion|Euler rotation to quaternion]] | ||
* [[Mod_Tool/Scripting# | * [[Mod_Tool/Scripting#Quaternion_-.3E_Euler_rotation|quaternion to Euler rotation]] | ||
==Calculating a transform matrix== | ==Calculating a transform matrix== | ||
In some scenarios we need to build a new transform matrix, e.g. when making a new weapon particle emitter. The first 9 values belong to a 3x3 rotation matrix. The last 3 values are the start positions. | In some scenarios we need to build a new transform matrix, e.g. when making a new weapon particle emitter. The first 9 values belong to a 3x3 rotation matrix. The last 3 values are the start positions. | ||
{| style="float:right;" | |||
!Single rotation matrices | |||
|- | |||
|<math>R_x(\theta)=\begin{bmatrix} | |||
\color{Salmon}1 & \color{YellowGreen}0 & \color{CornflowerBlue}0 \\ | |||
\color{Salmon}0 & \color{YellowGreen}\cos\theta & \color{CornflowerBlue}-\sin\theta \\ | |||
\color{Salmon}0 & \color{YellowGreen}\sin\theta & \color{CornflowerBlue}\cos\theta\end{bmatrix} | |||
</math> | |||
|} | |||
x = 60 | x = 60 | ||
<InitialTransform><span style="background-color:# | <InitialTransform><span style="background-color:#F69289">1 0 0</span> <span style="background-color:#98CC70">0 0.5 0.8660254</span> <span style="background-color:#41B0E4">0 -0.8660254 0.5</span> <font style="color:#AAAAAA">0 0 0</font></InitialTransform> | ||
<span style="background-color:# | <span style="background-color:#F69289">1 0 0</span> <span style="background-color:#98CC70">0 cos(x) sin(x)</span> <span style="background-color:#41B0E4">0 -sin(x) cos(x)<span> | ||
y = 60 | y = 60 | ||
<InitialTransform><span style="background-color:# | {| style="float:right;" | ||
<span style="background-color:# | |- | ||
|<math>R_x(\theta)=\begin{bmatrix} | |||
\color{YellowOrange}\cos\theta & \color{SpringGreen}0 & \color{ProcessBlue}\sin\theta \\ | |||
\color{YellowOrange}0 & \color{SpringGreen}1 & \color{ProcessBlue}0 \\ | |||
\color{YellowOrange}-\sin\theta & \color{SpringGreen}0 & \color{ProcessBlue}\cos\theta\end{bmatrix} | |||
</math> | |||
|} | |||
<InitialTransform><span style="background-color:#FAA21A">0.5 0 -0.8660254</span> <span style="background-color:#C6DC67">0 1 0</span> <span style="background-color:#00B0F0">0.8660254 0 0.5</span> <font style="color:#AAAAAA">0 0 0</font></InitialTransform> | |||
<span style="background-color:#FAA21A">cos(y) 0 -sin(y)</span> <span style="background-color:#C6DC67">0 1 0</span> <span style="background-color:#00B0F0">sin(y) 0 cos(y)</span> | |||
z = 60 | z = 60 | ||
<InitialTransform><span style="background-color:# | {| style="float:right;" | ||
<span style="background-color:# | |- | ||
|<math>R_x(\theta)=\begin{bmatrix} | |||
\color{OrangeRed}1 & \color{SeaGreen}0 & \color{RoyalBlue}0 \\ | |||
\color{OrangeRed}0 & \color{SeaGreen}\cos\theta & \color{RoyalBlue}-\sin\theta \\ | |||
\color{OrangeRed}0 & \color{SeaGreen}\sin\theta & \color{RoyalBlue}\cos\theta\end{bmatrix} | |||
</math> | |||
|} | |||
<InitialTransform><span style="background-color:#ED135A">0.5 0.8660254 0</span> <span style="background-color:#3FBC9D">-0.8660254 0.5 0</span> <span style="background-color:#0071BC">0 0 1</span> <font style="color:#AAAAAA">0 0 0</font></InitialTransform> | |||
<span style="background-color:#ED135A">cos(z) sin(z) 0</span> <span style="background-color:#3FBC9D">-sin(z) cos(z) 0</span> <span style="background-color:#0071BC">0 0 1</span> | |||
{| class="wikitable" style="float:right;" | {| class="wikitable" style="float:right;" | ||
Line 190: | Line 214: | ||
Mod Tool VBS code (rotations only): | Mod Tool VBS code (rotations only): | ||
* [[Mod_Tool/Scripting# | * [[Mod_Tool/Scripting#Euler_rotation_-.3E_matrix|Euler rotation to matrix]] | ||
* [[Mod_Tool/Scripting# | * [[Mod_Tool/Scripting#Matrix_-.3E_Euler_rotation|matrix to Euler rotation]] | ||
==Wish list== | ==Wish list== |