Geometry Class |
Language: |
Contains miscellaneous math-related functions.
Visual Basic NotInheritable MustInherit Public Class Geometry
Inherits ObjectC# public abstract sealed class Geometry : Object C++ public ref class Geometry abstract sealed : Object JScript public final abstract class Geometry extends Object
ObjectGeometry
Compute a Bounding Sphere from a Mesh
This example shows how to generate a simple bounding sphere around a 3-D object, using the Geometry.ComputeBoundingSphere method. A bounding sphere has many possible uses in 3-D graphics; for example, to help test whether one 3-D object intersects with another.
In the following C# code example, a vertex buffer is created from the vertex data of the mesh object. The new vertex buffer is then locked so that Geometry algorithms can be computed on it. The output of the ComputeBoundingSphere is the radius from the center to the farthest extremity of the mesh object. The mesh object is assumed to be a valid mesh loaded with Mesh.FromFile.
[C#]
float objectRadius = 0.0f; Vector3 objectCenter = new Vector3(); using (VertexBuffer vb = Mesh.VertexBuffer) { GraphicsStream vertexData = vb.Lock(0, 0, LockFlags.None); objectRadius = Geometry.ComputeBoundingSphere(vertexData, mesh.NumberVertices, mesh.VertexFormat, out objectCenter); vb.Unlock(); }
Namespace Microsoft.DirectX.Direct3D Assembly Microsoft.DirectX.Direct3DX (microsoft.directx.direct3dx.dll) Strong Name Microsoft.DirectX.Direct3DX, Version=1.0.900.0, Culture=neutral, PublicKeyToken=d3231b57b74a1492
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center