Partager via


Matrix, structure

Mise à jour : novembre 2007

Décrit et manipule une matrice.

Espace de noms :  Microsoft.WindowsMobile.DirectX
Assembly :  Microsoft.WindowsMobile.DirectX (dans Microsoft.WindowsMobile.DirectX.dll)

Syntaxe

'Déclaration
Public Structure Matrix
'Utilisation
Dim instance As Matrix
public struct Matrix
public value class Matrix
JScript prend en charge l'utilisation de structures mais pas la déclaration de nouvelles structures.

Notes

Cette structure représente une matrice 4 × 4 de nombres à virgule flottante simple précision. Les champs de cette structure sont nommés à l'aide du numéro de ligne, suivi du numéro de colonne.

Dans Microsoft Windows Mobile Direct3D, l'élément M34 d'une matrice de projection ne peut pas être un nombre négatif. Si une application doit utiliser une valeur négative dans cet emplacement, elle doit mettre à l'échelle la matrice de projection entière par –1, à la place.

Exemples

L'exemple suivant montre comment utiliser une structure Matrix.

' This code example is from the Direct3D Mobile Matrices Sample
' in the .NET Compact Framework Samples in the SDK.
Private Sub SetupMatrices()
    ' For the world matrix, rotate the object about the y-axis.
    ' Set up the rotation matrix to generate one full rotation (2*PI radians) 
    ' every 1000 ms. To avoid the loss of precision inherent in very high 
    ' floating-point numbers, the system time is modulated by the rotation 
    ' period before conversion to a radian angle.
    Dim iTime As Integer = Environment.TickCount Mod 1000
    Dim fAngle As Single = iTime * (2.0F * System.Convert.ToSingle(Math.PI)) / 1000.0F
    device.Transform.World = Matrix.RotationY(fAngle)
    ' Set up the view matrix. A view matrix can be defined given an eye point,
    ' a point to lookat, and a direction indicating which way is up. Here, you set
    ' the eye five units back along the z-axis and up three units, look at the
    ' origin, and define "up" to be in the y-direction.
    device.Transform.View = Matrix.LookAtLH(New Vector3(0.0F, 3.0F, -5.0F), New Vector3(0.0F, 0.0F, 0.0F), New Vector3(0.0F, 1.0F, 0.0F))
    ' For the projection matrix, set up a perspective transform (which
    ' transforms geometry from 3-D view space to 2-D viewport space, with
    ' a perspective divide making objects smaller in the distance). To build
    ' a perspective transform, you need the field of view (1/4 PI is common),
    ' the aspect ratio, and the near and far clipping planes (which define
    ' the distances at which geometry should no longer be rendered).
    device.Transform.Projection = Matrix.PerspectiveFovLH(System.Convert.ToSingle(Math.PI) / 4, 1.0F, 1.0F, 100.0F)
End Sub
// This code example is from the Direct3D Mobile Matrices Sample
// in the .NET Compact Framework Samples in the SDK.
private void SetupMatrices()
{
    // For the world matrix, rotate the object about the y-axis.

    // Set up the rotation matrix to generate one full rotation (2*PI radians)
    // every 1000 ms. To avoid the loss of precision inherent in very high
    // floating-point numbers, the system time is modulated by the rotation
    // period before conversion to a radian angle.
    int iTime = Environment.TickCount % 1000;
    float fAngle = iTime * (2.0f * (float)Math.PI) / 1000.0f;
    device.Transform.World = Matrix.RotationY(fAngle);
    // Set up the view matrix. A view matrix can be defined given an eye point,
    // a point to look at, and a direction indicating which way is up. Here, you set
    // the eye five units back along the z-axis and up three units, look at the
    // origin, and define "up" to be in the y-direction.
    device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 3.0f, -5.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));
    // For the projection matrix, set up a perspective transform (which
    // transforms geometry from 3-D view space to 2-D viewport space, with
    // a perspective divide making objects smaller in the distance). To build
    // a perspective transform, you need the field of view (1/4 PI is common),
    // the aspect ratio, and the near and far clipping planes (which define
    // the distances at which geometry should no longer be rendered).
    device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, 100.0f);
}

Sécurité des threads

Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Plateformes

Windows CE, Windows Mobile pour Smartphone, Windows Mobile pour Pocket PC

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Informations de version

.NET Compact Framework

Pris en charge dans : 3.5, 2.0

Voir aussi

Référence

Membres Matrix

Microsoft.WindowsMobile.DirectX, espace de noms

Autres ressources

Programmation Direct3D Mobile dans le .NET Compact Framework