Archived

This topic is now archived and is closed to further replies.

beowulf

mesh problem

Recommended Posts

Hi I wonder if anyone could help me with this. This following class works and displays the tiger.x (comes with sdk somewhere..) textured model perfectly, however when I try and load a untextured (but coloured) model converted to X with conv3ds.exe the model just doesnt show. The converted model works perfectly when I load them with the mesh samples. Looking at the mesh samples I just dont see why it doesnt work with my code as well.. (g_d3d_device is my IDirect3DDevice8) class ModelWrapper { private: DWORD numberOfMaterials; LPD3DXMESH myMesh; D3DMATERIAL8* myMaterials; LPDIRECT3DTEXTURE8* myTextures; public: ModelWrapper() { myMesh=0; numberOfMaterials=0; myMaterials=0; myTextures=0; } bool LoadFromFile(AnsiString filename) { LPD3DXBUFFER pD3DXMtrlBuffer; if( FAILED( D3DXLoadMeshFromX( filename.c_str(), D3DXMESH_SYSTEMMEM, g_d3d_device, NULL, &pD3DXMtrlBuffer, &numberOfMaterials, &myMesh ) ) ) return false; D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); myMaterials = new D3DMATERIAL8[numberOfMaterials]; myTextures = new LPDIRECT3DTEXTURE8[numberOfMaterials]; ZeroMemory(myMaterials,sizeof(myMaterials)); ZeroMemory(myTextures,sizeof(myTextures)); for (DWORD i = 0; i(lessthansign)numberOfMaterials; i++) { myMaterials = d3dxMaterials[i].MatD3D; myMaterials[i].Ambient = myMaterials[i].Diffuse; //load textures for this model, skide VC! if (FAILED(D3DXCreateTextureFromFile(g_d3d_device, d3dxMaterials[i].pTextureFilename, &myTextures[i]))) { myTextures[i] = NULL; } } pD3DXMtrlBuffer->Release(); return true; } void Draw() { for (DWORD i = 0; i(lessthansign)numberOfMaterials; i++) { g_d3d_device->SetMaterial( &myMaterials[i] ); g_d3d_device->SetTexture( 0, myTextures[i] ); myMesh->DrawSubset( i ); } } ~ModelWrapper() { //cleans-up } }; [edited by - beowulf on September 3, 2002 8:17:52 AM]

Share this post


Link to post
Share on other sites
Ok, i converted tutorial 6: meshes to borland c++ 5.0 to see if it works there.. it doesnt. Only works in the samples :/ suppose I will have to dwelve into those ms classes to see what the difference is. Could it be that I have to calculate normals for it?

Share this post


Link to post
Share on other sites
r u settin the right world matrices?
for instance, the model u have built may be of a very high scale (huge dimensions compared to tiger.x) and u maybe using the same world matrix as u did with tiger, and well the result...u dont see anythin

Hope this helps. Write back if it doesnt help

Later,
Raptor

Share this post


Link to post
Share on other sites
OMG you are right! stupid me LOL

I can now see my models after I scaled the model by factor 100 with conv3ds :-) Tho I think I need to use a slitghly lower factor.. like 50.

Share this post


Link to post
Share on other sites