OK, this has been annoying me for awhile now....I'm trying to generate an axis-aligned-bounding-box for an object I got the class okish but when I try to add points to it based on the vertices of the mesh (in this case, a circle...) I get this will number when I try to draw it....
before you ask, no, that's not a tinted screen over everything, that is suppose to be an axis aligned bounding box around one of the circle. Here is how I'm doing it.
void Circle::draw()
{
glPushMatrix();
glTranslated(mPosition.getX() + mTranslation.getX(),mPosition.getY() + mTranslation.getY(),0);
//glRotated(mSpin,0,0,1);
glScaled(mScale.getX(),mScale.getY(),0);
glTranslated(-mPosition.getX(),-mPosition.getY(),0);
glPopMatrix();
Vector3* vec = new Vector3();
mBoundingBox->setEntity(this);
mBoundingBox->setBounds(-FLT_MAX,-FLT_MAX,-FLT_MAX,
FLT_MAX, FLT_MAX, FLT_MAX);
for(int i = 0; i < Vertices.size();i++)
{
VertexPC* v = Vertices[i];
mBoundingBox->addPoint(*v);
}
glBegin(GL_POLYGON);
// draw the circle.
glColor4d(this->mRed,this->mGreen,this->mBlue,this->mAlpha);
for(int i = 0; i < this->getNumVertices(); i++)
{
VertexPC* v = getVertex(i);
glVertex2d(v->getVertX() + mPosition.getX(), v->getVertY() + mPosition.getY());
}
glEnd();
if(bTurnDebugOn)
{
glPushMatrix();
glTranslated(mPosition.getX(),
mPosition.getY(),0.0);
glScaled(mScale.getX(),mScale.getY(),mScale.getZ());
glTranslated(-mPosition.getX(),mPosition.getY(),0);
glPopMatrix();
glLineWidth(5);
glBegin(GL_LINES);
glColor4d(1,0,0,1);
glVertex2d(mPosition.getX(),mPosition.getY());
glVertex2d(mPosition.getX() + 50, mPosition.getY());
glColor4d(0,1,0,1);
glVertex2d(mPosition.getX(),mPosition.getY());
glVertex2d(mPosition.getX(), mPosition.getY() + 50);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslated(mPosition.getX(),mPosition.getY(),0);
glScaled(1,1,1);
glTranslated(-mPosition.getX(),-mPosition.getY(),0);
// try to draw the aabb
glBegin(GL_QUADS);
glColor4d(mDebugRed,mDebugGreen,mDebugBlue,mDebugAlpha);
double minX = mBoundingBox->getMin().getX() + mPosition.getX();
double minY = mBoundingBox->getMin().getY() + mPosition.getY();
double maxX = mBoundingBox->getMax().getX() + mPosition.getX();
double maxY = mBoundingBox->getMax().getY() + mPosition.getY();
glVertex2d(minX,minY);
glVertex2d(minX,maxY);
glVertex2d(maxX,maxY);
glVertex2d(maxX,minY);
glEnd();
glPopMatrix();
}
}
this is in the draw function so I don't know what I'm doing wrong or missing something. any advice would help.
Oh I feel I should post the circle's constructor also.
Circle::Circle()
: Entity()
{
this->mNumSegments = 0;
this->mAngle = 0.0;
this->mRadius = 0.0;
mBoundingBox = new AxisAlignedBoundingBox();
double minX = -FLT_MAX;
double minY = -FLT_MAX;
double maxX = FLT_MAX;
double maxY = FLT_MAX;
//mMin.setVector(-FLT_MAX,-FLT_MAX,-FLT_MAX);
//mMax.setVector( FLT_MAX, FLT_MAX, FLT_MAX);
}
I hope something comes out of this.....