This是我的程序,用於顯示.x網格。我能夠顯示網格tiger.x但無法顯示ball.x。兩個網格之間有什麼區別?在代碼中我應該處理什麼?但是我可以使用標準網格查看器(如DirectX SDK附帶的網格查看器)查看這兩個網格。使用DirectX 9顯示網格 - 網格差異
謝謝。
This是我的程序,用於顯示.x網格。我能夠顯示網格tiger.x但無法顯示ball.x。兩個網格之間有什麼區別?在代碼中我應該處理什麼?但是我可以使用標準網格查看器(如DirectX SDK附帶的網格查看器)查看這兩個網格。使用DirectX 9顯示網格 - 網格差異
謝謝。
網格除了視圖外沒有任何問題。它放大顯示圖像。我使用以下矩陣投影圖像,並能夠正確地查看網格。
//Set Projection
D3DXMATRIXA16 matProj(1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,1.0,0.0,
0.0,0.0,0.0,150.0);
但無法顯示ball.x.
這個問題還不清楚。網狀物是否加載?它是否包含頂點/面?或者也許它崩潰的應用程序?或加載失敗?
這兩個網格有什麼區別?
區別在於第二個網格(ball.x)不包含「模板」。
即這部分:
template Header {
<3D82AB43-62DA-11cf-AB39-0020AF71E433>
WORD major;
WORD minor;
DWORD flags;
}
template Vector {
<3D82AB5E-62DA-11cf-AB39-0020AF71E433>
FLOAT x;
FLOAT y;
FLOAT z;
}
template Coords2d {
<F6F23F44-7686-11cf-8F52-0040333594A3>
FLOAT u;
FLOAT v;
}
template Matrix4x4 {
<F6F23F45-7686-11cf-8F52-0040333594A3>
array FLOAT matrix[16];
}
template ColorRGBA {
<35FF44E0-6C7C-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
FLOAT alpha;
}
template ColorRGB {
<D3E16E81-7835-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
}
template IndexedColor {
<1630B820-7842-11cf-8F52-0040333594A3>
DWORD index;
ColorRGBA indexColor;
}
template Boolean {
<4885AE61-78E8-11cf-8F52-0040333594A3>
WORD truefalse;
}
template Boolean2d {
<4885AE63-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template MaterialWrap {
<4885AE60-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template TextureFilename {
<A42790E1-7810-11cf-8F52-0040333594A3>
STRING filename;
}
template Material {
<3D82AB4D-62DA-11cf-AB39-0020AF71E433>
ColorRGBA faceColor;
FLOAT power;
ColorRGB specularColor;
ColorRGB emissiveColor;
[...]
}
template MeshFace {
<3D82AB5F-62DA-11cf-AB39-0020AF71E433>
DWORD nFaceVertexIndices;
array DWORD faceVertexIndices[nFaceVertexIndices];
}
template MeshFaceWraps {
<4885AE62-78E8-11cf-8F52-0040333594A3>
DWORD nFaceWrapValues;
Boolean2d faceWrapValues;
}
template MeshTextureCoords {
<F6F23F40-7686-11cf-8F52-0040333594A3>
DWORD nTextureCoords;
array Coords2d textureCoords[nTextureCoords];
}
template MeshMaterialList {
<F6F23F42-7686-11cf-8F52-0040333594A3>
DWORD nMaterials;
DWORD nFaceIndexes;
array DWORD faceIndexes[nFaceIndexes];
[Material]
}
template MeshNormals {
<F6F23F43-7686-11cf-8F52-0040333594A3>
DWORD nNormals;
array Vector normals[nNormals];
DWORD nFaceNormals;
array MeshFace faceNormals[nFaceNormals];
}
template MeshVertexColors {
<1630B821-7842-11cf-8F52-0040333594A3>
DWORD nVertexColors;
array IndexedColor vertexColors[nVertexColors];
}
template Mesh {
<3D82AB44-62DA-11cf-AB39-0020AF71E433>
DWORD nVertices;
array Vector vertices[nVertices];
DWORD nFaces;
array MeshFace faces[nFaces];
[...]
}
template FrameTransformMatrix {
<F6F23F41-7686-11cf-8F52-0040333594A3>
Matrix4x4 frameMatrix;
}
也就是說,模板/結構聲明。
此外,在ball.x網格是框架的層次結構的一部分。在tiger.x中,它不是,並且存儲在層次結構的頂層。
自從我上次直接使用* .x文件以來已經有一段時間了,但據我所知,您需要將所有「非標準」模板的模板包含到文件中。即如果文件使用的模板未使用ID3DXFile或IDirectXFile的RegisterTemplates方法註冊,那麼如果模板沒有寫在文件的開頭,則文件將不會加載。嘗試爲ball.x中的每個可疑結構添加模板定義,直到找到罪魁禍首。我會以「Header」開頭。
如果問題是由於層次結構,您需要嘗試另一種加載方法。
使用像DirectX SDK一樣的標準網格查看器。
AFAIK,網格查看器帶有源代碼。閱讀源代碼並查看它的工作原理。