Esempio n. 1
0
/**
 * Draws the scene (used in display).
 */
void drawScene() {
   glMatrixMode(GL_MODELVIEW);
   glEnable(GL_DEPTH_TEST);

   glPushMatrix(); {
      cam.updateLookat();
      for (unsigned int i = 0; i < objs.size(); i++) {
         objs[i]->draw();
         if (draw_arrows) {
            glDisable(GL_DEPTH_TEST);
            objs[i]->drawArrows();
            glEnable(GL_DEPTH_TEST);
         }
         if (draw_bounding_box) {
            objs[i]->drawBoundingBox();
         }
         if (follow && objs[i]->classId == PART_ID) {
            particleSystem *temp = (particleSystem*)objs[i];
            cam.setFocus(temp->pos);
         }
      }
   } glPopMatrix();
}
Esempio n. 2
0
/**
 * The keyboard function that defines keys to be used.
 */
void keyboard(unsigned char key, int x, int y) {
   switch(key) {
      /* GENERAL */
      case 27:
         exit(EXIT_SUCCESS);
         break;
      case 'f': case 'F':
         full_screen_flag = !full_screen_flag;
         if (full_screen_flag) {
            glutFullScreen();
         }
         else {
            GW = 1080; GH = 720;
            glutReshapeWindow(GW, GH);
         }
         break;
      case '2': case '@':
         draw_arrows = !draw_arrows;
         break;
      case '3': case '#':
         draw_bounding_box = !draw_bounding_box;
         break;
      case '4': case '$':
         follow = !follow;
         if (!follow) { cam.setFocus(pnt3d(0, 0, 0)); }
         break;
      case '9':
         load();
         break;
      case '(': 
         save();
         break;


      /* CAMERA */
      case ' ':
         cam.cam_spin_flag = !cam.cam_spin_flag;
         break;

      /* PARTICLES */
      case '/': case '?':
         general((char*)"cif");
         break;
      case '\'': case '\"':
         general((char*)"retract_flag");
         break;
      case '1': 
         objs.push_back(new particleSystem(pnt3d(rand() % 10 - 5,
                                                 rand() % 10 - 5,
                                                 rand() % 10 - 5)));
         break;
      case '!':
         objs.pop_back();
         break;
      case '5': case '%':
         general((char*)"points_flag");
         break;
      case '6': case '^':
         general((char*)"switch_mesh");
         break;
      case '7': case '&':
         general((char*)"type");
         break;
      case '0': case ')':
         general((char*)"screen_saver");
         break;

      default:
         key_states[key] = true;
         break;
   }
}