Solved

D3DXComputeBoundingBox problem

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

621 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