Pyroclastic Flow

12-06-2009, 04:49 PM

So I need to add Bounding Boxes to the 3D models that I imported into my game. Is there an easy way to do this without manually having to manually add my coordinates?

So far I have:

struct Box {

Vector3 min;

Vector3 max;

}

...

void CreateBox (float minx, float miny, float minz, float maxx, float maxy, float maxz) {

Box b;

b.min.x = minx;

b.min.y = miny;

b.min.z = minz;

b.max.x = maxx;

b.max.y = maxy;

b.max.z = maxz;

// then add box to array

}

void drawScene()

// ... render my scene

glPushMatrix()

glTransformf(200, 200, 200);

glScalef(5.0, 5,0, 5.0);

glRotate(xAngle, 0.0, 1.0, 0.0);

drawModel(model); // draws the 3d model

CreateBox(200, 0, 200, 400, 300, 400);

glPopMatrix();

Reason I ask is, even after creating the box as mentioned above, the box isn't rotated by xAngle like the 3D model. So I cant really add collision detection, as the box does not fit around the 3d model (which is also a square).

Hope that makes sense.

Thanks guys.

So far I have:

struct Box {

Vector3 min;

Vector3 max;

}

...

void CreateBox (float minx, float miny, float minz, float maxx, float maxy, float maxz) {

Box b;

b.min.x = minx;

b.min.y = miny;

b.min.z = minz;

b.max.x = maxx;

b.max.y = maxy;

b.max.z = maxz;

// then add box to array

}

void drawScene()

// ... render my scene

glPushMatrix()

glTransformf(200, 200, 200);

glScalef(5.0, 5,0, 5.0);

glRotate(xAngle, 0.0, 1.0, 0.0);

drawModel(model); // draws the 3d model

CreateBox(200, 0, 200, 400, 300, 400);

glPopMatrix();

Reason I ask is, even after creating the box as mentioned above, the box isn't rotated by xAngle like the 3D model. So I cant really add collision detection, as the box does not fit around the 3d model (which is also a square).

Hope that makes sense.

Thanks guys.