Oriented Bounding Box (rotating about the central point)
#1 Members - Reputation: 189
Posted 18 February 2013 - 03:10 PM
#2 Members - Reputation: 165
Posted 18 February 2013 - 03:53 PM
Edited by _Slin_, 18 February 2013 - 04:09 PM.
#3 Members - Reputation: 189
Posted 19 February 2013 - 08:05 AM
Now seems to REALLY rotate about the world center
. I think the first try it's more correct. When I draw a cube like this:
glBegin(GL_POLYGON);
glColor3f( 1.0, 1.0, 1.0 );
glVertex3f( 0.5, -0.5, 0.5 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glVertex3f( -0.5, -0.5, 0.5 );
glEnd();
// Purple side - RIGHT
glBegin(GL_POLYGON);
glColor3f( 1.0, 0.0, 1.0 );
glVertex3f( 0.5, -0.5, -0.5 );
glVertex3f( 0.5, 0.5, -0.5 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( 0.5, -0.5, 0.5 );
glEnd();
// Green side - LEFT
glBegin(GL_POLYGON);
glColor3f( 0.0, 1.0, 0.0 );
glVertex3f( -0.5, -0.5, 0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glVertex3f( -0.5, -0.5, -0.5 );
glEnd();
// Blue side - TOP
glBegin(GL_POLYGON);
glColor3f( 0.0, 0.0, 1.0 );
glVertex3f( 0.5, 0.5, 0.5 );
glVertex3f( 0.5, 0.5, -0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glEnd();
// Red side - BOTTOM
glBegin(GL_POLYGON);
glColor3f( 1.0, 0.0, 0.0 );
glVertex3f( 0.5, -0.5, -0.5 );
glVertex3f( 0.5, -0.5, 0.5 );
glVertex3f( -0.5, -0.5, 0.5 );
glVertex3f( -0.5, -0.5, -0.5 );
glEnd();
Rotates perfectly. Maybe is a problem with max and min and I can't figure out. If someone know how to correctly draw a OBB...
#6 Members - Reputation: 526
Posted 22 February 2013 - 02:17 PM
glTranslate(x,y,z);glRotate(angle,x,y,z) and Set up all your vertices as if your box is axigned aligned. If you are using Quaternion you can always convert your quaternion of your object local rotation to an axis and angle and feed that to glRotate.






