title: Bounding box in opengl c programming
body: <p>How can I create a bounding box around a 3d object that I've created in 3DS MAX, and then used it in an openGL application? I need the bounding box for collision detection, but I don't understand how to link a bounding box to an object. The function that creates the object is:</p>
  
  <pre><code>void drawR2D2(){
  if (xrot &lt;= 5.0) xrot = 5.0;
  
  if (xrot &gt;= 70.0) xrot = 70.0;
  
  if (ztransKit2 &gt;= 0.7) ztransKit2 = 0.7;
  
  if (xtransS1 &gt;= 0.2) xtransS1 = 0.2;
  
  if (ztransKit2 &lt;= 0.0) ztransKit2 = 0.0;
  
  if (xtransS1 &lt;= 0.0) xtransS1 = 0.0;
  
  
  glPushMatrix();
      drawBodyR2();
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(0.0, 1.2, 0.0);
      glScalef(2.85, 2.85, 2.85);
      glRotatef(yrotHead, 0.0, 1.0, 0.0);
      drawHeadR2();
  glPopMatrix();
  
  glPushMatrix();
      glScalef(3.5, 3.5, 3.5);
      drawLegsR2();
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(-0.41, 0.45, 0.26);
      glScalef(1.4, 1.4, 1.4);
      glRotatef(xrotKit1, 1.0, 0.0, 0.0);
      drawKit1R2();
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(-0.2, 0.5, 0.0 + ztransKit2);
      glScalef(2.0, 2.0, 2.0);
      glRotatef(zrotKit2, 0.0, 0.0, 1.0);
      drawKit2R2();
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(-0.25 + xtransS1, 0.48, 0.45);
      glScalef(1.55, 1.55, 1.55);
      drawShield1R2();
  glPopMatrix();
  
  glPushMatrix();
      glTranslatef(-0.44 + xtransS2, 0.48, 0.37);
      glScalef(1.12, 1.12, 1.12);
      drawShield2R2();
  glPopMatrix();
  }
  </code></pre>
  
  <p>The other functions: <em>drawBodyR2()</em>,<em>drawHeadR2</em>, etc are the components of the entire object.</p>
  
  <p>The code for the <em>drawBodyR2</em>, for example, is:</p>
  
  <pre><code>void drawBodyR2(){
  InitModel("r2d2/body.obj", &amp;body);//function to initialize the object
  glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, bodyId);
  glmDraw(body, GLM_SMOOTH | GLM_TEXTURE);
  glDisable(GL_TEXTURE_2D);
  }
  </code></pre>
  
  <p>Can anyone show me how to create a bounding box around the object resulted from the <strong>drawR2D2</strong> function?</p>