MovieCamera.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <cstdint>
  17. #include <string>
  18. #include <vector>
  19. /**
  20. * The cameras of the movies, in moviecam.lgp.
  21. *
  22. * Each movie has a camera file, with 40 bytes per frame: a rotation matrix, a translation and the
  23. * projection. The models of a field are drawn with it over the movie. The frames in which the
  24. * movie has no camera are all zero.
  25. */
  26. namespace MovieCamera{
  27. /**
  28. * Size of the camera data of a frame.
  29. */
  30. const size_t FRAME_SIZE = 40;
  31. /**
  32. * Retrieves the first frame of a movie that has a camera.
  33. *
  34. * @param[in] camera Content of the camera file.
  35. * @return The frame, or -1 if no frame has a camera.
  36. */
  37. int FirstCameraFrame(const std::vector<uint8_t>& camera);
  38. /**
  39. * Reads a file of an LGP archive.
  40. *
  41. * @param[in] archive Content of the archive.
  42. * @param[in] name Name of the file, such as "opening.cam".
  43. * @param[out] content The content of the file.
  44. * @return True if the file was found.
  45. */
  46. bool ReadLgpFile(
  47. const std::vector<uint8_t>& archive, const std::string& name, std::vector<uint8_t>& content
  48. );
  49. /**
  50. * Reads the camera of a movie from moviecam.lgp.
  51. *
  52. * @param[in] lgp_path Path to moviecam.lgp.
  53. * @param[in] movie Name of the movie, without extension.
  54. * @return The content of the camera file. Empty if the archive or the camera can't be read.
  55. */
  56. std::vector<uint8_t> LoadCamera(const std::string& lgp_path, const std::string& movie);
  57. }