/** UGS Event Listener */
  @Override
  public void UGSEvent(UGSEvent cse) {
    if (cse.isFileChangeEvent()) {
      animator.pause();

      switch (cse.getFileState()) {
        case FILE_LOADING:
          setGcodeFile(cse.getFile());
          break;
        case FILE_LOADED:
          setProcessedGcodeFile(cse.getFile());
          break;
      }

      animator.resume();
    }
  }
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // GL_DEPTH_BUFFER_BITを追加
    gl.glLoadIdentity();

    // 視点位置と視線方向
    glu.gluLookAt(3.0f, 4.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

    // 光源の位置設定
    //		gl.glLightfv(GL_LIGHT0, GL_POSITION, light0pos, 0);
    //		gl.glLightfv(GL_LIGHT1, GL_POSITION, light1pos, 0);

    // 図形の回転
    gl.glTranslatef(0.5f, 0.5f, 0.5f);
    gl.glRotatef(r, 0.0f, 1.0f, 0.0f);
    gl.glTranslatef(-0.5f, -0.5f, -0.5f);
    // 図形の色 (赤)
    //		gl.glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red, 0);//追加
    //		gl.glColor3f(0.0f, 0.0f, 0.0f);

    // 図形の描画
    gl.glBegin(GL_QUADS);
    for (int j = 0; j < 6; ++j) {
      //			gl.glColor3fv(color[j], 0); //追加
      //			gl.glNormal3fv(normal[j], 0);
      for (int i = 0; i < 4; ++i) {
        gl.glNormal3fv(vertex[face[j][i]], 0);
        gl.glVertex3fv(vertex[face[j][i]], 0);
      }
    }
    gl.glEnd();

    // 一周回ったら回転角を 0 に戻す
    if (r++ >= 360.0f) r = 0;
    System.out.println("anim:" + animator.isAnimating() + ", r:" + r);
    if (willAnimatorPause) {
      animator.pause();
      System.out.println("animoator paused:");
      willAnimatorPause = false;
    }
  }
 public CubeSample6InvalidNormal() {
   GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
   glu = new GLU();
   GLWindow glWindow = GLWindow.create(caps);
   glWindow.setTitle("Cube demo (Newt)");
   glWindow.setSize(300, 300);
   glWindow.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowDestroyed(WindowEvent arg0) {
           System.exit(0);
         }
       });
   glWindow.addGLEventListener(this);
   glWindow.addMouseListener(this);
   animator = new FPSAnimator(30);
   animator.add(glWindow);
   animator.start();
   animator.pause();
   glWindow.setVisible(true);
 }
示例#4
0
 public void pauseThread() {
   if (animator != null) {
     animator.pause();
   }
 }
 @Override
 public void mouseReleased(MouseEvent e) {
   animator.pause();
 }