CustomVertex クラス
CustomVertex クラス
使用例
- テクスチャ マップを張るオブジェクト用の頂点バッファの作成
- シーンの生成
さまざまなカスタム固定フォーマットの頂点タイプ。
定義
Visual Basic | Public Class CustomVertex Inherits Object |
C# | public class CustomVertex : Object |
Managed C++ | public __gc class CustomVertex : public Object |
JScript | public class CustomVertex extends Object |
メンバ テーブル
次のテーブルは、CustomVertex オブジェクトによって公開されているメンバの一覧である。左側のタブをクリックし、表示したいメンバの種類を選ぶこと。
構造体
構造体 | 説明 |
---|---|
PositionColored | 位置とディフューズ色を格納するカスタム Vertex Format 構造体。 |
PositionColoredTextured | 位置、ディフューズ色、1 セット分のテクスチャ座標を格納するカスタム Vertex Format 構造体。 |
PositionNormal | 位置と法線データを格納するカスタム Vertex Format 構造体。 |
PositionNormalColored | 位置、法線データ、およびディフューズ色を格納するカスタム Vertex Format 構造体。 |
PositionNormalTextured | 位置、法線データ、1 セット分のテクスチャ座標を格納するカスタム Vertex Format 構造体。 |
PositionOnly | 位置のみを格納するカスタム Vertex Format 構造体。 |
PositionTextured | 位置および 1 セット分のテクスチャ座標を格納するカスタム Vertex Format 構造体。 |
Transformed | トランスフォーム済み頂点を格納するカスタム Vertex Format 構造体。 |
TransformedColored | トランスフォーム済み頂点とディフューズ色を格納するカスタム Vertex Format 構造体。 |
TransformedColoredTextured | トランスフォーム済み頂点、1 セット分のテクスチャ座標、およびディフューズ色を格納するカスタム Vertex Format 構造体。 |
TransformedTextured | トランスフォーム済み頂点および 1 セット分のテクスチャ座標を格納するカスタム Vertex Format 構造体。 |
継承の階層構造
CustomVertex
使用例
テクスチャ マップを張るオブジェクト用の頂点バッファの作成
この例は、テクスチャ マップ化された Microsoft® Direct3D® オブジェクトを表現する、定義済み頂点構造体を作成する方法である。
CustomVertex クラスで利用可能な 11 種類の構造体を、さまざまな種類の 3D オブジェクトの頂点バッファ表現に使うことができる。この場合、各頂点について PositionNormalTextured 構造体は、 (Tu, Tv) テクスチャ座標だけでなく、(Nx, Ny, Nz) 法線ベクタを格納する。
public void OnCreateVertexBuffer(object sender, EventArgs e)
{
VertexBuffer vb = (VertexBuffer)sender;
// Create a vertex buffer.
// Lock the buffer to be able to return filled structures
CustomVertex.PositionNormalTextured[] verts =
(CustomVertex.PositionNormalTextured[])vb.Lock(0,0);
// Fill the PositionNormalTextured structures with the
// 3-D object representation.
// When finished, unlock the vertex buffer to allow CPU access again.
}
シーンの生成
この例では、シーンの生成を開始して、プリミティブを描画する方法を示す。
SetStreamSource メソッドは、頂点バッファをデバイス データ ストリームにバインドし、頂点データと、プリミティブ処理関数にデータを供給するデータ ストリーム ポートの 1 つとを関連付ける。このメソッドのパラメータは、データ ストリームの数、VertexBuffer オブジェクトの名前、およびストリームの頂点ストライドである。
この例では、DrawPrimitives は、PrimitiveType 列挙の TriangleList 定数または TriangleStrip 定数のいずれかを使って、プリミティブをレンダリングできる。
using Microsoft.DirectX.Direct3D;
// Define custom vertex format
private struct customVertex
{
// Define structure
}
Device device = null; // Create rendering device
VertexBuffer vBuffer = null; // Create vertex buffer
// Begin the scene
device.BeginScene();
device.SetStreamSource( 0, vBuffer, 0);
// Assign custom vertex type, in this case a transformed, lit, and colored format
device.VertexFormat = CustomVertex.TransformedLitColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
// Alternative primitive rendering using TriangleStrip
// device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, (4*25)-2);
クラスの情報
名前空間 | Microsoft.DirectX.Direct3D |
アセンブリ | Microsoft.DirectX.Direct3D (microsoft.directx.direct3d.dll) |
厳密名 | Microsoft.DirectX.Direct3D, Version=0293, Culture=neutral, PublicKeyToken=d3231b57b74a1492 |
© 2002 Microsoft Corporation. All rights reserved. Terms of use.