Share via


方法 : 移動し、カメラの対象

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

移動し、Direct3D シーン内のカメラ ビュー変換を使用してターゲットできます。

注意

マネージの Direct3D モバイル アプリケーションが、Pocket PC やスマートフォン Windows Mobile 5. 0 ソフトウェアを必要です。.NET の外部のリソース フレームワークを最適化します。 Windows Mobile ソフトウェアおよび SDK についてを参照してください。

ビュー変換はワールド空間からの Direct3D オブジェクトを画面の領域を変換します。 ビュー変換を実行してへのカメラ (またはビューアー) の位置、カメラ、ターゲットおよび、座標系の意識の画面で、結果を操作できますにより、ワールド空間の座標を画面空間座標に正しく変換されます。

ワールド空間は、左手座標系をする正の Y 軸の値上に移動、正の x 軸の値が右に、移動し、架空のビューアーから z 軸の正の値を移動に基づきます。 方向逆に、右手座標系の座標系での z 軸の正の値に移動、ビューアーします。

デバイスの Transform プロパティは、変換状態を説明する Matrix 構造体を返します。 移動して、カメラを対象には、変換を処理する LookAtLH メソッドを使用してのビュー トランスフォーム行列をデバイス オブジェクトに渡します。

次の例で、カメラは最初、正の時点の z 軸は、上、シーンの背後の開始され原点の近くに点を対象します。 カメラは、シーンの背後にある、ため z 軸の正の値は遠く離れた場所ではなく、カメラに近いオブジェクトを配置します。 さらに、x 軸の正の値は右ではなく左側に遠くオブジェクトを配置します。

使用例

船を表すプリミティブ ボックス メッシュをアニメーション化するアプリケーションのビュー変換を次のコード例に示します。 完全な例のコードは 方法 : Direct3D オブジェクトを変換します。 を参照してください。

このコード例はなどのいくつかのオブジェクト。

  • 船を表すプリミティブ Mesh オブジェクト。

  • Device オブジェクトを返します。

                        ' Set up the view matrix. You can define a view matrix with a camera position,
                        ' a point to look at (camera target), and an "up" direction.
                        ' First vector passed to LookAtLH is the camera position.
                        ' Second vector passed to LookAtLH is the camera target.
                        ' Third vector passed to LookAtLH defines the "up" direction.
                        ' In this example, you set the camera seven units up along the z-axis ("behind"
                        ' the scene), down one unit, and left two units. You then point the camera
                        ' just above the origin and define "up" to be in the y-direction.
                        If
                        Not isShipDeparted Then
    device.Transform.View = Matrix.LookAtLH(New Vector3(- 2, - 1, 7), New Vector3(0, 1, 0), New Vector3(0, 1, 0))
Else    ' Handles movement of camera after     ' the ship "fires" the main engines.
    device.Transform.View = Matrix.LookAtLH(New Vector3(xCameraPosition, yCameraPosition, 7), New Vector3(0, 1, 0), New Vector3(0, 1, 0))
    xCameraPosition += 0.01F
    yCameraPosition += 0.01F
EndIf
                        // Set up the view matrix. You can define a view matrix with a camera position,
                        // a point to look at (camera target), and an 
                        "up" direction.
// First vector passed to LookAtLH is the camera position.// Second vector passed to LookAtLH is the camera target.// Third vector passed to LookAtLH defines the "up" direction.
// Here, you set the camera seven units up along the z-axis ("behind"// the scene), down one unit, and left two units. You then point the camera// just above the origin and define "up" to be in the y-direction.
if (!isShipDeparted)
{
    device.Transform.View = Matrix.LookAtLH(new Vector3(-2, -1, 7),
        new Vector3(0, 1, 0), new Vector3(0, 1, 0));
}
else
{
    // Handles movement of camera after // the ship "fires" the main engines.
    device.Transform.View = Matrix.LookAtLH(new Vector3(xCameraPosition, 
        yCameraPosition, 7), new Vector3(0, 1, 0), new Vector3(0, 1, 0));
    xCameraPosition += 0.01f;
    yCameraPosition += 0.01f;
}

コードのコンパイル方法

この例では、方法 : Direct3D オブジェクトを変換します。 の完全なサンプル コードは必要があります。

参照

概念

.NET コンパクトなフレームワーク方法を説明したトピックの検索

その他の技術情報

.NET Compact Framework でモバイル Direct3D プログラミング