PDA

View Full Version : Drawing irregular 3d shapes



ltrain_riders
10-17-2002, 05:55 AM
I'm trying to draw a 3d "box". The shape isn't a square cube, but resembles the letter " T " drawn in 3D. What would be the easiest and best way to draw this object. I've been thinking about using GL_LINES and drawing each vertex at every corner of the shape for: top view, front view, back view, left and right views. There has to be some sort of algorithm to construct without having to plot each vertex of every corner...? I was also debating wether to break the object up into Quads, so I would draw the " - " for the top of the letter T and draw a " | " for the vertical part. Are there any algorithms or techniques that are practiced when trying to create these mishaped boxes? I have many other boxes that need to be drawn, but if I break it down into Quads the total lines of code will be tremendous.
Also, I want to texture map these block objects, so does it matter if they are drawn with GL_QUADS, GL_LINES, etc... ?

nexusone
10-17-2002, 07:43 AM
You can use display list and store the objects in array's.

example:

GLfloat box3d[4][3] = {{ 1, 1, 0}, {1,0,0}, {0,0,1}, {0,1,0}}; // box3d[number_of_vertex_points][xyz_values]

Just draw out your object on graph paper, then enter at points data.

Yes, code can get very large on a good program.


Originally posted by ltrain_riders:
I'm trying to draw a 3d "box". The shape isn't a square cube, but resembles the letter " T " drawn in 3D. What would be the easiest and best way to draw this object. I've been thinking about using GL_LINES and drawing each vertex at every corner of the shape for: top view, front view, back view, left and right views. There has to be some sort of algorithm to construct without having to plot each vertex of every corner...? I was also debating wether to break the object up into Quads, so I would draw the " - " for the top of the letter T and draw a " | " for the vertical part. Are there any algorithms or techniques that are practiced when trying to create these mishaped boxes? I have many other boxes that need to be drawn, but if I break it down into Quads the total lines of code will be tremendous.
Also, I want to texture map these block objects, so does it matter if they are drawn with GL_QUADS, GL_LINES, etc... ?

tinak
10-17-2002, 01:47 PM
wouldn't GL_POLYGON be useful for this task... from what I understand this is sorta like GL_QUADS but you can use any number of vertices and the last vertex is connected to the first to create a polygon. Not used it myself though so don't know for sure.

Tina

adityagaddam
10-18-2002, 03:54 AM
yeah GL_POLYGON is good and yes it does join the last polygon with the first.

-Aditya

coredump
10-18-2002, 09:29 AM
but if you use GL_POLYGON you must be sure that the vertices you give it are coplanar, else you'll have strange looking geometry.

b