Errors while loading a custom file format

Started by
9 comments, last by pachesantiago 12 years, 3 months ago
I try using WeldMesh and it dosent works(the same error)
Then I try using CleanMesh afther WeldMesh and CleanMesh returns [color=#2A2A2A]D3DERR_INVALIDCALL.
[color=#2A2A2A]

[color=#2A2A2A]Here is the code:
[color=#2A2A2A]

[font="'Segoe UI"][color="#2a2a2a"]if(bypass_materials == true)[/font]
[font="'Segoe UI"][color="#2a2a2a"] {[/font]
[font="'Segoe UI"][color="#2a2a2a"] inFile.close();[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] DWORD* Adjacency = new DWORD[Mesh->GetNumFaces() * 3];[/font]
[font="'Segoe UI"][color="#2a2a2a"] DWORD* AdjacencyOut = new DWORD[Mesh->GetNumFaces() * 3];[/font]
[font="'Segoe UI"][color="#2a2a2a"] ID3DXMesh* MeshCorrected = nullptr;[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXWELDEPSILONS Epsilons;[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] // Set epsilon values[/font]
[font="'Segoe UI"][color="#2a2a2a"] Epsilons.Normal = 0.001;[/font]
[font="'Segoe UI"][color="#2a2a2a"] Epsilons.Position = 0.1;[/font]
[font="'Segoe UI"][color="#2a2a2a"] Mesh->GenerateAdjacency(0.001,Adjacency);[/font]
[font="'Segoe UI"][color="#2a2a2a"]#ifdef debug[/font]
[font="'Segoe UI"][color="#2a2a2a"] CheckHR(D3DXWeldVertices(Mesh,D3DXWELDEPSILONS_DONOTSPLIT,NULL,Adjacency,AdjacencyOut,nullptr,nullptr));[/font]
[font="'Segoe UI"][color="#2a2a2a"] CheckHR(D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr));[/font]
[font="'Segoe UI"][color="#2a2a2a"]#endif[/font]
[font="'Segoe UI"][color="#2a2a2a"]#ifndef debug[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXWeldVertices(MeshCorrected,D3DXWELDEPSILONS_DONOTSPLIT,NULL,AdjacencyOut,nullptr,nullptr,nullptr);[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr);[/font]
[font="'Segoe UI"][color="#2a2a2a"]#endif[/font]
[font="'Segoe UI"][color="#2a2a2a"] delete Adjacency;[/font]
[font="'Segoe UI"][color="#2a2a2a"] delete AdjacencyOut;[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] MakeObjectFromMemoryIndirect(ID,MeshCorrected,&temp,Use_Default_Material,FVF);[/font]
[font="'Segoe UI"][color="#2a2a2a"] MeshBufer.push_back(temp);[/font]
[font="'Segoe UI"][color="#2a2a2a"] objects_to_render_count_X3D.push_back(tempC);[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] return Completed;[/font]
[font="'Segoe UI"][color="#2a2a2a"] }[/font]
[font="'Segoe UI"][color="#2a2a2a"] else[/font]
[font="'Segoe UI"][color="#2a2a2a"] {[/font]
[font="'Segoe UI"][color="#2a2a2a"] DWORD material_count;[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] inFile.getline(temp_data,128);[/font]
[font="'Segoe UI"][color="#2a2a2a"] strtok(temp_data," ");[/font]
[font="'Segoe UI"][color="#2a2a2a"] material_count = strtoul(strtok(NULL," "),NULL,10);[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] char material_location[256];[/font]
[font="'Segoe UI"][color="#2a2a2a"] if(material_count != 0)[/font]
[font="'Segoe UI"][color="#2a2a2a"] {[/font]
[font="'Segoe UI"][color="#2a2a2a"] for(DWORD sentinel = 0;sentinel <= material_count AND material_count != 0;sentinel++)[/font]
[font="'Segoe UI"][color="#2a2a2a"] {[/font]
[font="'Segoe UI"][color="#2a2a2a"] inFile.getline(material_location,256);[/font]
[font="'Segoe UI"][color="#2a2a2a"] strtok(temp_data," ");[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] LoadMaterial(strtok(NULL," "));[/font]
[font="'Segoe UI"][color="#2a2a2a"] temp.MaterialsIDs.push_back(GetLastMaterialID());[/font]
[font="'Segoe UI"][color="#2a2a2a"] }[/font]
[font="'Segoe UI"][color="#2a2a2a"] }[/font]
[font="'Segoe UI"][color="#2a2a2a"] inFile.close();[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] DWORD* Adjacency = new DWORD[Mesh->GetNumFaces() * 3];[/font]
[font="'Segoe UI"][color="#2a2a2a"] DWORD* AdjacencyOut = new DWORD[Mesh->GetNumFaces() * 3];[/font]
[font="'Segoe UI"][color="#2a2a2a"] ID3DXMesh* MeshCorrected = nullptr;[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXWELDEPSILONS Epsilons;[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] // Set epsilon values[/font]
[font="'Segoe UI"][color="#2a2a2a"] Epsilons.Normal = 0.001;[/font]
[font="'Segoe UI"][color="#2a2a2a"] Epsilons.Position = 0.1;[/font]
[font="'Segoe UI"][color="#2a2a2a"] Mesh->GenerateAdjacency(0.001,Adjacency);[/font]
[font="'Segoe UI"][color="#2a2a2a"]#ifdef debug[/font]
[font="'Segoe UI"][color="#2a2a2a"] CheckHR(D3DXWeldVertices(Mesh,D3DXWELDEPSILONS_DONOTSPLIT,NULL,Adjacency,AdjacencyOut,nullptr,nullptr));[/font]
[font="'Segoe UI"][color="#2a2a2a"] CheckHR(D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr));[/font]
[font="'Segoe UI"][color="#2a2a2a"]#endif[/font]
[font="'Segoe UI"][color="#2a2a2a"]#ifndef debug[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXWeldVertices(MeshCorrected,D3DXWELDEPSILONS_DONOTSPLIT,NULL,AdjacencyOut,nullptr,nullptr,nullptr);[/font]
[font="'Segoe UI"][color="#2a2a2a"] D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr);[/font]
[font="'Segoe UI"][color="#2a2a2a"]#endif[/font]
[font="'Segoe UI"][color="#2a2a2a"] delete Adjacency;[/font]
[font="'Segoe UI"][color="#2a2a2a"] delete AdjacencyOut;[/font]
[font="'Segoe UI"][color="#2a2a2a"]
[/font]
[font="'Segoe UI"][color="#2a2a2a"] MakeObjectFromMemoryIndirect(ID,MeshCorrected,&temp,Use_Default_Material,FVF);[/font]
[font="'Segoe UI"][color="#2a2a2a"] MeshBufer.push_back(temp);[/font]
[font="'Segoe UI"][color="#2a2a2a"] objects_to_render_count_X3D.push_back(tempC);[/font]
[font="'Segoe UI"][color="#2a2a2a"] return Completed;[/font]
[font="'Segoe UI"][color="#2a2a2a"] }[/font]
[color=#2A2A2A]

Advertisement
I try using WeldMesh and it dosent works(the same error)
Then I try using CleanMesh afther WeldMesh and CleanMesh returns D3DERR_INVALIDCALL.


Here is the code:

if(bypass_materials == true)
{
inFile.close();

DWORD* Adjacency = new DWORD[Mesh->GetNumFaces() * 3];
DWORD* AdjacencyOut = new DWORD[Mesh->GetNumFaces() * 3];
ID3DXMesh* MeshCorrected = nullptr;
D3DXWELDEPSILONS Epsilons;

// Set epsilon values
Epsilons.Normal = 0.001;
Epsilons.Position = 0.1;
Mesh->GenerateAdjacency(0.001,Adjacency);
#ifdef debug
CheckHR(D3DXWeldVertices(Mesh,D3DXWELDEPSILONS_DONOTSPLIT,NULL,Adjacency,AdjacencyOut,nullptr,nullptr));
CheckHR(D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr));
#endif
#ifndef debug
D3DXWeldVertices(MeshCorrected,D3DXWELDEPSILONS_DONOTSPLIT,NULL,AdjacencyOut,nullptr,nullptr,nullptr);
D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr);
#endif
delete Adjacency;
delete AdjacencyOut;

MakeObjectFromMemoryIndirect(ID,MeshCorrected,&temp,Use_Default_Material,FVF);
MeshBufer.push_back(temp);
objects_to_render_count_X3D.push_back(tempC);

return Completed;
}
else
{
DWORD material_count;

inFile.getline(temp_data,128);
strtok(temp_data," ");
material_count = strtoul(strtok(NULL," "),NULL,10);

char material_location[256];
if(material_count != 0)
{
for(DWORD sentinel = 0;sentinel <= material_count AND material_count != 0;sentinel++)
{
inFile.getline(material_location,256);
strtok(temp_data," ");

LoadMaterial(strtok(NULL," "));
temp.MaterialsIDs.push_back(GetLastMaterialID());
}
}
inFile.close();

DWORD* Adjacency = new DWORD[Mesh->GetNumFaces() * 3];
DWORD* AdjacencyOut = new DWORD[Mesh->GetNumFaces() * 3];
ID3DXMesh* MeshCorrected = nullptr;
D3DXWELDEPSILONS Epsilons;

// Set epsilon values
Epsilons.Normal = 0.001;
Epsilons.Position = 0.1;
Mesh->GenerateAdjacency(0.001,Adjacency);
#ifdef debug
CheckHR(D3DXWeldVertices(Mesh,D3DXWELDEPSILONS_DONOTSPLIT,NULL,Adjacency,AdjacencyOut,nullptr,nullptr));
CheckHR(D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr));
#endif
#ifndef debug
D3DXWeldVertices(MeshCorrected,D3DXWELDEPSILONS_DONOTSPLIT,NULL,AdjacencyOut,nullptr,nullptr,nullptr);
D3DXCleanMesh(D3DXCLEAN_OPTIMIZATION,Mesh,AdjacencyOut,&MeshCorrected,nullptr,nullptr);
#endif
delete Adjacency;
delete AdjacencyOut;

MakeObjectFromMemoryIndirect(ID,MeshCorrected,&temp,Use_Default_Material,FVF);
MeshBufer.push_back(temp);
objects_to_render_count_X3D.push_back(tempC);
return Completed;
}
any ideas?

This topic is closed to new replies.

Advertisement