Public Group

# drawing bounding box around mesh

This topic is 3075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hy.
I would draw a yellow or red rectangle around the bounding box(rectangular bounding box) of a mesh if it is selected.
I have an array of 8 point :
3dPoint{
float x;
float y;
float z;

}
3dPoint[7]now i must find the correct index buffer , but i'm don't know how works the indexes in opengl for lines primitives.But How i draw the correct rectangle? the first four points are the top 4 point of the rectangle and the subsequent points are the down 4 3dpoint.At the end i draw a poly, is possible to select anoter primitive?Thanks

##### Share on other sites
Seriously, you need to learn to solve problems for your own. You will never learn programming (programming = problem solving) if you come here with even the smallest issues you have, and ask for solutions.

Sit down, take a paper and a pen and start thinking about the problem.

##### Share on other sites
Im not to familiar with this topic myself but it does interest me somewhat since I would require at some point the same answers.

I have tried it but you (we) might be able to provide indices for each line on the bounding box as a set of 2.

for example:
unsigned int indices[] = {		1, 2, // front top line		2, 3, // front right line		3, 4, // front bottom line		4, 1, // front left line		5, 6, // back top line		6, 7, // back right line		7, 8, // back bottom  line		8, 5, // back left line		1, 5, // front-back join top left		2, 6, // front back join top right		3, 7, // front-back join bottom right		4, 8, // front-back join bottom left	};

Now problem would be to only draw the corners of the bounding box and not the entire box itself, which would require 8*4 vertices amd numerous indices...

Anyone know of a simpler way to do this?

EDIT: sorry szecs :S

##### Share on other sites
Quote:
 Original post by CodeCriminalIm not to familiar with this topic myself but it does interest me somewhat since I would require at some point the same answers.I have tried it but you (we) might be able to provide indices for each line on the bounding box as a set of 2.for example:*** Source Snippet Removed ***Now problem would be to only draw the corners of the bounding box and not the entire box itself, which would require 8*4 vertices amd numerous indices...Anyone know of a simpler way to do this?EDIT: sorry szecs :S

If you want to do it real smart, you could use a 1D texture, enabled alpha test and other "smart stuff".

IMHO, you just have all the vertices for a generic box (As you said: "that's a lot of vertices, rzzzzz"), that you instance/scale/rotate/translate.

##### Share on other sites
Actually one of the easiest ways of doing this is by creating a line list. Either done with a index list or with an additional vertex buffer without an index buffer.

How to fill this buffer is left to the OP as it is really easy to find this out.
Hint have a look at D3DPT_LINELIST in DX or GL_LINES in GL

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633684
• Total Posts
3013316
×