コード例 #1
0
ファイル: sccolorlight.java プロジェクト: neosam/jogl-demos
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    //
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glPushMatrix();
    gl.glRotatef(20.0f, 1.0f, 0.0f, 0.0f);

    gl.glPushMatrix();
    gl.glTranslatef(-0.75f, 0.5f, 0.0f);
    gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);

    glut.glutSolidTorus(0.275f, 0.85f, 20, 20);
    gl.glPopMatrix();

    gl.glPushMatrix();
    gl.glTranslatef(-0.75f, -0.5f, 0.0f);
    gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
    glut.glutSolidCone(1.0f, 2.0f, 20, 20);
    gl.glPopMatrix();

    gl.glPushMatrix();
    gl.glTranslatef(0.75f, 0.0f, -1.0f);
    glut.glutSolidSphere(1.0f, 20, 20);
    gl.glPopMatrix();

    gl.glPopMatrix();
    gl.glFlush();
  }
コード例 #2
0
  public void display(GLAutoDrawable drawable) {

    GL2 gl = drawable.getGL().getGL2();

    // Clear the drawing area
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    // Reset the current matrix to the "identity"
    gl.glLoadIdentity();

    // Move the "drawing cursor" around
    gl.glTranslatef(-1.5f, 0.0f, -6.0f);

    // Drawing Using Triangles
    gl.glBegin(GL2.GL_TRIANGLES);
    gl.glColor3f(1.0f, 0.0f, 0.0f); // Set the current drawing color to red
    gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
    gl.glColor3f(0.0f, 1.0f, 0.0f); // Set the current drawing color to green
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    gl.glColor3f(0.0f, 0.0f, 1.0f); // Set the current drawing color to blue
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    // Finished Drawing The Triangle
    gl.glEnd();

    // Move the "drawing cursor" to another position
    gl.glTranslatef(3.0f, 0.0f, 0.0f);
    // Draw A Quad
    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(0.5f, 0.5f, 1.0f); // Set the current drawing color to light blue
    gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    // Done Drawing The Quad
    gl.glEnd();
  }
コード例 #3
0
ファイル: Arrow.java プロジェクト: snowgoon88/JSpaceZombie
  /**
   * Render the arrow as a line and a _head.
   *
   * @param gl OpenGL Context
   */
  public void render(GL2 gl) {
    // save Light Attributes and remove lighting to get "full" RGB colors
    // gl.glPushAttrib( GL2.GL_LIGHTING_BIT );
    gl.glPushAttrib(GL2.GL_ENABLE_BIT);
    gl.glDisable(GL2.GL_LIGHTING);

    if (_fg_verb) {
      System.out.println(
          "Arrow pos="
              + _pos.toString()
              + "  angZ1="
              + _angZ1
              + "  angY2="
              + _angY2
              + "  length="
              + _length);
      _fg_verb = false;
    }

    // save transformation matrix, then translate and scale.
    gl.glPushMatrix();
    gl.glTranslatef(_pos.x, _pos.y, _pos.z);
    gl.glRotatef(Matrix.rad2Deg(_angZ1), 0, 0, 1); // rotation around 0z
    gl.glRotatef(Matrix.rad2Deg(_angY2), 0, 1, 0); // rotation around 0y

    // draw line
    gl.glColor4f(_color_fg.x, _color_fg.y, _color_fg.z, _color_fg.w);
    gl.glLineWidth(1.0f);
    gl.glBegin(GL.GL_LINES);
    {
      gl.glVertex3f(0, 0, 0);
      gl.glVertex3f(_length, 0, 0);
    }
    gl.glEnd();

    // draw head
    gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL);
    gl.glTranslatef(_length, 0, 0);
    gl.glBegin(GL.GL_TRIANGLES);
    {
      for (float[] face : _head_faces) {
        gl.glVertex3f(face[0], face[1], face[2]);
        gl.glVertex3f(face[3], face[4], face[5]);
        gl.glVertex3f(face[6], face[7], face[8]);
      }
    }
    gl.glEnd();

    // restore transformation matrix
    gl.glPopMatrix();
    // restore attributes
    gl.glPopAttrib();
  }
コード例 #4
0
  @Override
  public void render(GL2 gl, float trajectory) {
    //		flat = true;

    gl.glPushMatrix();
    {
      gl.glTranslatef(c.x, c.y, c.z);
      gl.glRotatef(trajectory, 0, -1, 0);
      gl.glRotatef((flat) ? -90 : 0, 1, 0, 0);
      gl.glRotatef(rotation, 0, 0, 1);

      Vec3 scale = new Vec3(0.75f, 2.0f, 0);
      if (miniature) scale = scale.multiply(0.5f);
      scale = scale.multiply(0.8f);

      gl.glScalef(scale.x, scale.y, scale.z);
      gl.glTranslatef(0, 0.2f, 0);

      gl.glDepthMask(false);
      gl.glDisable(GL_LIGHTING);
      gl.glEnable(GL_BLEND);
      gl.glEnable(GL_TEXTURE_2D);

      gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE);

      whiteSpark.bind(gl);

      gl.glColor3f(colors[color][0], colors[color][1], colors[color][2]);

      gl.glBegin(GL_QUADS);
      {
        gl.glTexCoord2f(1.0f, 1.0f);
        gl.glVertex3f(-0.5f, -0.5f, 0.0f);
        gl.glTexCoord2f(1.0f, 0.0f);
        gl.glVertex3f(-0.5f, 0.5f, 0.0f);
        gl.glTexCoord2f(0.0f, 0.0f);
        gl.glVertex3f(0.5f, 0.5f, 0.0f);
        gl.glTexCoord2f(0.0f, 1.0f);
        gl.glVertex3f(0.5f, -0.5f, 0.0f);
      }
      gl.glEnd();

      gl.glDisable(GL_BLEND);
      gl.glEnable(GL_LIGHTING);
      gl.glDepthMask(true);

      gl.glColor3f(1, 1, 1);
    }
    gl.glPopMatrix();
  }
コード例 #5
0
  private void renderBlast(GL2 gl) {
    GLU glu = new GLU();

    Shader shader = Shader.get("dissolve");
    if (shader != null) {
      shader.enable(gl);

      shader.setSampler(gl, "cloudSampler", 0);
      shader.setUniform(gl, "dissolveFactor", 1.0f - ((float) blastDuration / 60.0f));
    }

    gl.glEnable(GL2.GL_TEXTURE_2D);

    GLUquadric sphere = glu.gluNewQuadric();

    glu.gluQuadricDrawStyle(sphere, GLU.GLU_FILL);
    glu.gluQuadricTexture(sphere, true);

    gl.glPushMatrix();
    {
      noiseSampler.bind(gl);
      noiseSampler.setTexParameterf(gl, GL2.GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);

      gl.glTranslatef(bound.c.x, bound.c.y, bound.c.z);

      glu.gluSphere(sphere, blastRadius, 24, 24);
    }
    gl.glPopMatrix();
  }
コード例 #6
0
  private void drawStar(GL2 gl, GLAutoDrawable drawable, Float x, Float y, Float z) {
    // Pushing to matrix stack
    gl.glPushMatrix();

    // STAR
    // Moves the figure in the (x, y, z)-axis
    gl.glTranslatef(x, y, z);

    // BEGIN Star
    gl.glBegin(GL_LINE_LOOP);

    // Pushing to attribute stack
    gl.glPushAttrib(GL_ALL_ATTRIB_BITS);

    // Set color to GREEN
    gl.glColor3f(0.0f, 1.0f, 0.0f);

    // Draw the sides
    gl.glVertex3f(0.0f, 1.0f, 0.0f);
    gl.glVertex3f(0.2f, 0.2f, 0.0f);
    gl.glVertex3f(1.0f, 0.0f, 0.0f);
    gl.glVertex3f(0.2f, -0.2f, 0.0f);
    gl.glVertex3f(0.0f, -1.0f, 0.0f);
    gl.glVertex3f(-0.2f, -0.2f, 0.0f);
    gl.glVertex3f(-1.0f, 0.0f, 0.0f);
    gl.glVertex3f(-0.2f, 0.2f, 0.0f);

    // END Star
    gl.glEnd();

    // Popping state
    gl.glPopAttrib();
    gl.glPopMatrix();
  }
コード例 #7
0
ファイル: JOGL2Nehe11Flag.java プロジェクト: ElDombrovan/java
  /** Called back by the animator to perform rendering. */
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context
    gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
    gl.glLoadIdentity(); // reset the model-view matrix

    gl.glTranslatef(0.0f, 0.0f, -12.0f);
    gl.glRotatef(rotateAnleX, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(rotateAnleY, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(rotateAngleZ, 0.0f, 0.0f, 1.0f);

    // need to flip the image
    float textureHeight = textureTop - textureBottom;

    float x1, y1, x2, y2; // used to break the flag into tiny quads

    gl.glBegin(GL_QUADS);
    for (int x = 0; x < numPoints - 1; x++) {
      for (int y = 0; y < numPoints - 1; y++) {
        x1 = (float) x / 44.0f;
        y1 = (float) y / 44.0f;
        x2 = (float) (x + 1) / 44.0f;
        y2 = (float) (y + 1) / 44.0f;

        // Texture need to flip vertically
        gl.glTexCoord2f(x1, y1 * textureHeight + textureBottom);
        gl.glVertex3f(points[x][y][0], points[x][y][1], points[x][y][2]);

        gl.glTexCoord2f(x1, y2 * textureHeight + textureBottom);
        gl.glVertex3f(points[x][y + 1][0], points[x][y + 1][1], points[x][y + 1][2]);

        gl.glTexCoord2f(x2, y2 * textureHeight + textureBottom);
        gl.glVertex3f(points[x + 1][y + 1][0], points[x + 1][y + 1][1], points[x + 1][y + 1][2]);

        gl.glTexCoord2f(x2, y1 * textureHeight + textureBottom);
        gl.glVertex3f(points[x + 1][y][0], points[x + 1][y][1], points[x + 1][y][2]);
      }
    }
    gl.glEnd();

    if (wiggleCount == 2) { // Used To Slow Down The Wave (Every 2nd Frame Only)
      for (int y = 0; y < 45; y++) {
        float tempHold = points[0][y][2]; // Store current value One Left Side Of
        // Wave
        for (int x = 0; x < 44; x++) {
          // Current Wave Value Equals Value To The Right
          points[x][y][2] = points[x + 1][y][2];
        }
        points[44][y][2] = tempHold; // Last Value Becomes The Far Left Stored
        // Value
      }
      wiggleCount = 0; // Set Counter Back To Zero
    }
    wiggleCount++;

    // update the rotational position after each refresh
    rotateAnleX += roateSpeedX;
    rotateAnleY += rotateSpeedY;
    rotateAngleZ += rotateSpeedZ;
  }
コード例 #8
0
ファイル: Test.java プロジェクト: JibouLBF/Fablab
  @Override
  public void display(GLAutoDrawable gLDrawable) {
    final GL2 gl = gLDrawable.getGL().getGL2();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);

    // rotate about the three axes
    gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);

    // Draw A Quad
    gl.glBegin(GL2.GL_QUADS);
    gl.glColor3f(0.0f, 1.0f, 1.0f); // set the color of the quad
    gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
    gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
    gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
    // Done Drawing The Quad
    gl.glEnd();

    // increasing rotation for the next iteration
    rotateT += 0.2f;
  }
コード例 #9
0
ファイル: Renderer.java プロジェクト: harishd10/cloud-track
 /** @param gl */
 private void loadDefaults(GL2 gl) {
   gl.glLoadIdentity();
   gl.glScaled(scale, scale, scale);
   if (Options.getProjectionMode() == Options.PERSPECTIVE) {
     gl.glTranslatef(0, 0, translate);
   }
 }
コード例 #10
0
ファイル: dof.java プロジェクト: jzy3d/glredbook
  /*
   * accFrustum() The first 6 arguments are identical to the glFrustum() call.
   * pixdx and pixdy are anti-alias jitter in pixels. Set both equal to 0.0
   * for no anti-alias jitter. eyedx and eyedy are depth-of field jitter in
   * pixels. Set both equal to 0.0 for no depth of field effects. focus is
   * distance from eye to plane in focus. focus must be greater than, but not
   * equal to 0.0. Note that accFrustum() calls glTranslatef(). You will
   * probably want to insure that your ModelView matrix has been initialized
   * to identity before calling accFrustum().
   */
  private void accFrustum(
      GL2 gl,
      double left,
      double right,
      double bottom,
      double top,
      double near,
      double far,
      double pixdx,
      double pixdy,
      double eyedx,
      double eyedy,
      double focus) {
    double xwsize, ywsize;
    double dx, dy;
    int viewport[] = new int[4];

    gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);

    xwsize = right - left;
    ywsize = top - bottom;

    dx = -(pixdx * xwsize / (double) viewport[2] + eyedx * near / focus);
    dy = -(pixdy * ywsize / (double) viewport[3] + eyedy * near / focus);

    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glFrustum(left + dx, right + dx, bottom + dy, top + dy, near, far);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef((float) -eyedx, (float) -eyedy, 0.0f);
  }
コード例 #11
0
  private void drawSquare(GL2 gl, GLAutoDrawable drawable, Float x, Float y, Float z) {
    // Pushing to matrix stack
    gl.glPushMatrix();

    // SQUARE
    // Moves the figure in the (x, y, z)-axis
    gl.glTranslatef(x, y, z);

    // Makes so that square is filled in
    gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    // BEGIN Square
    gl.glBegin(GL_QUADS);

    // Pushing to attribute stack
    gl.glPushAttrib(GL_ALL_ATTRIB_BITS);

    // Set color to BLUE
    gl.glColor3f(0.0f, 0.0f, 1.0f);

    // The Quad
    gl.glVertex3f(1.0f, 1.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, 1.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);

    // END Square
    gl.glEnd();

    // Popping state
    gl.glPopAttrib();
    gl.glPopMatrix();
  }
コード例 #12
0
ファイル: clip.java プロジェクト: jzy3d/glredbook
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    //
    double eqn[] = {0.0, 1.0, 0.0, 0.0};
    double eqn2[] = {1.0, 0.0, 0.0, 0.0};

    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    gl.glColor3f(1.0f, 1.0f, 1.0f);
    gl.glPushMatrix();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);

    /* clip lower half -- y < 0 */
    gl.glClipPlane(GL2.GL_CLIP_PLANE0, eqn, 0);
    gl.glEnable(GL2.GL_CLIP_PLANE0);
    /* clip left half -- x < 0 */
    gl.glClipPlane(GL2.GL_CLIP_PLANE1, eqn2, 0);
    gl.glEnable(GL2.GL_CLIP_PLANE1);

    gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
    glut.glutWireSphere(1.0, 20, 16);
    gl.glPopMatrix();

    gl.glFlush();
  }
コード例 #13
0
  /** ***************************************************** */
  public void draw(GL2 gl, GLU glu, Camera cam) {
    if (transform != null) transform.execute(gl);
    gl.glTranslatef(x, y, z);

    applyMaterial(gl);
    gl.glLineWidth(wfwidth);

    // Draw
    GLUquadric qobj = glu.gluNewQuadric();

    if (facestatus) {
      if (wfstatus) {
        gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL);
        gl.glPolygonOffset(1.0f, 1.0f);
      }

      gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
      gl.glNormal3f(norm.x, norm.y, norm.z);
      gl.glColor4f(color.r, color.g, color.b, color.a);
      glu.gluDisk(qobj, radiusInner, radiusOuter, slices, loops);

      if (wfstatus) gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
    }
    if (wfstatus) {
      gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
      gl.glNormal3f(norm.x, norm.y, norm.z);
      gl.glColor4f(wfcolor.r, wfcolor.g, wfcolor.b, wfcolor.a);
      glu.gluDisk(qobj, radiusInner, radiusOuter, slices, loops);
    }
  }
コード例 #14
0
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    GLUT glut = new GLUT();
    // limpa o buer
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    // dene que a matrix é a de modelo
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glScalef(delta, delta, delta); // faça a escala de todos objetos

    gl.glPushMatrix(); // armazena a matriz corrente
    gl.glTranslatef(-3, 0, 0);
    gl.glRotatef(beta, 0, 1, 0);
    gl.glRotatef(alpha, 1, 0, 0);
    gl.glColor3f(1, 1, 0);
    glut.glutWireSphere(1, 20, 20);

    // desenha um piso sob a esfera
    gl.glTranslatef(0, -1, 0);
    gl.glScalef(4, 0.1f, 4);
    gl.glColor3f(0, 0, 1);
    glut.glutSolidCube(1.0f);

    gl.glPopMatrix(); // restaura a matriz anterior

    gl.glPushMatrix(); // armazena a matriz corrente
    gl.glTranslatef(3, 0, 0);
    gl.glRotatef(beta, 0, 1, 0);
    gl.glRotatef(alpha, 1, 0, 0);
    gl.glColor3f(1, 0, 0);
    glut.glutWireSphere(1, 20, 20);

    // desenha um piso sob a esfera
    gl.glTranslatef(0, -1, 0);
    gl.glScalef(4, 0.1f, 4);
    gl.glColor3f(0, 1, 0);
    glut.glutSolidCube(1.0f);

    gl.glPopMatrix(); // restaura a matriz anterior
    // força o desenho das primitivas
    gl.glFlush();
  }
コード例 #15
0
  @Override
  public void beginPoly(int windingRule) {
    /*
     * pen hangs down and to the right. See java.awt.Graphics
     */
    gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glTranslatef(0.5f, 0.5f, 0);

    super.beginPoly(windingRule);
  }
コード例 #16
0
  public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
    GL2 gl = drawable.getGL().getGL2();
    //
    gl.glViewport(0, 0, w, h);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(45.0, 1.0, 0.25, 25.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, -5.0f);
  }
コード例 #17
0
  public void selfDraw(GL2 gl) {

    texture.enable(gl);
    texture.bind(gl);

    gl.glTranslatef(8.65f, -0.8f, 8.8f);

    gl.glPushMatrix();
    gl.glScalef(3f, 3f, 3f);
    gl.glCallList(startList);
    gl.glPopMatrix();
  }
コード例 #18
0
  @Override
  public void draw(GL2 gl) {
    gl.glTranslatef(x, y, z);
    // ----- Render the Color Cube -----
    gl.glBegin(GL_QUADS); // of the color cube

    gl.glColor3f(red, green, blue);
    gl.glVertex3f(-demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(+demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, -demiWidth);
    gl.glVertex3f(-demiWidth, +demiWidth, -demiWidth);

    gl.glVertex3f(-demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(-demiWidth, -demiWidth, +demiWidth);
    gl.glVertex3f(-demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(-demiWidth, +demiWidth, -demiWidth);

    gl.glVertex3f(-demiWidth, -demiWidth, +demiWidth);
    gl.glVertex3f(-demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, -demiWidth, +demiWidth);

    gl.glVertex3f(+demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, -demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, -demiWidth, +demiWidth);

    gl.glVertex3f(+demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(-demiWidth, -demiWidth, -demiWidth);
    gl.glVertex3f(-demiWidth, -demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, -demiWidth, +demiWidth);

    gl.glVertex3f(-demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, +demiWidth);
    gl.glVertex3f(+demiWidth, +demiWidth, -demiWidth);
    gl.glVertex3f(-demiWidth, +demiWidth, -demiWidth);

    gl.glEnd(); // of the color cube
    gl.glTranslatef(-x, -y, -z);
  }
コード例 #19
0
ファイル: GLSandBox.java プロジェクト: MMesbahU/caleydo
  @Override
  public void display(GLAutoDrawable drawable) {
    final int deltaTimeMs = local.getDeltaTimeMs();
    eventListeners.processEvents();

    GL2 gl = drawable.getGL().getGL2();
    final GLGraphics g = new GLGraphics(gl, local, true, deltaTimeMs);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0.375f, 0.375f, 0);

    float paddedWidth = getWidth() - padding.left - padding.right;
    float paddedHeight = getHeight() - padding.top - padding.bottom;
    g.move(padding.left, padding.right);

    if (dirty) {
      root.setBounds(0, 0, paddedWidth, paddedHeight);
      root.relayout();
      dirty = false;
    }

    // 1 pass: picking
    Runnable toRender =
        new Runnable() {
          @Override
          public void run() {
            root.renderPick(g);
          }
        };

    Vec2f mousePos = pickingManager.getCurrentMousePos();
    if (mousePos != null) {
      root.getMouseLayer()
          .setBounds(
              mousePos.x() - padding.left,
              mousePos.y() - padding.top,
              getWidth() - mousePos.x(),
              getHeight() - mousePos.y());
      root.getMouseLayer().relayout();
    }
    pickingManager.doPicking(g.gl, toRender);

    // 2. pass: layout
    root.layout(deltaTimeMs);

    // 3. pass: rendering
    if (renderPick) root.renderPick(g);
    else root.render(g);

    g.move(-padding.left, -padding.right);
  }
コード例 #20
0
  /*
   * display() draws a triangle at an angle.
   */
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    //
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    if (key != null)
      switch (key.getKeyChar()) {
        case 'c':
          gl.glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FRAGMENT_DEPTH);
          break;
        case 'C':
          gl.glFogi(GL2.GL_FOG_COORDINATE_SOURCE, GL2.GL_FOG_COORDINATE);
          break;

        case 'b':
          gl.glMatrixMode(GL2.GL_MODELVIEW);
          gl.glTranslatef(0.0f, 0.0f, -0.25f);
          break;
        case 'f':
          gl.glMatrixMode(GL2.GL_MODELVIEW);
          gl.glTranslatef(0.0f, 0.0f, 0.25f);
          break;
        default:
          break;
      }

    gl.glColor3f(1.0f, 0.75f, 0.0f);
    gl.glBegin(GL2.GL_TRIANGLES);
    gl.glFogCoordf(f1);
    gl.glVertex3f(2.0f, -2.0f, 0.0f);
    gl.glFogCoordf(f2);
    gl.glVertex3f(-2.0f, 0.0f, -5.0f);
    gl.glFogCoordf(f3);
    gl.glVertex3f(0.0f, 2.0f, -10.0f);
    gl.glEnd();

    gl.glFlush();
  }
コード例 #21
0
ファイル: Scene.java プロジェクト: seaworthy/temp
  public void make(FloatBuffer whiteMaterial, FloatBuffer blackMaterial) {
    this.whiteMaterial = whiteMaterial;
    this.blackMaterial = blackMaterial;

    drawSheet();
    for (int i = -2; i <= 2; i++) {
      gl.glPushMatrix();
      // gl.glLoadIdentity();
      gl.glTranslatef(2.f * i, 2.f * i, 0.f);
      drawCube();
      setText("Object");
      gl.glPopMatrix();
    }
  }
コード例 #22
0
  // Support Methods
  private void drawPyramid(GL2 gl, GLAutoDrawable drawable, Float x, Float y, Float z) {
    // Pushing to matrix stack
    gl.glPushMatrix();

    // PYRAMID
    // Moves the figure in the (x, y, z)-axis
    gl.glTranslatef(x, y, z);

    // Rotates the pyramid, just for "fun"
    gl.glRotatef(-55.0f, 0.0f, 1.0f, 0.0f);

    // Makes only the outlines
    gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

    // BEGIN Pyramid
    gl.glBegin(GL_TRIANGLES);

    // Pushing current color to stack
    gl.glPushAttrib(GL_ALL_ATTRIB_BITS);

    // Set color to RED
    gl.glColor3f(1.0f, 0.0f, 0.0f);

    // Front triangle
    gl.glVertex3f(0.0f, 1.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);

    // Right triangle
    gl.glVertex3f(0.0f, 1.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);
    gl.glVertex3f(1.0f, -1.0f, -1.0f);

    // Left triangle
    gl.glVertex3f(0.0f, 1.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, -1.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);

    // Back triangle
    gl.glVertex3f(0.0f, 1.0f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, -1.0f);
    gl.glVertex3f(-1.0f, -1.0f, -1.0f);

    // END Pyramid
    gl.glEnd();

    // Popping state
    gl.glPopAttrib();
    gl.glPopMatrix();
  }
コード例 #23
0
ファイル: Tunnelblick.java プロジェクト: AltSysrq/tunnelblick
 public void configureGL(GL2 gl) {
   gl.glEnable(GL2.GL_FOG);
   gl.glFogi(GL2.GL_FOG_MODE, GL2.GL_LINEAR);
   gl.glFogf(GL2.GL_FOG_DENSITY, 0.25f);
   gl.glFogf(GL2.GL_FOG_START, Math.max(getNearClippingPlane(), fadeOut * 1.0f));
   gl.glFogf(GL2.GL_FOG_END, Math.max(1.1f, fadeOut * 1.1f * getSpawnDistance()));
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glFrustumf(-1, 1, -man.vheight(), man.vheight(), getNearClippingPlane(), 128.0f);
   gl.glScalef(2.0f, 2.0f, 1);
   gl.glTranslatef(-0.5f, -man.vheight() / 2.0f, 0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
コード例 #24
0
  public void drawTextureToOffScreenTexture(int texId, int attachment)
        // public void drawTextureToOffScreenTextureUsingShader(Texture tex, int attachment, Program
        // program)
      {
    GL2 gl = getGL();

    // program.bind(gl);

    gl.glBindTexture(GL_TEXTURE_2D, texId);
    // gl.glBindTexture(GL_TEXTURE_2D, tex.getTextureObject());
    // gl.glDrawBuffer(attachment);
    gl.glBindFramebuffer(GL_FRAMEBUFFER, attachment); // think this is the new way...

    gl.glEnable(GL_TEXTURE_2D);
    // gl.glActiveTexture(GL_TEXTURE0);
    gl.glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

    gl.glViewport(0, 0, fboWidth, fboHeight);

    // gl.glUniform1i(program.uniform("theTexture"), 0);
    // set projection to ortho
    gl.glMatrixMode(GL_PROJECTION);
    gl.glTranslatef(1f, 1f, 1f);

    gl.glPushMatrix();
    {
      gl.glLoadIdentity();
      RenderUtils.getGLU().gluOrtho2D(0, fboWidth, fboHeight, 0);

      gl.glMatrixMode(gl.GL_MODELVIEW);

      gl.glPushMatrix();
      {
        gl.glLoadIdentity();

        gl.glColor4f(1f, 1f, 1f, 1f);
        drawSquare(gl, 0, 0, fboWidth, fboHeight);
      }
      gl.glPopMatrix();

      gl.glMatrixMode(gl.GL_PROJECTION);
    }
    gl.glPopMatrix();

    gl.glMatrixMode(gl.GL_MODELVIEW);

    gl.glDisable(GL_TEXTURE_2D);
    // program.unbind(gl);
  }
コード例 #25
0
  @Override
  public void draw(float fXCenter, float fYCenter, GL2 gl, GLU glu) {

    HashMap<PartialDisc, PDDrawingStrategySelected> mapSelectedDrawingStrategies =
        new HashMap<PartialDisc, PDDrawingStrategySelected>();
    parentIndicatorType = SelectionType.NORMAL;

    initDrawingStrategies(mapSelectedDrawingStrategies);

    PartialDisc pdCurrentRootElement = radialHierarchy.getCurrentRootElement();

    gl.glLoadIdentity();
    gl.glTranslatef(fXCenter, fYCenter, 0);

    float fHierarchyOuterRadius =
        Math.min(
            fXCenter * RadialHierarchyRenderStyle.USED_SCREEN_PERCENTAGE,
            fYCenter * RadialHierarchyRenderStyle.USED_SCREEN_PERCENTAGE);
    float fDiscWidth = fHierarchyOuterRadius / iDisplayedHierarchyDepth;

    pdCurrentRootElement.drawHierarchyFull(gl, glu, fDiscWidth, iDisplayedHierarchyDepth);

    // The selected elements have to be drawn (again using their own drawing
    // strategy) at last for
    // correct antialiasing

    for (PartialDisc pdSelected : mapSelectedDrawingStrategies.keySet()) {
      PDDrawingStrategySelected dsCurrent = mapSelectedDrawingStrategies.get(pdSelected);
      dsCurrent.drawPartialDisc(gl, glu, pdSelected);
    }

    if (parentIndicatorType != SelectionType.NORMAL) {
      gl.glPushClientAttrib(GL.GL_COLOR_BUFFER_BIT);
      if (parentIndicatorType == SelectionType.SELECTION)
        gl.glColor3fv(SelectionType.SELECTION.getColor().getRGB(), 0);
      else gl.glColor3fv(SelectionType.MOUSE_OVER.getColor().getRGB(), 0);
      GLPrimitives.renderCircle(glu, fDiscWidth / 2.0f, 100);
      GLPrimitives.renderCircleBorder(gl, glu, fDiscWidth / 2.0f, 100, 2);
      gl.glPopAttrib();
    }

    LabelManager.get()
        .drawAllLabels(gl, glu, fXCenter * 2.0f, fYCenter * 2.0f, fHierarchyOuterRadius);
    LabelManager.get().clearLabels();

    radialHierarchy.setNewSelection(false);
  }
コード例 #26
0
  @Override
  public void render(GL2 gl, float trajectory) {
    if (!dead) {
      gl.glPushMatrix();
      {
        gl.glTranslatef(bound.c.x, bound.c.y, bound.c.z);
        gl.glRotatef(rotation, 0, -1, 0);
        gl.glScalef(1.5f, 1.5f, 1.5f);

        Shader shader = Shader.getLightModel("texture");
        if (shader != null) shader.enable(gl);

        gl.glCallList(shellList);

        spikeNode.render(gl);
        rimNode.render(gl);
      }
      gl.glPopMatrix();

      Shader.disable(gl);
    } else if (!blast.isEmpty() && !Scene.shadowMode) {
      boolean useHDR = BloomStrobe.isEnabled();

      if (Scene.reflectMode) BloomStrobe.end(gl);

      if (Scene.singleton.enableBloom) renderBlast(gl);
      else BlastParticle.renderList(gl, blast);

      if (useHDR) BloomStrobe.begin(gl);

      Shader.disable(gl);
    }

    if (blastDuration <= 1) blastLight.disable(gl);
    else blastLight.enable(gl);
  }
コード例 #27
0
ファイル: dof.java プロジェクト: jzy3d/glredbook
  private void renderTeapot(
      GL2 gl,
      float x,
      float y,
      float z,
      float ambr,
      float ambg,
      float ambb,
      float difr,
      float difg,
      float difb,
      float specr,
      float specg,
      float specb,
      float shine) {
    float mat[] = new float[4];

    gl.glPushMatrix();
    gl.glTranslatef(x, y, z);
    mat[0] = ambr;
    mat[1] = ambg;
    mat[2] = ambb;
    mat[3] = 1.0f;
    gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, mat, 0);
    mat[0] = difr;
    mat[1] = difg;
    mat[2] = difb;
    gl.glMaterialfv(GL.GL_FRONT, GL2.GL_DIFFUSE, mat, 0);
    mat[0] = specr;
    mat[1] = specg;
    mat[2] = specb;
    gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, mat, 0);
    gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, shine * 128.0f);
    gl.glCallList(teapotList);
    gl.glPopMatrix();
  }
コード例 #28
0
 public void interact(GL2 gl) {
   gl.glTranslatef(0, 0, z);
   gl.glRotatef(rotx, 1f, 0f, 0f);
   gl.glRotatef(roty, 0f, 1.0f, 0f);
 }
コード例 #29
0
ファイル: Renderer.java プロジェクト: Jotschi/jogl2-example
  public void display(GLAutoDrawable drawable) {
    update();

    GL2 gl = drawable.getGL().getGL2();
    // Clear Color Buffer, Depth Buffer
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

    Matrix TmpMatrix = new Matrix(); // Temporary MATRIX Structure ( NEW )
    Vector TmpVector = new Vector(), TmpNormal = new Vector(); // Temporary
    // VECTOR
    // Structures
    // ( NEW )

    gl.glLoadIdentity(); // Reset The Matrix

    if (outlineSmooth) { // Check To See If We Want Anti-Aliased Lines ( NEW
      // )
      gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST); // Use The Good
      // Calculations
      // ( NEW )
      gl.glEnable(GL2.GL_LINE_SMOOTH); // Enable Anti-Aliasing ( NEW )
    } else
      // We Don't Want Smooth Lines ( NEW )
      gl.glDisable(GL2.GL_LINE_SMOOTH); // Disable Anti-Aliasing ( NEW )

    gl.glTranslatef(0.0f, 0.0f, -2.0f); // Move 2 Units Away From The Screen
    // ( NEW )
    gl.glRotatef(modelAngle, 0.0f, 1.0f, 0.0f); // Rotate The Model On It's
    // Y-Axis ( NEW )

    gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, TmpMatrix.Data, 0); // Get
    // The
    // Generated
    // Matrix
    // (
    // NEW
    // )

    // Cel-Shading Code //
    gl.glEnable(GL2.GL_TEXTURE_1D); // Enable 1D Texturing ( NEW )
    gl.glBindTexture(GL2.GL_TEXTURE_1D, shaderTexture[0]); // Bind Our
    // Texture ( NEW
    // )
    gl.glColor3f(1.0f, 1.0f, 1.0f); // Set The Color Of The Model ( NEW )

    gl.glBegin(GL2.GL_TRIANGLES); // Tell OpenGL That We're Drawing
    // Triangles
    // Loop Through Each Polygon
    for (int i = 0; i < polyNum; i++)
      // Loop Through Each Vertex
      for (int j = 0; j < 3; j++) {

        // Fill Up The TmpNormal Structure With
        TmpNormal.X = polyData[i].Verts[j].Nor.X;
        // The Current Vertices' Normal Values
        TmpNormal.Y = polyData[i].Verts[j].Nor.Y;
        TmpNormal.Z = polyData[i].Verts[j].Nor.Z;
        // Rotate This By The Matrix
        TmpMatrix.rotateVector(TmpNormal, TmpVector);
        // Normalize The New Normal
        TmpVector.normalize();

        // Calculate The Shade Value
        float TmpShade = Vector.dotProduct(TmpVector, lightAngle);

        // Clamp The Value to 0 If Negative ( NEW )
        if (TmpShade < 0.0f) {
          TmpShade = 0.0f;
        }
        // Set The Texture Co-ordinate As The Shade Value
        gl.glTexCoord1f(TmpShade);
        // Send The Vertex Position
        gl.glVertex3f(
            polyData[i].Verts[j].Pos.X, polyData[i].Verts[j].Pos.Y, polyData[i].Verts[j].Pos.Z);
      }

    gl.glEnd(); // Tell OpenGL To Finish Drawing
    gl.glDisable(GL2.GL_TEXTURE_1D); // Disable 1D Textures ( NEW )

    // Outline Code
    // Check To See If We Want To Draw The Outline
    if (outlineDraw) {
      // Enable Blending
      gl.glEnable(GL2.GL_BLEND);
      // Set The Blend Mode
      gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

      // Draw Backfacing Polygons As Wireframes
      gl.glPolygonMode(GL2.GL_BACK, GL2.GL_LINE);
      // Set The Line Width
      gl.glLineWidth(outlineWidth);
      // Don't Draw Any Front-Facing Polygons
      gl.glCullFace(GL2.GL_FRONT);

      // Change The Depth Mode
      gl.glDepthFunc(GL2.GL_LEQUAL);
      // Set The Outline Color
      gl.glColor3fv(outlineColor, 0);

      // Tell OpenGL What We Want To Draw
      gl.glBegin(GL2.GL_TRIANGLES);

      // Loop Through Each Polygon
      for (int i = 0; i < polyNum; i++) {

        // Loop Through Each Vertex
        for (int j = 0; j < 3; j++) {

          // Send The Vertex Position
          gl.glVertex3f(
              polyData[i].Verts[j].Pos.X, polyData[i].Verts[j].Pos.Y, polyData[i].Verts[j].Pos.Z);
        }
      }
      gl.glEnd(); // Tell OpenGL We've Finished
      // Reset The Depth-Testing Mode
      gl.glDepthFunc(GL2.GL_LESS);
      // Reset The Face To Be Culled
      gl.glCullFace(GL2.GL_BACK);
      // Reset Back-Facing Polygon Drawing Mode
      gl.glPolygonMode(GL2.GL_BACK, GL2.GL_FILL);

      // Disable Blending
      gl.glDisable(GL2.GL_BLEND);
    }

    // Check To See If Rotation Is Enabled
    if (modelRotate) {
      // Update Angle Based On The Clock
      modelAngle += .2f;
    }
  }
コード例 #30
0
  public void render(GL2 gl2) {
    int i;

    boolean draw_finger_star = false;
    boolean draw_base_star = false;
    boolean draw_shoulder_to_elbow = false;
    boolean draw_shoulder_star = false;
    boolean draw_elbow_star = false;
    boolean draw_wrist_star = false;
    boolean draw_stl = true;

    // RebuildShoulders(motion_now);

    gl2.glPushMatrix();
    gl2.glTranslated(position.x, position.y, position.z);

    if (draw_stl) {
      // base
      gl2.glPushMatrix();
      gl2.glColor3f(0, 0, 1);
      gl2.glTranslatef(0, 0, BASE_TO_SHOULDER_Z + 0.6f);
      gl2.glRotatef(90, 0, 0, 1);
      gl2.glRotatef(90, 1, 0, 0);
      modelBase.render(gl2);
      gl2.glPopMatrix();

      // arms
      for (i = 0; i < 3; ++i) {
        gl2.glColor3f(1, 0, 1);
        gl2.glPushMatrix();
        gl2.glTranslatef(
            motion_now.arms[i * 2 + 0].shoulder.x,
            motion_now.arms[i * 2 + 0].shoulder.y,
            motion_now.arms[i * 2 + 0].shoulder.z);
        gl2.glRotatef(120.0f * i, 0, 0, 1);
        gl2.glRotatef(90, 0, 1, 0);
        gl2.glRotatef(180 - motion_now.arms[i * 2 + 0].angle, 0, 0, 1);
        modelArm.render(gl2);
        gl2.glPopMatrix();

        gl2.glColor3f(1, 1, 0);
        gl2.glPushMatrix();
        gl2.glTranslatef(
            motion_now.arms[i * 2 + 1].shoulder.x,
            motion_now.arms[i * 2 + 1].shoulder.y,
            motion_now.arms[i * 2 + 1].shoulder.z);
        gl2.glRotatef(120.0f * i, 0, 0, 1);
        gl2.glRotatef(90, 0, 1, 0);
        gl2.glRotatef(+motion_now.arms[i * 2 + 1].angle, 0, 0, 1);
        modelArm.render(gl2);
        gl2.glPopMatrix();
      }
      // top
      gl2.glPushMatrix();
      gl2.glColor3f(0, 1, 0);
      gl2.glTranslatef(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z);
      gl2.glRotatef(motion_now.iku, 1, 0, 0);
      gl2.glRotatef(motion_now.ikv, 0, 1, 0);
      gl2.glRotatef(motion_now.ikw, 0, 0, 1);
      gl2.glRotatef(90, 0, 0, 1);
      gl2.glRotatef(180, 1, 0, 0);
      modelTop.render(gl2);
      gl2.glPopMatrix();
    }

    // draw the forearms

    Cylinder tube = new Cylinder();
    gl2.glColor3f(0.8f, 0.8f, 0.8f);
    tube.setRadius(0.15f);
    for (i = 0; i < 6; ++i) {
      // gl2.glBegin(GL2.GL_LINES);
      // gl2.glColor3f(1,0,0);
      // gl2.glVertex3f(motion_now.arms[i].wrist.x,motion_now.arms[i].wrist.y,motion_now.arms[i].wrist.z);
      // gl2.glColor3f(0,1,0);
      // gl2.glVertex3f(motion_now.arms[i].elbow.x,motion_now.arms[i].elbow.y,motion_now.arms[i].elbow.z);
      // gl2.glEnd();
      tube.SetP1(motion_now.arms[i].wrist);
      tube.SetP2(motion_now.arms[i].elbow);
      PrimitiveSolids.drawCylinder(gl2, tube);
    }

    gl2.glDisable(GL2.GL_LIGHTING);
    // debug info
    gl2.glPushMatrix();
    for (i = 0; i < 6; ++i) {
      gl2.glColor3f(1, 1, 1);
      if (draw_shoulder_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].shoulder, 5);
      if (draw_elbow_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].elbow, 3);
      if (draw_wrist_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].wrist, 1);

      if (draw_shoulder_to_elbow) {
        gl2.glBegin(GL2.GL_LINES);
        gl2.glColor3f(0, 1, 0);
        gl2.glVertex3f(
            motion_now.arms[i].elbow.x, motion_now.arms[i].elbow.y, motion_now.arms[i].elbow.z);
        gl2.glColor3f(0, 0, 1);
        gl2.glVertex3f(
            motion_now.arms[i].shoulder.x,
            motion_now.arms[i].shoulder.y,
            motion_now.arms[i].shoulder.z);
        gl2.glEnd();
      }
    }
    gl2.glPopMatrix();

    if (draw_finger_star) {
      // draw finger orientation
      float s = 2;
      gl2.glBegin(GL2.GL_LINES);
      gl2.glColor3f(1, 1, 1);
      gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z);
      gl2.glVertex3f(
          motion_now.finger_tip.x + motion_now.finger_forward.x * s,
          motion_now.finger_tip.y + motion_now.finger_forward.y * s,
          motion_now.finger_tip.z + motion_now.finger_forward.z * s);
      gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z);
      gl2.glVertex3f(
          motion_now.finger_tip.x + motion_now.finger_up.x * s,
          motion_now.finger_tip.y + motion_now.finger_up.y * s,
          motion_now.finger_tip.z + motion_now.finger_up.z * s);
      gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z);
      gl2.glVertex3f(
          motion_now.finger_tip.x + motion_now.finger_left.x * s,
          motion_now.finger_tip.y + motion_now.finger_left.y * s,
          motion_now.finger_tip.z + motion_now.finger_left.z * s);

      gl2.glEnd();
    }

    if (draw_base_star) {
      // draw finger orientation
      float s = 2;
      gl2.glDisable(GL2.GL_DEPTH_TEST);
      gl2.glBegin(GL2.GL_LINES);
      gl2.glColor3f(1, 0, 0);
      gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z);
      gl2.glVertex3f(
          motion_now.base.x + motion_now.base_forward.x * s,
          motion_now.base.y + motion_now.base_forward.y * s,
          motion_now.base.z + motion_now.base_forward.z * s);
      gl2.glColor3f(0, 1, 0);
      gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z);
      gl2.glVertex3f(
          motion_now.base.x + motion_now.base_up.x * s,
          motion_now.base.y + motion_now.base_up.y * s,
          motion_now.base.z + motion_now.base_up.z * s);
      gl2.glColor3f(0, 0, 1);
      gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z);
      gl2.glVertex3f(
          motion_now.base.x + motion_now.finger_left.x * s,
          motion_now.base.y + motion_now.finger_left.y * s,
          motion_now.base.z + motion_now.finger_left.z * s);

      gl2.glEnd();
      gl2.glEnable(GL2.GL_DEPTH_TEST);
    }

    gl2.glEnable(GL2.GL_LIGHTING);

    gl2.glPopMatrix();
  }