Solved

D3DXComputeBoundingBox problem

Posted on 2002-07-22
3
564 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now