Original Post
Good Day Everyone,
As the subject says, I''ve got a slight problem with this function. I can create the mesh, and save this mesh to "mesh.x", but however when i try to load the mesh it can''t read the file. This is my code for loading and saving the mesh:
HRESULT MeshCreator::CreateMesh( LPDIRECT3DDEVICE8 Dev, LPDIRECT3DVERTEXBUFFER8 Vb )
{
HRESULT hr;
if( Dev )
{
Vb->Lock( 0, 0, (BYTE**)&MeshVertices, NULL );
MeshVertices[NumVertices].Create( 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB( 0, 0, 0, 255 ) );
MeshVertices[NumVertices++].Create( 0.0f, 0.0f, 1.0f, D3DCOLOR_ARGB( 0, 0, 0, 255 ) );
MeshVertices[NumVertices++].Create( 1.0f, 0.0f, 0.0f, D3DCOLOR_ARGB( 0, 0, 0, 255 ) );
Vb->Unlock( );
NumFaces = 1;
hr = D3DXCreateMeshFVF( 1, 3, D3DXMESH_VB_MANAGED,
D3DFVF_Mesh, Dev, &pMesh );
if( hr != D3D_OK )
{
Log( "Could not Create Mesh\n" );
if( hr == D3DERR_INVALIDCALL )
Log( "Invalid Call\n" );
return FALSE;
}
pMesh->GenerateAdjacency( 0.0, &pAdjacency );
hr = FVFCloneMesh( Dev, D3DFVF_Mesh );
if( hr != TRUE )
Log( "Could not Clone Mesh\n" );
return TRUE;
}
else
{
Log( "Device Failed\n" );
return FALSE;
}
}
HRESULT MeshCreator::SaveMeshToFile( LPSTR Filename, LPDIRECT3DDEVICE8 Dev )
{
if( Dev )
{
D3DXSaveMeshToX( Filename, pMesh, &pAdjacency, pMaterials, NumMaterials,
DXFILEFORMAT_BINARY | DXFILEFORMAT_COMPRESSED );
return TRUE;
}
else
{
Log( "Device failed\n" );
return FALSE;
}
}
As before i''ve been able to create the mesh object, but I currently can''t open up the file, the D3DXLoadMeshFromFile function returns. Thanks for the help in advance.
-Brad Hittle