world.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include <group.h>
  18. #ifdef ENABLE_LUA_SUPPORT
  19. extern "C" {
  20. #include <lua.h>
  21. }
  22. #endif
  23. class World
  24. {
  25. public:
  26. uint32_t lightCount;
  27. private:
  28. uint32_t allocatedLightCount;
  29. Light* *lightList;
  30. Group worldGroup;
  31. #ifdef ENABLE_LUA_SUPPORT
  32. lua_State *L;
  33. #endif
  34. public:
  35. World();
  36. ~World();
  37. void addObject(Shape *s);
  38. void addLight(Light *l);
  39. /* Some debug things */
  40. bool lightIsIn(Light &l);
  41. bool objectIsIn(Shape &s);
  42. Shape *getObject(int i) { return this->worldGroup[i]; };
  43. Light *getLight(int i) { return this->lightList[i]; };
  44. uint32_t getObjectCount() { return this->worldGroup.getObjectCount(); };
  45. uint32_t getLightCount() { return this->lightCount; };
  46. Tuple shadeHit(Computation comps, uint32_t depthCount = 4);
  47. Tuple colourAt(Ray r, uint32_t depthCount = 4);
  48. bool isShadowed(Tuple point, Tuple lightPosition);
  49. Colour reflectColour(Computation comps, uint32_t depthCount = 4);
  50. Colour refractedColour(Computation comps, uint32_t depthCount = 4);
  51. Intersect intersect(Ray r);
  52. void dumpMe(FILE *fp);
  53. };
  54. #endif /* DORAYME_WORLD_H */