Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 19th, 2013  |  syntax: Java  |  size: 0.71 KB  |  views: 170  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void setPerspectiveView(float fov, float aspectRatio, float near, float far) {
  2.                 float radians = (float) Math.toRadians(fov * 0.5f);
  3.                 float coTan2 = (float) (1.0f / Math.tan(radians));
  4.                 float yScale = coTan2;
  5.                 float xScale = yScale / aspectRatio;
  6.                
  7.                 projMat.set(0, xScale);
  8.                 projMat.set(1, 0.0f);
  9.                 projMat.set(2, 0.0f);
  10.                 projMat.set(3, 0.0f);
  11.                
  12.                 projMat.set(4, 0.0f);
  13.                 projMat.set(5, yScale);
  14.                 projMat.set(6, 0.0f);
  15.                 projMat.set(7, 0.0f);
  16.                
  17.                 projMat.set(8, 0.0f);
  18.                 projMat.set(9, 0.0f);
  19.                 projMat.set(10, far / (near - far));
  20.                 projMat.set(11, -1.0f);
  21.                
  22.                 projMat.set(12, 0.0f);
  23.                 projMat.set(13, 0.0f);
  24.                 projMat.set(14, near * far / (near - far));
  25.                 projMat.set(15, 0.0f);
  26.         }