world.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include <worldoptimiser.h>
  19. #ifdef ENABLE_LUA_SUPPORT
  20. extern "C" {
  21. #include <lua.h>
  22. }
  23. #endif
  24. class World
  25. {
  26. public:
  27. uint32_t lightCount;
  28. private:
  29. uint32_t allocatedLightCount;
  30. Light* *lightList;
  31. Group worldGroup;
  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->worldGroup[i]; };
  44. Light *getLight(int i) { return this->lightList[i]; };
  45. uint32_t getObjectCount() { return this->worldGroup.getObjectCount(); };
  46. uint32_t getLightCount() { return this->lightCount; };
  47. Tuple shadeHit(Computation comps, uint32_t depthCount = 4);
  48. Tuple colourAt(Ray r, uint32_t depthCount = 4);
  49. bool isShadowed(Tuple point, Tuple lightPosition);
  50. Colour reflectColour(Computation comps, uint32_t depthCount = 4);
  51. Colour refractedColour(Computation comps, uint32_t depthCount = 4);
  52. Intersect intersect(Ray r);
  53. void finalise(WorldOptimiser &opt);
  54. void dumpMe(FILE *fp);
  55. };
  56. #endif /* DORAYME_WORLD_H */