Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2013
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class Camera {
  2. public static float fov, aspect, near, far, x, y, z, rx, ry, rz;
  3.  
  4. public static void init(float x, float y, float z, float rx, float ry, float rz, float fov, float aspect, float near, float far) {
  5. Camera.x = x;
  6. Camera.y = y;
  7. Camera.z = z;
  8. Camera.rx = rx;
  9. Camera.ry = ry;
  10. Camera.rz = rz;
  11. Camera.fov = fov;
  12. Camera.aspect = aspect;
  13. Camera.near = near;
  14. Camera.far = far;
  15. initGl(x, y, z, rx, ry, rz, fov, aspect, near, far);
  16. }
  17.  
  18. public static void initGl(float x, float y, float z, float rx, float ry, float rz, float fov, float aspect, float near, float far) {
  19. glMatrixMode(GL_PROJECTION);
  20. glLoadIdentity();
  21. gluPerspective(fov, aspect, near, far);
  22. glMatrixMode(GL_MODELVIEW);
  23.  
  24. glEnable(GL_DEPTH);
  25. glEnable(GL_DEPTH_FUNC);
  26. glDepthFunc(GL_LEQUAL);
  27.  
  28. useTraits();
  29. }
  30.  
  31. public static void useTraits() {
  32. glPushMatrix();
  33. glRotatef(rx, 1, 0, 0);
  34. glRotatef(ry, 0, 1, 0);
  35. glRotatef(rz, 0, 0, 1);
  36. glTranslatef(x, y, z);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement