Jump to content
  • Advertisement


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



This topic is 5522 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 everybody. I am working on getting all the vertex information out of a model loaded by DX. I am finally getting close, but i have a bug somewere that does not alow this to work.. Can anybody see what i am doing wrong. Thanks in advanced for any help. LPD3DXMESH mMeshBuffer; hr = D3DXLoadMeshFromX( fileName, D3DXMESH_DYNAMIC, device, NULL, NULL, NULL, &mMeshBuffer // The mesh buffer ); if (FAILED(hr)) { mApp->getAppWindow()->messageBox((char*)DXGetErrorString8(hr), "Mesh loading error"); } DWORD numVerts = mMeshBuffer->GetNumVertices(); DWORD numFaces = mMeshBuffer->GetNumFaces(); float* MeshArray = new float[numVerts]; float* TextureArray = new float[numFaces*3*2]; unsigned short* IndexArray = new unsigned short[numFaces*3]; LPDIRECT3DVERTEXBUFFER8 pVBuf; if (SUCCEEDED(mMeshBuffer->GetVertexBuffer(&pVBuf))) { CUSTOMVERTEX *pVert; if (SUCCEEDED(pVBuf->Lock(0,0,(BYTE **) &pVert,D3DLOCK_DISCARD))) { int meshCount = 0; int textureCount = 0; for (unsigned int i=0;ix; MeshArray[meshCount++] = pVert->y; MeshArray[meshCount++] = pVert->z; TextureArray[textureCount++] = pVert->tu; TextureArray[textureCount++] = pVert->tv; pVert++; } pVBuf->Unlock(); } pVBuf->Release(); } LPDIRECT3DINDEXBUFFER8 pIndBuf; hr = mMeshBuffer->GetIndexBuffer(&pIndBuf); if ( FAILED(hr)) { mApp->getAppWindow()->messageBox((char*)DXGetErrorString8(hr), "Mesh loading error"); } else { WORD *pInd; if (SUCCEEDED(pIndBuf->Lock(0, 0 ,(BYTE **)&pInd, D3DLOCK_DISCARD))) { for (unsigned int i=0;iUnlock(); } pIndBuf->Release(); } mesh->setVertexList(&MeshArray[0], numVerts); mesh->setTextureCoord(&TextureArray[0]); mesh->setIndexList(&IndexArray[0], numFaces*3); mesh->setTextureId( mApp->getImageManager()->LoadImage("textures/tiger.bmp") ); The problem seem to be something related to the indicies. Thanks again.. Ben

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!