Jump to content
  • Advertisement


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


Multiple Layers/Textures Lightwave Object -> .X Troubles

This topic is 5269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''ve been going at game programming for a bit now, but now I''ve hit a little snag. I just made a house in Lightwave 7.5, and exported it to a .X file in Deep Exploration. When I loaded it into my .X viewer, only the brick walls were textured (1st layer in Lightwave, too), I checked the .X file out in Deep Exploration, and it gave me this frame heirachy Frm `object7 `Frm6 `object6 `Frm3 `object4 `Frm1 `object2 I''m basically using the DirectX 8.1 SDK source to load the .X file in [see below] Any help would be much appreciated. #include "global.h" #include "core.h" DWORD End; float theta = -15.0f; float alpha = 1.0f; float beta = 150.0f; LPD3DXMESH g_pMesh = NULL; // Our mesh object in sysmem D3DMATERIAL8* g_pMeshMaterials = NULL; // Materials for our mesh LPDIRECT3DTEXTURE8* g_pMeshTextures = NULL; // Textures for our mesh DWORD g_dwNumMaterials = 0L; // Number of mesh materials LPD3DXBUFFER pD3DXMtrlBuffer; struct CUSTOMVERTEX { FLOAT x, y, z; // The untransformed position for the vertex. DWORD color; // The vertex color. }; void Frame(); void LoadMesh(char* Filename); cApplication App; cGraphics Graphics; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iShowCmd) { App.m_hInst = hInstance; App.Run(); Graphics.Init(App, App.m_hWnd); LoadMesh(); while(App.msg.message != WM_QUIT) { if(PeekMessage(&App.msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&App.msg); DispatchMessage(&App.msg); } Frame(); End = GetTickCount(); //while((GetTickCount() - End) < 33); } return(0); } void Frame() { Graphics.GetDeviceCOM()->SetRenderState( D3DRS_AMBIENT, 0xffffffff ); if(KEY_DOWN(VK_UP)) theta+=0.1f; else if(KEY_DOWN(VK_DOWN)) theta-=0.1f; else if(KEY_DOWN(VK_LEFT)) beta+=0.1f; else if(KEY_DOWN(VK_RIGHT)) beta-=0.1f; else if(KEY_DOWN(VK_INSERT)) alpha+=0.1f; else if(KEY_DOWN(VK_DELETE)) alpha-=0.1f; else return; D3DXMATRIX matWorld; D3DXMATRIX matView; D3DXMATRIX matProj; D3DXMatrixRotationY(&matWorld, beta); D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3( 0.0f, 3.0f, theta), &D3DXVECTOR3(0.0f, alpha, 0.0f), &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f); Graphics.BeginScene(); Graphics.ClearZ(); for( DWORD i=0; iSetMaterial( &g_pMeshMaterials ); Graphics.GetDeviceCOM()->SetTexture( 0, g_pMeshTextures[i] ); // Draw the mesh subset g_pMesh->DrawSubset( i ); } Graphics.GetDeviceCOM()->SetTransform(D3DTS_WORLD, &matWorld); Graphics.GetDeviceCOM()->SetTransform( D3DTS_VIEW, &matView ); Graphics.GetDeviceCOM()->SetTransform( D3DTS_PROJECTION, &matProj ); Graphics.EndScene(); Graphics.Display(); } void LoadMesh(char* Filename) { if(FAILED(D3DXLoadMeshFromX(Filename, D3DXMESH_SYSTEMMEM, Graphics.GetDeviceCOM(), NULL, &pD3DXMtrlBuffer, &g_dwNumMaterials, &g_pMesh))) PostQuitMessage(0); D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); g_pMeshMaterials = new D3DMATERIAL8[g_dwNumMaterials]; g_pMeshTextures = new LPDIRECT3DTEXTURE8[g_dwNumMaterials]; for( DWORD i=0; iRelease(); } I''''m a signature virus, copy me into your signature and help me spread!

Share this post

Link to post
Share on other sites
It looked OK in their mesh viewer, and I just copied some of their source from their Enhanced Mesh sample and now i''m slowly getting there. At least now everything is textured, but albiet with the wrong texture... all brick.bmp.
Oh well... thanks anyway

I''''m a signature virus, copy me into your signature and help me spread!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!