Solved

D3DXComputeBoundingBox problem

Posted on 2002-07-22
3
574 Views
Last Modified: 2013-12-08
has anyone had problems with this method - i am using directX 8 and trying to compute the bounding box from a file mesh.  I dont get any errors in the methods but the returned vector dimensions do not add up.

     LPDIRECT3DVERTEXBUFFER8 vertBuf = NULL;
     LPD3DXMESH m_pLocalMesh = NULL;
     BYTE* pVertices;

     device = dev;

     if (FAILED(frame.m_pMesh->Create( device, const_cast<LPSTR>(xFileName) )))
          return false;
     m_pLocalMesh = frame.m_pMesh->GetSysMemMesh();
     DWORD fvf = m_pLocalMesh->GetFVF();
     DWORD numVert = m_pLocalMesh->GetNumVertices();
     
     HRESULT hr = m_pLocalMesh->GetVertexBuffer(&vertBuf);
     if (FAILED(hr)) MessageBox(NULL,"BAD","BAD",MB_OK);
     
     hr = vertBuf->Lock(0,0,&pVertices,D3DLOCK_NOSYSLOCK );
     if (FAILED(hr)) MessageBox(NULL,"BOX BAD", " BOX BAD",MB_OK);
     // compute the bounding box //
     hr = D3DXComputeBoundingBox(pVertices,numVert,fvf,&minVect,&maxVect);

this is my test code sample.
PS - minVect and maxVect are public vars D3DXVECTOR3
0
Comment
Question by:argVader
3 Comments
 
LVL 2

Accepted Solution

by:
kamarey earned 100 total points
ID: 7170338
Here is my code, it work perfect:

BYTE *pVertex;
D3DXVECTOR3 min;
D3DXVECTOR3 max;

m_pMesh->LockVertexBuffer(D3DLOCK_READONLY, (BYTE**)&pVertex);

D3DXComputeBoundingBox((VOID*)pVertex, m_pMesh->GetNumVertices(), m_pMesh->GetFVF(), &min, &max);

m_pMesh->UnlockVertexBuffer();

If your program still doesn't work, that meens you have wrong data in a vertex buffer.
0
 

Expert Comment

by:CleanupPing
ID: 9464750
argVader:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question