示例#1
0
/**
 * draw_dodecahedron:
 * @solid: TRUE if the dodecahedron should be solid.
 *
 * Renders a dodecahedron centered at the modeling coordinates
 * origin with a radius of the square root of 3.
 *
 **/
void
draw_dodecahedron (gboolean solid)
{
  if (solid)
    dodecahedron (GL_TRIANGLE_FAN);
  else
    dodecahedron (GL_LINE_LOOP);
}
示例#2
0
文件: scene.c 项目: jchan1e/graphics
void display()
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_CULL_FACE);

   glLoadIdentity();

   
   //view angle
   if (mode == 0) //rotation for ortho mode
   {
      glRotatef(ph, 1,0,0);
      glRotatef(th, 0,1,0);
      glScaled(0.4,0.4,0.4);
   }
   else if (mode == 1) //rotation for perspective mode
   {
      ex = Sin(-th)*Cos(ph)*8;
      ey = Sin(ph)*8;
      ez = Cos(-th)*Cos(ph)*8;

      gluLookAt(ex,ey,ez , 0,0,0 , 0,Cos(ph),0);
      //glScaled(0.3,0.3,0.3);
   }
   else //mode == 2              // rotation and movement for FP mode
   {                             // occur in keyboard & special
      vx = ex - Sin(th)*Cos(ph); // here we simply update
      vy = ey - Sin(ph);         // location of view target
      vz = ez - Cos(th)*Cos(ph);

      gluLookAt(ex,ey,ez , vx,vy,vz , 0,Cos(ph),0);
   }


   sphere(0, 0, 0, 1.5*r, 0.5); //Jupiter
   glPushMatrix();
   glRotated(r/2, 0,1,0);
   cube(1, 0, 0, r, 0.25); //IO
   glPopMatrix();
   glPushMatrix();
   glRotated(r/4, 0,1,0);
   octahedron(-2, 0, 0, 4.0/3.0*r, 0.25); //Europa
   glPopMatrix();
   glPushMatrix();
   glRotated(r/8, 0,1,0);
   dodecahedron(3, 0, 0, -1.125*r, 0.25); //Ganymede
   glPopMatrix();
   glPushMatrix();
   glRotated(r/18.4, 0,1,0);
   icosahedron(4, 0, 0, 0.75*r, 0.25); //Callisto
   glPopMatrix();

   r = glutGet(GLUT_ELAPSED_TIME)*rate;
   r = fmod(r, 360*24*18.4);
   glFlush();
   glutSwapBuffers();
}
void APIENTRY
glutSolidDodecahedron(void)
{
  dodecahedron(GL_TRIANGLE_FAN);
}
/* CENTRY */
void APIENTRY
glutWireDodecahedron(void)
{
  dodecahedron(GL_LINE_LOOP);
}
示例#5
0
main(int argc, char *argv[])
{
  int i,j;
  char *s;
  char *progname;
  int solid = TETRA;

  progname = argv[0];

  while (--argc > 0 && (*++argv)[0]=='-') {
    for (s = argv[0]+1; *s; s++)
      switch (*s) {
        case 's':
          xscale = atof (*++argv);
          yscale = atof (*++argv);
          zscale = atof (*++argv);
          argc -= 3;
          break;
        case 't':
          solid = TETRA;
          break;
        case 'o':
          solid = OCTA;
          break;
        case 'c':
          solid = CUBE;
          break;
        case 'i':
          solid = ICOSA;
          break;
        case 'd':
          solid = DODECA;
          break;
        default:
          usage (progname);
          exit (-1);
          break;
      }
  }

  switch (solid) {
    case TETRA:
      tetra();
      break;
    case OCTA:
      octa();
      break;
    case CUBE:
      cube();
      break;
    case ICOSA:
      icosahedron();
      break;
    case DODECA:
      dodecahedron();
      break;
    default:
      exit (-1);
      break;
  }

  write_file();
}
示例#6
0
void APIENTRY auxSolidDodecahedron (GLdouble radius)
{
    GLdouble center[3] = {(GLdouble)0.0, (GLdouble)0.0, (GLdouble)0.0};

    dodecahedron (center, radius/(GLdouble)1.73, GL_POLYGON);
}
示例#7
0
/*  Render wire frame or solid dodecahedra.  If no display list with
 *  the current model size exists, create a new display list.
 */
void APIENTRY auxWireDodecahedron (GLdouble radius)
{
    GLdouble center[3] = {(GLdouble)0.0, (GLdouble)0.0, (GLdouble)0.0};

    dodecahedron (center, radius/(GLdouble)1.73, GL_LINE_LOOP);
}
示例#8
0
void
glutSolidDodecahedron(void)
{
  dodecahedron(GL_TRIANGLE_FAN);
}
示例#9
0
void
glutWireDodecahedron(void)
{
  dodecahedron(GL_LINE_LOOP);
}