Esempio n. 1
0
  @Override
  public void display() {

    gl.glClear(GL4.GL_COLOR_BUFFER_BIT | GL4.GL_DEPTH_BUFFER_BIT);

    // Initialize with the identity matrix ...
    modelMatrix.loadIdentity();

    // Create the view matrix.
    viewMatrix.loadIdentity();
    viewMatrix.lookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

    // The calculations are done in camera / view space.
    // So pass the view matrix, which is a rigid body transform.
    normalMatrix.extract(viewMatrix);

    // MV = V * M (M is identity)
    modelViewMatrix.multiply(viewMatrix, modelMatrix);

    modelViewMatrix.bind();
    normalMatrix.bind();

    light.setDirOrPos(Matrix4.multiplyVector3(viewMatrix.getMatrix(), light.getDirOrPos()));

    light.bind();
    material.bind();

    model.bind();
    model.draw(GL4.GL_TRIANGLES);

    gl.glFlush();
  }
Esempio n. 2
0
  @Override
  public void reshape(final int x, final int y, final int width, final int height) {

    gl.glViewport(0, 0, width, height);

    projectionMatrix.loadIdentity();
    projectionMatrix.perspective(40f, aspect, 1.0f, 100.0f);
    projectionMatrix.bind();
  }