I am not a huge X mesh lover, mostly because everything is so black box.
Hmmm lemme try writing a bbox routine in the post window:
CODE |
BYTE *pVert; D3DXVECTOR3 minv(0,0,0),maxv(0,0,0),temp; UINT v_size=D3DXGetFVFVertexSize(mesh->GetFVF()); mesh->LockVertexBuffer(0,&pVert); for(int i=0;iGetNumVertices();i++) { memcpy(&temp,pVert,sizeof(D3DXVECTOR3)); minv.x=min(minv.x,temp.x); maxv.x=max(maxv.x,temp.x); //etc etc etc
pVert+=v_size; } mesh->UnlockVertexBuffer();
|
There's a couple things that need to be right in the mesh for that to work, i.e. position needs to be the first 12 bytes. The mesh also needs to be based around the origin. You can always change that by setting min and max as the first vert and then going through all the other verts. Should consider getting off .x and onto a raw vert list or something.
-PeteGabe