world.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * World header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_WORLD_H
  10. #define DORAYME_WORLD_H
  11. #include <stdint.h>
  12. #include <light.h>
  13. #include <shape.h>
  14. #include <intersect.h>
  15. #include <ray.h>
  16. #include <stdio.h>
  17. #ifdef ENABLE_LUA_SUPPORT
  18. extern "C" {
  19. #include <lua.h>
  20. }
  21. #endif
  22. class World
  23. {
  24. public:
  25. uint32_t objectCount;
  26. uint32_t lightCount;
  27. private:
  28. uint32_t allocatedObjectCount;
  29. uint32_t allocatedLightCount;
  30. Light* *lightList;
  31. Shape* *objectList;
  32. #ifdef ENABLE_LUA_SUPPORT
  33. lua_State *L;
  34. #endif
  35. public:
  36. World();
  37. ~World();
  38. void addObject(Shape *s);
  39. void addLight(Light *l);
  40. /* Some debug things */
  41. bool lightIsIn(Light &l);
  42. bool objectIsIn(Shape &s);
  43. Shape *getObject(int i) { return this->objectList[i]; };
  44. Light *getLight(int i) { return this->lightList[i]; };
  45. Tuple shadeHit(Computation comps, uint32_t depthCount = 4);
  46. Tuple colourAt(Ray r, uint32_t depthCount = 4);
  47. bool isShadowed(Tuple point, Tuple lightPosition);
  48. Colour reflectColour(Computation comps, uint32_t depthCount = 4);
  49. Colour refractedColour(Computation comps, uint32_t depthCount = 4);
  50. Intersect intersect(Ray r);
  51. void dumpMe(FILE *fp);
  52. };
  53. #endif /* DORAYME_WORLD_H */