@Override
  public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    GLES20.glViewport(0, 0, width, height);
    ratio = (float) width / height;

    Matrix.perspectiveM(
        mProjectionMatrix,
        0,
        FOV / (float) Math.PI * 180.0f,
        ratio,
        len / LEN_RANGE,
        len * LEN_RANGE);
    Matrix.setLookAtM(
        mViewMatrix,
        0,
        matCam[0] * len,
        matCam[1] * len,
        matCam[2] * len,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        1.0f);

    float[] lightPos = {len, len, 0};
    GLES20.glUniform3fv(mLightPosHandle, 1, lightPos, 0);
  }
Exemplo n.º 2
0
 @Override
 public void onSurfaceChanged(GL10 unused, int width, int height) {
   float aspect = (float) width / height;
   Matrix.perspectiveM(mMatrixProjection, 0, 60f, aspect, .1f, 10f);
   Matrix.setLookAtM(mMatrixView, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0);
   Matrix.multiplyMM(mMatrixModelViewProjection, 0, mMatrixProjection, 0, mMatrixView, 0);
   mLastRenderTime = -1;
 }
 @Override
 public void onSurfaceChanged(GL10 unused, int width, int height) {
   float aspect = (float) width / height;
   Matrix.perspectiveM(mMatrixProjection, 0, 60f, aspect, .1f, 10f);
   Matrix.setLookAtM(mMatrixView, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0);
 }
  public void camZoom(float exp) {
    len = LEN_DEFAULT * (float) Math.pow(LEN_RANGE, exp);

    Matrix.perspectiveM(
        mProjectionMatrix,
        0,
        FOV / (float) Math.PI * 180.0f,
        ratio,
        len / LEN_RANGE,
        len * LEN_RANGE);
    Matrix.setLookAtM(
        mViewMatrix,
        0,
        matCam[0] * len,
        matCam[1] * len,
        matCam[2] * len,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        1.0f);

    float[] lightPos = {len, len, 0};
    GLES20.glUniform3fv(mLightPosHandle, 1, lightPos, 0);
  }