Jump to content
  • Advertisement
Sign in to follow this  
giugio

drawing bounding box around mesh

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
maybe you should read this:
http://www.c-sharpcorner.com/UploadFile/jeradus/OpenGLBasics11172005014307AM/OpenGLBasics.aspx

third hit on google by the way: http://www.google.nl/search?hl=nl&source=hp&q=opengl+draw+a+box+with+lines&aq=f&aqi=&aql=&oq=&gs_rfai=

Share this post


Link to post
Share on other sites
Quote:
Original post by CodeCriminal
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:
*** 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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!