Minetest  5.4.0
tileanimation.h
Go to the documentation of this file.
1 /*
2 Minetest
3 Copyright (C) 2016 sfan5 <sfan5@live.de>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program 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 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #pragma once
21 
22 #include <iostream>
23 #include "irrlichttypes_bloated.h"
24 
26 {
27  TAT_NONE = 0,
30 };
31 
33 {
35  union
36  {
37  // struct {
38  // } none;
39  struct
40  {
41  int aspect_w; // width for aspect ratio
42  int aspect_h; // height for aspect ratio
43  float length; // seconds
45  struct
46  {
47  int frames_w; // number of frames left-to-right
48  int frames_h; // number of frames top-to-bottom
49  float frame_length; // seconds
51  };
52 
53  void serialize(std::ostream &os, u8 tiledef_version) const;
54  void deSerialize(std::istream &is, u8 tiledef_version);
55  void determineParams(v2u32 texture_size, int *frame_count, int *frame_length_ms,
56  v2u32 *frame_size) const;
57  void getTextureModifer(std::ostream &os, v2u32 texture_size, int frame) const;
58  v2f getTextureCoords(v2u32 texture_size, int frame) const;
59 };
core::vector2d< f32 > v2f
Definition: irr_v2d.h:26
core::vector2d< u32 > v2u32
Definition: irr_v2d.h:29
Definition: tileanimation.h:33
enum TileAnimationType type
Definition: tileanimation.h:34
int aspect_h
Definition: tileanimation.h:42
int frames_h
Definition: tileanimation.h:48
void deSerialize(std::istream &is, u8 tiledef_version)
Definition: tileanimation.cpp:36
v2f getTextureCoords(v2u32 texture_size, int frame) const
Definition: tileanimation.cpp:93
void serialize(std::ostream &os, u8 tiledef_version) const
Definition: tileanimation.cpp:22
void getTextureModifer(std::ostream &os, v2u32 texture_size, int frame) const
Definition: tileanimation.cpp:76
float length
Definition: tileanimation.h:43
float frame_length
Definition: tileanimation.h:49
struct TileAnimationParams::@20::@23 sheet_2d
int frames_w
Definition: tileanimation.h:47
struct TileAnimationParams::@20::@22 vertical_frames
int aspect_w
Definition: tileanimation.h:41
void determineParams(v2u32 texture_size, int *frame_count, int *frame_length_ms, v2u32 *frame_size) const
Definition: tileanimation.cpp:51
TileAnimationType
Definition: tileanimation.h:26
@ TAT_NONE
Definition: tileanimation.h:27
@ TAT_SHEET_2D
Definition: tileanimation.h:29
@ TAT_VERTICAL_FRAMES
Definition: tileanimation.h:28