PDA

View Full Version : Rectangle in 3D



10-01-2001, 07:13 AM
How to draw in GLU a parallelepipede? And not a cube as one can do with gluCylinder !

Gavin
10-01-2001, 07:34 AM
What is a parallelepipede?

10-01-2001, 07:38 AM
A rectangle in 3D ! Width, Height et Length

Gavin
10-01-2001, 07:45 AM
Can't quite figure out how cube and glucylinder are connected. To draw an 'irregular cube' (just made that up) Draw each face as a polygon. Can't do it in GLU. This is basic stuff.....

glBegin(GL_POLYGON);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y2, z2);
glVertex3f(x3, y3, z3);
glVertex3f(x4, y4, z4);
glEnd();

/* Do this for each face, there are better ways of doing it but to make it easy for you to learn this way may be best for now !*/

Paulus
10-01-2001, 07:46 AM
You can use i suppose:

(optionally you can use
glenable(GL_NORMALIZE);
if you want to use lighting)

glscalef (Width,Height,Length);
glutsolidcube(1);

Gavin
10-01-2001, 07:51 AM
Paulus' way will work, but I imagine you will need to work out how to 'build' objects from polygons at some point in your project.

Paulus
10-01-2001, 07:51 AM
With glucylinder you can draw a parallepiped if slices=4 but with a square bases-again you can use the glscalef to adjust it not to be square.

Gavin
10-01-2001, 07:56 AM
Well you learn something new every day, a parallelpipede, what a cool name, more interesting than 'a box'. :-)

Paulus
10-01-2001, 07:56 AM
Originally posted by Gavin:
Paulus' way will work, but I imagine you will need to work out how to 'build' objects from polygons at some point in your project.

Yeah!You are right!In fact I use my own DrawSolidParallepiped routines made up of simple primitives -in fact i use only vertex/normal arrays for performance reasons-i can post the code if you like.

Paulus
10-01-2001, 07:58 AM
Originally posted by Gavin:
Well you learn something new every day, a parallelpipede, what a cool name, more interesting than 'a box'. :-)

"Parallepiped" means "With Parallel Planes" -i know this because it's greek-and i am greek!

Gavin
10-01-2001, 08:01 AM
But did you know there is a whole family of parallelepipede...including....
1. random parallelepiped
2. random rhombic parallelepiped
3. pointy-shaped rhombic parallelepiped
4. flat-shaped rhombic parallelepiped
5. right parallelepiped.
6. cube.

10-02-2001, 06:40 AM
Maybe I can use GL_QUAD_STRIP two time?

Gavin
10-02-2001, 07:01 AM
If you so wish, no difference really, well obviously you type in a couple less verticies but there you are. quad, quad strip, poly, poly strip. Which ever you are more comfortable with I suppose.

gav

Exxos
02-07-2002, 01:40 AM
use glutSolidCube
and deform it (i think glScale(x,y,z))
maybe u need 2 put it in matrix:
glPushMatrix()
...
glPopMatrix()