Jump to content
  • Advertisement

Archived

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

Kawahee

Problems with .X

This topic is 5384 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; i { // Set the material and texture for this subset Graphics.GetDeviceCOM()->SetMaterial( &g_pMeshMaterials ); Graphics.GetDeviceCOM()->SetTexture( 0, g_pMeshTextures ); // 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; i { // Copy the material g_pMeshMaterials[i] = d3dxMaterials[i].MatD3D; // Set the ambient color for the material (D3DX does not do this) g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse; // Create the texture if( FAILED( D3DXCreateTextureFromFile( Graphics.GetDeviceCOM(), d3dxMaterials[i].pTextureFilename, &g_pMeshTextures[i] ) ) ) { g_pMeshTextures[i] = NULL; } } pD3DXMtrlBuffer->Release(); } 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
In my experience with LW (from a programming perspective) I haven''t found many exporters that convert LW features into the .X file format very well. You usually need to restrict your artists very severely to get the expected .X format that you need. Perhaps the next version of LW will be a little more game-developer friendly.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yeah, thanks.
I had to export it as a no frames object, and I also fixed up my loader code a bit.

----------------------------------------------------------------

I''m a signature virus, copy me into your signature to help me grow.

----------------------------------------------------------------

You don''t have to be a Leanardo to draw a circle, you can use a compass.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!