strange .x problem
I am trying to write a wrapper to load and render .x files, so I spend the last couple of hours writing it and finally it compiles, but when I run it, I get the funny green and pink lines. I went and checked the debugger, and it says this:
D3DXOF:800: syntax error near "0"
D3DXOF:XStreamRead::GetNextObject: Error while parsing stream
D3DXOF:GetNextObject: Parse error.
Direct3D8: (ERROR) :Cannot invert view matrix
"
"
"....
I''m assuming that this is a runtime error, but I dont exactly know whats going on. I can post some code, but I want to see if anyone has any ideas before I do. Thanks.
Sounds a little like the X file is corrupt, are you using one of the x files in the media library contained with the DirectX SDK, if not, try one of them first, as they are all tested. (I would hope
The first error is most likely from an unregistered template while the second error is because you are trying to invert or transpose a matrix that can''t be transposed or inverted (check the SDK docs for info).
Jim Adams
Jim Adams
I had problems like that when i was loading the X files but most of the time the X file was corrupt so i had to re convert it from 3ds to X again read the converter info it helps to know what it can do
Well, you were right. My file was corrupt...I was using Milkshape to export the file, but once I tried loading a .x file using the common files utilities, and then milkshapes files worked fine. Now to go look at this whole matrix thing....
Well, I have returned from the SDK and cannot think of anything that could cause this. I a have not inverted any matrices in all of my code unless some of the .x functions are doing it. Any ideas? I post some code if you want...its 35 lines at the most. Thanks.
No one? Well, I will post some code anyways. Here is the code I am using to load and render the mesh:
And this to render it:
As you can see, most of this code was ripped from tutorial 6 from the SDK. As far as I can tell, I''m not doing anything with the matrices...The rest of the code works fine when I don''t do anything with the models. Any suggestions would be appreciated. Thanks.
HRESULT CX::CreateModel( LPDIRECT3DDEVICE8 pDevice, char *fileName ){ LPD3DXBUFFER pD3DXMtrlBuffer; // Material buffer // Load the mesh from the specified file if( FAILED( D3DXLoadMeshFromX( fileName, D3DXMESH_SYSTEMMEM, pDevice, NULL, &pD3DXMtrlBuffer, &m_dwNumMaterials, &m_pMesh ) ) ) { return E_FAIL; } // Get material properties m_d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); m_pMeshMaterials = new D3DMATERIAL8[m_dwNumMaterials]; for( DWORD i=0; i<m_dwNumMaterials; i++ ) { // Copy the material m_pMeshMaterials[i] = m_d3dxMaterials[i].MatD3D; // Set the ambient color for the material (D3DX does not do this) m_pMeshMaterials[i].Ambient = m_pMeshMaterials[i].Diffuse; } // Done with the material buffer pD3DXMtrlBuffer->Release(); return S_OK;}
And this to render it:
HRESULT CX::Render( LPDIRECT3DDEVICE8 pDevice ){ for( DWORD i=0; i<m_dwNumMaterials; i++ ) { // Set the material for this subset pDevice->SetMaterial( &m_pMeshMaterials[i] ); // Draw the mesh subset m_pMesh->DrawSubset( i ); } return S_OK;}
As you can see, most of this code was ripped from tutorial 6 from the SDK. As far as I can tell, I''m not doing anything with the matrices...The rest of the code works fine when I don''t do anything with the models. Any suggestions would be appreciated. Thanks.
You might want to show the code where you are setting the projection, view, and world transformation matrices.
Jim Adams
Jim Adams
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement