Skip to main content
GameDev.net gamedev.net
🔒 Locked

mesh problem when its in its own cpp..

Started by Anddos Apr 13, 2007 at 2:19 AM 1 replies 450+ views
Original Post
Anddos
Anddos
ive got this function to load the mesh and i cant seem to make it show up on screen , if this code is in main then it works fine , some problem with the parameters thats not making it work right , SetMaterial and the rest is in RenderMesh(); in main... Code: #include "Globals.h" HRESULT LoadD3DMeshNew( IDirect3DDevice9* g_pDirect3DDevice, DWORD dwNumMaterials, LPD3DXMESH pMesh, D3DMATERIAL9* pMeshMaterials, LPDIRECT3DTEXTURE9* pMeshTextures ) { LPD3DXBUFFER pD3DXMtrlBuffer; if( FAILED( D3DXLoadMeshFromX( "airplane 2.x", D3DXMESH_SYSTEMMEM, g_pDirect3DDevice, NULL, &pD3DXMtrlBuffer, NULL, &dwNumMaterials, &pMesh ) ) ) { MessageBox(NULL, "Could not find tiger.x","Meshes.exe", MB_OK); return E_FAIL; } else { // MessageBox(NULL, "Loaded tiger.x","Meshes.exe", MB_OK); } // We need to extract the material properties and texture names from the // pD3DXMtrlBuffer D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); pMeshMaterials = new D3DMATERIAL9[dwNumMaterials]; pMeshTextures = new LPDIRECT3DTEXTURE9[dwNumMaterials]; char buf[64]; sprintf(buf , "%s %d" , "dwNumMaterials is" , dwNumMaterials); // MessageBox(NULL, buf,buf, MB_OK); for( DWORD i=0; i = d3dxMaterials.MatD3D; // Set the ambient color for the material (D3DX does not do this) pMeshMaterials.Ambient = pMeshMaterials.Diffuse; // Create the texture if( FAILED( D3DXCreateTextureFromFile( g_pDirect3DDevice, d3dxMaterials.pTextureFilename, &pMeshTextures ) ) ) { pMeshTextures = NULL; } } // Done with the material buffer pD3DXMtrlBuffer->Release(); return S_OK; }
:)
jaafit
jaafit
two things: one,use source tags (see faq). two, show us the main function too because there just isn't enough here to go on.
Anddos
Anddos


void RenderMesh()
{

for( DWORD i=0; i<dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pDirect3DDevice->SetMaterial( &pMeshMaterials );
g_pDirect3DDevice->SetTexture( 0, pMeshTextures );
//InitMatrices();
InitMatricesNew(g_pDirect3DDevice,
Spin,
Back,
Right ,
EyeVecFloat ,
Up ,
Spin2,
Camara,
Camera2,
0.0f
);
// Draw the mesh subset
pMesh->DrawSubset( i );
}


<!--EDIT--><!--/EDIT-->[Edited by - Anddos on April 13, 2007 3:40:25 AM]<!--EDIT--><!--/EDIT-->
:)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.