Make a set of static 3D cubes

Hi there,
I really don’t know much about Jogl programming, but I need to visualize a set of cubes like dices ordered in a xyz space. I can pass a coordinates vector to this program to decide where to put dices (even one on the other). Can you tell me where I can find an application like this?

???

Thank you!
Stefano

Smells like homework :wink:

looks like you need to start with a basic scene to draw some primitive objects as place holders for your eventual dice cubes. I would just draw gluSphere() objects at the points that you want and then if that worked I would move on to drawing the cubes.

Here is the layout for OpenGL code for drawing a cube and you could simply translate this to JOGL when you are ready:


void gluCube(double wid,double hgt,double dep)
// Draws a cube at Z=0 to Z=dep
{
  glBegin(GL_QUADS);
    // Top
    glNormal3d(0,1,0);
    glVertex3d(-wid/2,hgt/2,dep);
    glVertex3d(wid/2,hgt/2,dep);
    glVertex3d(wid/2,hgt/2,0);
    glVertex3d(-wid/2,hgt/2,0);
    // Back
    glNormal3d(0,0,1);
    glVertex3d(-wid/2,hgt/2,dep);
    glVertex3d(-wid/2,-hgt/2,dep);
    glVertex3d(wid/2,-hgt/2,dep);
    glVertex3d(wid/2,hgt/2,dep);
    // Front
    glNormal3d(0,0,-1);
    glVertex3d(-wid/2,hgt/2,0);
    glVertex3d(wid/2,hgt/2,0);
    glVertex3d(wid/2,-hgt/2,0);
    glVertex3d(-wid/2,-hgt/2,0);
    // Left
    glNormal3d(1,0,0);
    glVertex3d(wid/2,hgt/2,0);
    glVertex3d(wid/2,hgt/2,dep);
    glVertex3d(wid/2,-hgt/2,dep);
    glVertex3d(wid/2,-hgt/2,0);
    // Right
    glNormal3d(-1,0,0);
    glVertex3d(-wid/2,hgt/2,dep);
    glVertex3d(-wid/2,hgt/2,0);
    glVertex3d(-wid/2,-hgt/2,0);
    glVertex3d(-wid/2,-hgt/2,dep);
    // Bottom
    glNormal3d(0,-1,0);
    glVertex3d(-wid/2,-hgt/2,dep);
    glVertex3d(-wid/2,-hgt/2,0);
    glVertex3d(wid/2,-hgt/2,0);
    glVertex3d(wid/2,-hgt/2,dep);
  glEnd();
}