Archived

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

webjeff

D3DXComputeBoundingBox

Recommended Posts

webjeff    241
I do this: D3DXComputeBoundingBox(pObject.pVertices,pObject[i].dwNumVerts,MESH_FVF_MODEL,&pMax,&pMin); OK, pMax looks ok, comes with values like 250,210,200 for xyz, but pMin are all NULL. How can that be? I''m using DirectX 8.1 Has anyone had any problems like this before? Thanks Jeff.

Share this post


Link to post
Share on other sites
neneboricua19    634
I can''t tell by your naming conventions so, are "pMax" and "pMin" pointers to D3DXVECTOR3 variables or are they actual D3DXVECTOR3''s?

You said that "pMin are all NULL." Does that mean that the position values of the variable are 0 or that the address of pMin is NULL?

neneboricua

Share this post


Link to post
Share on other sites
webjeff    241
Yes pMin,pMax are D3DXVECTOR3''s. The pMin comes back with the -4.32434234324234e-10,-4.32434234324234e-10,-4.32434234324234e-10... all the same values, like a null Vector usually does.

Jeff.

Share this post


Link to post
Share on other sites
S1CA    1418
Random braindump:

1) Check the return code from the call to check for failure.
Personally I surround *all* D3D/D3DX calls with a macro which checks the return code and then upon failure displays the line and file where the problem occurred as well as the decoded error code. This macro is designed to dissolve away in release builds.


2) Link with the DEBUG version of the D3DX library (link with D3DX8D.LIB instead of D3DX8.LIB). If there are any problems with your D3DX call, as well as returning a failure HRESULT, the debug version of the library will output a plain English description of *WHY* there was a failure (i.e. "file blah not found", "parameter X doesn''t make sense with respect to data set Y"). This output goes to the standard debug spew stream (what gets displayed in the Output window when you debug in MSVC or captured with dbmon.exe or DebugView).


3) What is MESH_FVF_MODEL ? is that the actual FVF for the data (e.g. #define MESH_FVF_MODEL D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1) ??. If so, then that''s wrong - The stride parameter should be the size of a single vertex structure in memory e.g.:
struct
{
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
D3DXVECTOR2 uv;
}
MyVertex;

stride == sizeof(MyVertex);



4) Where is the centre of your object mesh?, i.e. where is 0,0,0 in object space? - if 0,0,0 is one of the corners of your mesh, then the result you''re getting is likely actually correct! -4.32434234324234e-10 is -0.000000000432434234324234 which is pretty close to 0, particularly if the data has come from something such as 3DS Max which tends to introduce an amount of noise in the lower bits of the mantissa (due to things such as having UI tweakable values etc).


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites