Rectangle in 3D

How to draw in GLU a parallelepipede? And not a cube as one can do with gluCylinder !

What is a parallelepipede?

A rectangle in 3D ! Width, Height et Length

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 !*/

You can use i suppose:

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

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

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.

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.

Well you learn something new every day, a parallelpipede, what a cool name, more interesting than ‘a box’. :slight_smile:

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.

Originally posted by Gavin:
Well you learn something new every day, a parallelpipede, what a cool name, more interesting than ‘a box’. :slight_smile:

“Parallepiped” means “With Parallel Planes” -i know this because it’s greek-and i am greek!

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.

Maybe I can use GL_QUAD_STRIP two time?

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

use glutSolidCube
and deform it (i think glScale(x,y,z))
maybe u need 2 put it in matrix:
glPushMatrix()

glPopMatrix()