Matrixクラスのメソッドにより行列計算を行い、DeviceクラスのTransformプロパティのWorldプロパティに設定します。
| Device.Transformプロパティ | public Transforms Transform { get; } |
| Transforms.Worldプロパティ | public Matrix World { get; set; } |
オフセットを指定して行列を作成します。
| 静的メソッド | public static Matrix Translation( Vector3 v ); |
|---|---|
| インスタンス メソッド | public void Translate( Vector3 v ); |
x、y、zの要素を持つ3次元ベクトル (Vector3) を引数に取り、

のような行列を作成します。
// 原点に設定 device.Transform.World = Matrix.Identity; // 座標 ( 1.0, 2.0, 3.0 ) へ移動 device.Transform.World *= Matrix.Translation( 1.0f, 2.0f, 3.0f );
| 回転軸 | メソッド | 作成される行列 | |
|---|---|---|---|
| X軸 | RotationX | RotateX | ![]() |
| Y軸 | RotationY | RotateY | ![]() |
| Z軸 | RotationZ | RotateZ | ![]() |
| 任意の軸 | RotationAxis | RotateAxis | |
RotationX系は静的メソッドで、回転後の新しいMatrix構造体を返します。
RotateX系は、その行列自体を回転させます。
| 静的メソッド | public static Matrix RotationX( float angle );
public static Matrix RotationAxis(
Vector3 axisRotation,
float angle
);
|
|---|---|
| インスタンス メソッド | public void RotateX( float angle );
public void RotateAxis(
Vector3 axisRotation,
float angle
);
|
device.Transform.World *= Matrix.RotationX(
Geometry.DegreeToRadian( 90.0f ) );
ヨー、ピッチ、およびロールを指定して行列を作成します。
| 静的メソッド |
public static Matrix RotationYawPitchRoll(
float yaw,
float pitch,
float roll
);
|
|---|---|
| インスタンス メソッド |
public void RotateYawPitchRoll(
float yaw,
float pitch,
float roll
);
|
x軸、y軸、z軸に沿ってスケーリングする行列を作成します。
| 静的メソッド | public static Matrix Scaling( Vector3 v ); |
|---|---|
| インスタンス メソッド | public void Scale( Vector3 v ); |
移動、回転、拡大縮小の処理はすべて行列の演算で行われるため、処理の順番によって異なる結果となります。
// 原点に初期化 device.Transform.World = Matrix.Identity; // 拡大縮小 device.Transform.World *= Matrix.Scaling( 2.0f, 2.0f, 2.0f ); // 回転 device.Transform.World *= Matrix.RotationX( Geometry.DegreeToRadian( 90.0f ) ); // 移動 device.Transform.World *= Matrix.Translation( 1.0f, 2.0f, 3.0f );