   Draw BoX line problem
  i want to draw box line to show bounding sphere.but it is not the box that I want to geti found and apply from internet.D3DXVECTOR3 m_objectBounds[24]; m_objectBounds[0] = D3DXVECTOR3(m_min.x, m_min.y, m_min.z);  m_objectBounds[1] = D3DXVECTOR3(m_max.x, m_min.y, m_min.z);  m_objectBounds[2] = D3DXVECTOR3(m_min.x, m_min.y, m_max.z);  m_objectBounds[3] = D3DXVECTOR3(m_max.x, m_min.y, m_max.z);  m_objectBounds[4] = D3DXVECTOR3(m_min.x, m_min.y, m_min.z);  m_objectBounds[5] = D3DXVECTOR3(m_min.x, m_min.y, m_max.z);  m_objectBounds[6] = D3DXVECTOR3(m_max.x, m_min.y, m_min.z);  m_objectBounds[7] = D3DXVECTOR3(m_max.x, m_min.y, m_max.z);  m_objectBounds[8] = D3DXVECTOR3(m_min.x, m_max.y, m_min.z);  m_objectBounds[9] = D3DXVECTOR3(m_max.x, m_max.y, m_min.z);  m_objectBounds[10] = D3DXVECTOR3(m_min.x, m_max.y, m_max.z);  m_objectBounds[11] = D3DXVECTOR3(m_max.x, m_max.y, m_max.z);  m_objectBounds[12] = D3DXVECTOR3(m_min.x, m_max.y, m_min.z);  m_objectBounds[13] = D3DXVECTOR3(m_min.x, m_max.y, m_max.z);  m_objectBounds[14] = D3DXVECTOR3(m_max.x, m_max.y, m_min.z);  m_objectBounds[15] = D3DXVECTOR3(m_max.x, m_max.y, m_max.z);  m_objectBounds[16] = D3DXVECTOR3(m_min.x, m_min.y, m_min.z);  m_objectBounds[17] = D3DXVECTOR3(m_min.x, m_max.y, m_min.z);  m_objectBounds[18] = D3DXVECTOR3(m_max.x, m_min.y, m_min.z);  m_objectBounds[19] = D3DXVECTOR3(m_max.x, m_max.y, m_min.z);  m_objectBounds[20] = D3DXVECTOR3(m_min.x, m_min.y, m_max.z);  m_objectBounds[21] = D3DXVECTOR3(m_min.x, m_max.y, m_max.z);  m_objectBounds[22] = D3DXVECTOR3(m_max.x, m_min.y, m_max.z);  m_objectBounds[23] = D3DXVECTOR3(m_max.x, m_max.y, m_max.z);const unsigned short index[] = {0, 1, 1, 2, 2, 3, 3, 0,4, 5, 5, 6, 6, 7, 7, 4,3, 7, 2, 6, 0, 4, 1, 5};#define FVF_VERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)typedef struct {float x, y, z;float nx, ny, nz;float u, v;}VERTEX;m3pdevice->SetFVF(FVF_VERTEX);m3pdevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, 24, 12, (void *)index, D3DFMT_INDEX16,m_objectBounds,sizeof(VERTEX));[Edited by - fantasyme on June 2, 2010 6:07:52 AM]
  The DrawIndexedPrimitiveUP call requires the number of vertices as the third parameter. You have 8 vertices but pass in 24 as that parameter. That parameter is the actual number of vertices in the array, not the number of lines*2.You also have an array m_objectBound but pass in m_objectBounds as the vertices parameter. Do you have m_objectBounds defined elsewhere?You don't indicate how you have FVF_VERTEX defined.;  ok, I fixed what you said.it is not work. The shape is not cubeI actually not understand about 4 and 5 parameter.i think 5 parameter is face.http://msdn.microsoft.com/en-us/library/bb174370(VS.85).aspxI read the definition but I don't get it.;  1. m_objectBounds should be an array of 8 elements, one for each corner of the box.2. Your m_objectBounds array is an array of 3D vectors (12 bytes, 3*sizeof(float)), but FVF_VERTEX says that D3D should expect a struct containing a 3D vector for position, a 3D vector for the normal, and a 2D vector for the texture coordinates (32 bytes, 8*sizeof(float)).You need to pass in an array of VERTEX structs instead of D3DVECTOR3's to DrawIndexedPrimitiveUP().   ;  well, i fixed it now, thanks.[Edited by - fantasyme on June 2, 2010 8:35:42 AM]