tileanimation.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Minetest
  3. Copyright (C) 2016 sfan5 <sfan5@live.de>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <iostream>
  18. #include "irrlichttypes_bloated.h"
  19. enum TileAnimationType
  20. {
  21. TAT_NONE = 0,
  22. TAT_VERTICAL_FRAMES = 1,
  23. TAT_SHEET_2D = 2,
  24. };
  25. struct TileAnimationParams
  26. {
  27. enum TileAnimationType type;
  28. union
  29. {
  30. // struct {
  31. // } none;
  32. struct
  33. {
  34. int aspect_w; // width for aspect ratio
  35. int aspect_h; // height for aspect ratio
  36. float length; // seconds
  37. } vertical_frames;
  38. struct
  39. {
  40. int frames_w; // number of frames left-to-right
  41. int frames_h; // number of frames top-to-bottom
  42. float frame_length; // seconds
  43. } sheet_2d;
  44. };
  45. void serialize(std::ostream &os, u8 tiledef_version) const;
  46. void deSerialize(std::istream &is, u8 tiledef_version);
  47. void determineParams(v2u32 texture_size, int *frame_count, int *frame_length_ms,
  48. v2u32 *frame_size) const;
  49. void getTextureModifer(std::ostream &os, v2u32 texture_size, int frame) const;
  50. v2f getTextureCoords(v2u32 texture_size, int frame) const;
  51. };