   Help on my DX engine
  Hey guys.  I'm writing my own DX graphics engine and getting some odd results.  Wondering if anyone might have some suggestions.  My design works like this:gfx namspace contains all graphics classes.Resources (wrappers for the D3D versions):  gfx::cShader  gfx::cTexture  gfx::cMesh  gfx::cMaterialgfx::cEngine class manages engine components (camera, window, etc)gfx::cCamera class manages view and projection transforms like this: in the Update function (called each frame) it computes the projection and view matrices and sets them to all loaded shaders.gfx::cWindow class manages Win32 and D3D initialization, alt+tabbing, etc.My meshes currently only support loading from .X files, which I've used before.  I'm currently loading the dwarf.x mesh to test.  It loads the mesh into the D3DXMESH and loads the materials into a material buffer, then loops through the material buffer and creates each material with the values loaded.  The materials in my engine contain the textures that material uses, so the engine then takes the filename in the D3DXMATERIAL it is loading from (the materialbuffer) and loads that texture (LPDIRECT3DTEXTURE9) into the material.  These are stored in an array that the attribute buffer indexes (like normal).  My mesh rendering looks like this:gfx::cMesh::Render (const cMatrix44& matWorld){   iUInt numPasses = 0;shader.SetWorldMatrix(matWorld);shader.Begin(numPasses);for (iUInt i=0; i<numPasses; ++i){shader.BeginPass(i);for (iUInt j=0; j<nMaterials; ++j){shader.SetMaterial(pMaterials[j]);shader.CommitChanges();pD3DMesh->DrawSubset(j);}shader.EndPass();}shader.End();}shader.SetMaterial() looks like this:Each shader keeps a reference to the last loaded texture.  If the next material uses the same texture as the last one, it doesn't send the texture data to the shader.void SetMaterial(const cMaterial& mat){pD3DEffect->SetFloatArray("mAmb", (iFloat*)&mat.ambient,  4);pD3DEffect->SetFloatArray("mDif", (iFloat*)&mat.diffuse,  4);pD3DEffect->SetFloatArray("mSpe", (iFloat*)&mat.specular, 4);pD3DEffect->SetFloatArray("mEmi", (iFloat*)&mat.emissive, 4);pD3DEffect->SetFloat("mShi", mat.shine);if (texturemap != mat.texturemap){texturemap = mat.texturemap;pD3DEffect->SetTexture ("texMap", mat.texturemap);}}My resource classes contain cast operators to the D3D types they wrap, so passing them directly into a function expecting their D3D type should call the cast operator right?Anyways, here is my result from this design.ScreenieIt obviously loads the mesh, and and the other resource load, because any load errors send an error message to the debug window on my compiler, and there are none.  At this point I'm at a loss as to what is wrong.  Any suggestions?   
  Any ideas?  I am thinking that the problem is my near / far clipping planes.  It looks like it takes a 2D "slice" and draws that.  However, I have had that problem before and it still applied textures and materials.  And I double checked my near / far distances and they are set to 0.18f and 100.0f respectively.  The projection matrix is updated using D3DXMatrixPerspectiveLH() with these values each frame.ANY suggestions would be greatly appreciated...   ;Quote:Original post by EnoschAny ideas?  I am thinking that the problem is my near / far clipping planes.  It looks like it takes a 2D "slice" and draws that.  However, I have had that problem before and it still applied textures and materials.  And I double checked my near / far distances and they are set to 0.18f and 100.0f respectively.  The projection matrix is updated using D3DXMatrixPerspectiveLH() with these values each frame.ANY suggestions would be greatly appreciated...I'm not really sure what problem you're having.  From your screenshot I'm guessing that it shouldn't be in black and white?  Or is that your shader?How come you're updating your projection matrix each frame?Have you tired running your program through PIX and going step by step through the render pipeline?   