Microsoft DirectX 8.1 (Visual Basic)

D3DX8.LoadMeshFromX

Loads a mesh from a Microsoft® DirectX® X file.

object.LoadMeshFromX( _ 
    FileName As String, _ 
    Options As Long, _ 
    Device As Direct3DDevice8, _ 
    RetAdjacency As D3DXBuffer, _ 
    RetMaterials As D3DXBuffer, _ 
    RetMaterialCount As Long) As D3DXMesh

Parts

object
Object expression that resolves to a D3DX8 object.
FileName
String that specifies the name of the DirectX file to load.
Options
A combination of one or more flags defined by the CONST_D3DXMESH enumeration, specifying creation options for the mesh.
Device
Direct3DDevice8 object, the device associated with the mesh.
RetAdjacency
D3DXBuffer object. When the method returns, this parameter is filled with an array of three Long values per face that specify the three neighbors for each face in the mesh.
RetMaterials
D3DXBuffer object. When this method returns, this parameter is filled with an array of D3DXMATERIAL types, containing information saved in the DirectX file.
RetMaterialCount
Number of D3DXMATERIAL types in the RetMaterials array, when the method returns.

Return Values

D3DXMesh object representing the loaded mesh.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

The following code fragment shows how to call LoadMeshFromX.

Dim g_device As Direct3DDevice8

Dim g_d3dx As D3DX8
Set g_d3dx = New D3DX8

Dim mesh As D3DXMesh
Dim matBuf As D3DXBuffer

' The following assumes that FileName, g_device, matBuf, and matCount have been set to valid values.
Set mesh = g_d3dx.LoadMeshFromX(FileName, D3DXMESH_MANAGED, g_device, Nothing, matBuf, matCount)

When LoadMeshFromX returns, matBuf and matCount have been set to valid values.

Note  All the meshes in the file are collapsed into one output mesh. If the file contains a frame hierarchy, all the transformations are applied to the mesh.

See Also

D3DX8.BufferGetMaterial, D3DX8.BufferGetTextureName