Share via


メッシュ オブジェクトの作成

メッシュ オブジェクトの作成

この例では、事前に作成されたメッシュ ファイル、ジオメトリ、頂点バッファの処理を自動化する Mesh オブジェクトを作成する方法を示している。

using Microsoft.DirectX.Direct3D;
.
.
.
public class myMeshes : Form
{
    // Global variables for this project
    Device device = null;         // Create rendering device
    PresentParameters presentParams = new PresentParameters();
    Mesh mesh = null;             // Create mesh object
        
    // Custom Direct3D vertex format used by the vertex buffer
    struct myVertex
    {
        public Vector3 p;         // vertex position
        public Vector3 n;         // vertex normal
        public static readonly VertexFormat format = VertexFormat.Xyz | 
                                                     VertexFormat.Normal;
    };
    
    private int numTriangles = 0; // Number of triangles in one wall of mesh
    
    // Compute the total number of triangles, numTriangles
    .
    .
    .
    public bool InitializeGraphics()
    {
        try
        {
            device = new Device(0, DeviceType.Hardware, this, 
                                CreateFlags.SoftwareVertexProcessing,
                                presentParams);
            mesh = new Mesh( numTriangles, numTriangles * 3, 
                0, myVertex.format, device );
            pause = false;
            return true;
        }
        catch { return false; }
    }

    // Call InitializeGraphics from Main...
    
}

関連項目

© 2002 Microsoft Corporation. All rights reserved. Terms of use.