Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class ParallaxCamera extends OrthographicCamera
  2. {
  3. Matrix4 parallaxView = new Matrix4 ();
  4. Matrix4 parallaxCombined = new Matrix4 ();
  5. Vector3 tmp = new Vector3 ();
  6. Vector3 tmp_2 = new Vector3 ();
  7.  
  8. public ParallaxCamera (float viewportWidth, float viewportHeight) { super (viewportWidth, viewportHeight); }
  9.  
  10. public Matrix4 calculateMatrix (float x, float y)
  11. {
  12. update ();
  13. tmp.set (position);
  14. tmp.x *= x;
  15. tmp.y *= y;
  16.  
  17. parallaxView.setToLookAt (tmp, tmp_2.set (tmp).add (direction), up);
  18. parallaxCombined.set (projection);
  19. Matrix4.mul (parallaxCombined.val, parallaxView.val);
  20.  
  21. return parallaxCombined;
  22. }
  23. }
  24.  
  25. clickPos.set (Gdx.input.getX (), Gdx.input.getY (), 0);
  26. camera.unproject (clickPos);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement