Advertisement
Guest User

Untitled

a guest
Feb 19th, 2013
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  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.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement