Geometry.ComputeBoundingSphere(Array,VertexFormats,Vector3)
ComputeBoundingSphere メソッド
使用例
- 境界球の生成
メッシュの境界球を算出する。
定義
Visual Basic | Public Shared Function ComputeBoundingSphere( _ ByVal pointsFvf As Array, _ ByVal vertexFormat As VertexFormats, _ ByRef center As Vector3 _ ) As Single |
C# | public static float ComputeBoundingSphere( Array pointsFvf, VertexFormats vertexFormat, out Vector3 center ); |
Managed C++ | public: static float ComputeBoundingSphere( Array* pointsFvf, VertexFormats vertexFormat, Vector3* center ); |
JScript | public static function ComputeBoundingSphere( pointsFvf : Array, vertexFormat : VertexFormats, center : Vector3 ) : float; |
パラメータ
pointsFvf | System.Array. |
vertexFormat | Microsoft.DirectX.Direct3D.VertexFormats. |
center | Microsoft.DirectX.Vector3. |
戻り値
System.Single.
使用例
境界球の生成
この例では、Geometry.ComputeBoundingSphere メソッドを使って、3D オブジェクトの周りに簡単な境界球を生成する方法を示す。3D グラフィックでは、境界球にはさまざまな使い方がある。たとえば、ある 3D オブジェクトが別のオブジェクトと交差するかどうかをテストするときに役に立つ。
次のサンプル コードでは、メッシュ オブジェクトの頂点データから頂点バッファを作成している。次に、新しい頂点バッファをロックし、その頂点バッファに対して Geometry アルゴリズムを計算できるようにする。ComputeBoundingSphere の出力は、メッシュ オブジェクトの中心から最も遠い端までの半径である。
using Microsoft.DirectX.Direct3D;
protected Device device; // The rendering device
device = null;
Mesh pMesh = null;
GraphicsStream adj = null;
ExtendedMaterial[] mtrl = null;
MeshFlags i32BitFlag;
float objectRadius = 0.0f; // Radius of bounding sphere of object
// Load the mesh from the specified file.
pMesh = Mesh.FromFile("tiger.x", MeshFlags.Managed, device,
out adj,out mtrl);
i32BitFlag = pMesh.Options.Use32Bit ? MeshFlags.Use32Bit : 0;
// Retrieve the vertex buffer data in the mesh object
VertexBuffer vb = pMesh.VertexBuffer;
// Lock the vertex buffer to generate a simple bounding sphere
GraphicsStream vertexData = vb.Lock(0, 0, LockFlags.NoSystemLock);
objectRadius = Geometry.ComputeBoundingSphere(vertexData,
pMesh.NumberVertices,
pMesh.VertexFormat,
out objectCenter);
vb.Unlock();
vb.Dispose();
対象
© 2002 Microsoft Corporation. All rights reserved. Terms of use.