camera.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Camera header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_CAMERA_H
  10. #define DORAYME_CAMERA_H
  11. #include <matrix.h>
  12. #include <stdint.h>
  13. #include <ray.h>
  14. #include <canvas.h>
  15. #include <world.h>
  16. class Camera
  17. {
  18. private:
  19. double halfWidth;
  20. double halfHeight;
  21. public:
  22. double focalDistance;
  23. double apertureSize;
  24. uint32_t rayCount;
  25. uint32_t verticalSize;
  26. uint32_t horizontalSize;
  27. double fieldOfView;
  28. double pixelSize;
  29. Matrix transformMatrix;
  30. Matrix inverseTransform;
  31. public:
  32. Camera(uint32_t hsize, uint32_t vsize, double fov);
  33. void setFocal(double focal, double aperture, uint32_t rayCount) {
  34. this->focalDistance = focal;
  35. this->apertureSize = aperture;
  36. this->rayCount = rayCount;
  37. }
  38. void setTransform(Matrix transform);
  39. Ray rayForPixel(uint32_t pixelX, uint32_t pixelY, double horzOffset = 0, double vertOffset = 0);
  40. Canvas render(World w, uint32_t depth = 5);
  41. };
  42. #endif /* DORAYME_CAMERA_H */