public void display(GLAutoDrawable drawable) {
   GL gl = drawable.getGL();
   synchronized (this._camera) {
     try {
       gl.glClear(
           GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
       NyARGLDrawUtil.drawBackGround(gl, this._camera.getSourceImage(), 1.0);
       this._nyar.update(this._camera);
       if (this._nyar.isExistMarker(this.ids[0])) {
         gl.glMatrixMode(GL.GL_MODELVIEW);
         gl.glPushMatrix();
         gl.glLoadMatrixd(this._nyar.getGlMarkerMatrix(this.ids[0]), 0);
         NyARGLDrawUtil.drawColorCube(gl, 40);
         gl.glPopMatrix();
       }
       if (this._nyar.isExistMarker(this.ids[1])) {
         gl.glMatrixMode(GL.GL_MODELVIEW);
         gl.glPushMatrix();
         gl.glLoadMatrixd(this._nyar.getGlMarkerMatrix(this.ids[1]), 0);
         NyARGLDrawUtil.drawColorCube(gl, 40);
         gl.glPopMatrix();
       }
       Thread.sleep(1);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
예제 #2
0
  public void display(GLAutoDrawable drawable) {
    if (!_cap_image.hasBuffer()) {
      return;
    }
    // 背景を書く
    this._gl.glClear(
        GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
    // OnEnter,OnUpdateの間に、transmatに初回行列がストアされる実行されることを防ぎます。
    try {
      NyARGLDrawUtil.drawBackGround(this._gl, this._cap_image, 1.0);
      synchronized (this._sync_object) {
        if (this._processor.current_code < 0) {

        } else {
          // Projection transformation.
          this._gl.glMatrixMode(GL.GL_PROJECTION);
          this._gl.glLoadMatrixd(_camera_projection, 0);
          this._gl.glMatrixMode(GL.GL_MODELVIEW);
          // Viewing transformation.
          this._gl.glLoadIdentity();
          this._gl.glLoadMatrixd(this._processor.gltransmat, 0);
          // All other lighting and geometry goes here.
          this._gl.glPushMatrix();
          this._gl.glDisable(GL.GL_LIGHTING);

          // マーカのXZ平面をマーカの左上、表示開始位置を10cm上空へ。
          // くるーんくるん
          Date d = new Date();
          float r = (d.getTime() / 50) % 360;
          this._gl.glRotatef(r, 0f, 0f, 1.0f);
          this._gl.glTranslatef(-70f, 0f, 1.0f);
          this._gl.glRotatef(90, 1.0f, 0f, 0f);
          NyARGLDrawUtil.drawText("MarkerId:" + this._processor.current_code, 1f);
          this._gl.glPopMatrix();
          Thread.sleep(1); // タスク実行権限を一旦渡す
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return;
  }