Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

D3DXComputeBoundingBox problem

Posted on 2002-07-22
3
Medium Priority
?
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
kamarey earned 400 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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