uvmap_aligncheckplane.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Plane with alignment check pattern for bonus chapter UV Mapping
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #include <world.h>
  10. #include <light.h>
  11. #include <sphere.h>
  12. #include <plane.h>
  13. #include <material.h>
  14. #include <colour.h>
  15. #include <canvas.h>
  16. #include <camera.h>
  17. #include <pattern.h>
  18. #include <texturemap.h>
  19. #include <uv_checkers.h>
  20. #include <uv_aligncheck.h>
  21. #include <transformation.h>
  22. int main()
  23. {
  24. World w = World();
  25. Light light = Light(POINT_LIGHT, Point(-10, 10, -10), Colour(1, 1, 1));
  26. w.addLight(&light);
  27. Plane sp = Plane();
  28. UVAlignCheck checkers = UVAlignCheck(Colour(1, 1, 1),
  29. Colour(1, 0, 0),
  30. Colour(1, 1, 0),
  31. Colour(0, 1, 0),
  32. Colour(0, 1, 1)
  33. );
  34. TextureMap tm = TextureMap(PLANAR_MAP, &checkers);
  35. sp.material.pattern = &tm;
  36. sp.material.ambient = 0.1;
  37. sp.material.diffuse = 0.8;
  38. w.addObject(&sp);
  39. /* Set the camera */
  40. Camera camera = Camera(400, 400, 0.5);
  41. camera.setTransform(viewTransform(Point(1, 2, -5),
  42. Point(0, 0, 0),
  43. Vector(0, 1, 0)));
  44. /* Now render it */
  45. Canvas image = camera.render(w);
  46. image.SaveAsPNG("uvmap_aligncheckplane.png");
  47. return 0;
  48. }