Microsoft DirectX 9.0 SDK Update (October 2004)

Geometry Class

Language:

Note: This documentation is preliminary and is subject to change.
How Do I...?

Contains miscellaneous math-related functions.

Definition

Visual Basic .NET NotInheritable Public Class Geometry
   Inherits Object 
C# public sealed class Geometry : Object
Managed C++ public __gc __sealed class Geometry  : public Object
JScript .NET public class Geometry extends Object

Members Table

Method Description
static (Shared in Visual Basic .NET) BoxBoundProbe Determines whether a ray intersects the volume of a bounding box.
static (Shared in Visual Basic .NET) ComputeBoundingBox Computes a coordinate axis-oriented bounding box.
static (Shared in Visual Basic .NET) ComputeBoundingSphere Computes a bounding sphere for a mesh.
static (Shared in Visual Basic .NET) DegreeToRadian Converts degrees to radians.
static (Shared in Visual Basic .NET) FresnelTerm Calculates the Fresnel term.
static (Shared in Visual Basic .NET) IntersectTri Computes the intersection of a ray and a triangle.
static (Shared in Visual Basic .NET) OptimizeFaces Optimizes a set of faces.
static (Shared in Visual Basic .NET) OptimizeVertices Optimizes a set of vertices.
static (Shared in Visual Basic .NET) RadianToDegree Converts radians to degrees.
static (Shared in Visual Basic .NET) SphereBoundProbe Determines whether a ray intersects the volume of a sphere's bounding box.

Inheritance Hierarchy

Object Leave Site
Geometry

How Do I...?

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(); }

Class Information

Namespace Microsoft.DirectX.Direct3D
Assembly Microsoft.DirectX.Direct3DX (microsoft.directx.direct3dx.dll)
Strong Name Microsoft.DirectX.Direct3DX,  Version=1.0.2902.0,  Culture=neutral,  PublicKeyToken=31bf3856ad364e35

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

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center