neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
animation.hpp
Go to the documentation of this file.
1
// animation.hpp
2
/*
3
neogfx C++ App/Game Engine
4
Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6
This program is free software: you can redistribute it and / or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <
neogfx/neogfx.hpp
>
23
#include <
neolib/core/uuid.hpp
>
24
#include <
neolib/core/string.hpp
>
25
#include <
neogfx/gfx/color.hpp
>
26
#include <
neogfx/game/ecs_ids.hpp
>
27
#include <
neogfx/game/i_component.hpp
>
28
#include <
neogfx/game/mesh_filter.hpp
>
29
#include <
neogfx/game/material.hpp
>
30
31
namespace
neogfx::game
32
{
33
struct
animation_frame
34
{
35
scalar
duration
;
36
mesh_filter
filter
;
37
38
struct
meta
:
i_component_data::meta
39
{
40
static
const
neolib::uuid
&
id
()
41
{
42
static
const
neolib::uuid
sId = { 0x31bf1ad4, 0x9d06, 0x409d, 0xbc4f, { 0x4f, 0x80, 0x86, 0x38, 0xfd, 0x4f } };
43
return
sId;
44
}
45
static
const
i_string
&
name
()
46
{
47
static
const
string
sName =
"Animation Frame"
;
48
return
sName;
49
}
50
static
uint32_t
field_count
()
51
{
52
return
2;
53
}
54
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
55
{
56
switch
(aFieldIndex)
57
{
58
case
0:
59
return
component_data_field_type::Scalar;
60
case
1:
61
return
component_data_field_type::ComponentData;
62
default
:
63
throw
invalid_field_index
();
64
}
65
}
66
static
neolib::uuid
field_type_id
(uint32_t aFieldIndex)
67
{
68
switch
(aFieldIndex)
69
{
70
case
0:
71
return
neolib::uuid
{};
72
case
1:
73
return
mesh_filter::meta::id
();
74
default
:
75
throw
invalid_field_index
();
76
}
77
}
78
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
79
{
80
static
const
string
sFieldNames[] =
81
{
82
"Duration"
,
83
"Filter"
84
};
85
return
sFieldNames[aFieldIndex];
86
}
87
};
88
};
89
90
typedef
std::vector<animation_frame>
animation_frames
;
91
92
struct
animation
93
{
94
animation_frames
frames
;
95
96
struct
meta
:
i_component_data::meta
97
{
98
static
const
neolib::uuid
&
id
()
99
{
100
static
const
neolib::uuid
sId = { 0x164a76c6, 0x7081, 0x4b38, 0xb3ec, { 0x5b, 0xf9, 0xe0, 0x2, 0xe5, 0xbf } };
101
return
sId;
102
}
103
static
const
i_string
&
name
()
104
{
105
static
const
string
sName =
"Animation"
;
106
return
sName;
107
}
108
static
uint32_t
field_count
()
109
{
110
return
1;
111
}
112
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
113
{
114
switch
(aFieldIndex)
115
{
116
case
0:
117
return
component_data_field_type::ComponentData | component_data_field_type::Array;
118
default
:
119
throw
invalid_field_index
();
120
}
121
}
122
static
neolib::uuid
field_type_id
(uint32_t aFieldIndex)
123
{
124
switch
(aFieldIndex)
125
{
126
case
0:
127
return
animation_frame::meta::id
();
128
default
:
129
throw
invalid_field_index
();
130
}
131
}
132
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
133
{
134
static
const
string
sFieldNames[] =
135
{
136
"Animation"
137
};
138
return
sFieldNames[aFieldIndex];
139
}
140
};
141
};
142
}
neolib::i_string
Definition
i_string.hpp:49
color.hpp
material.hpp
mesh_filter.hpp
neogfx::game
Definition
aabb_octree.hpp:31
neogfx::game::animation_frames
std::vector< animation_frame > animation_frames
Definition
animation.hpp:90
neolib::ecs::component_data_field_type
component_data_field_type
Definition
i_component_data.hpp:52
neolib::math::scalar
double scalar
Definition
numerical.hpp:63
ecs_ids.hpp
i_component.hpp
neogfx.hpp
string.hpp
neogfx::game::animation::meta
Definition
animation.hpp:97
neogfx::game::animation::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
animation.hpp:132
neogfx::game::animation::meta::field_count
static uint32_t field_count()
Definition
animation.hpp:108
neogfx::game::animation::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
animation.hpp:112
neogfx::game::animation::meta::name
static const i_string & name()
Definition
animation.hpp:103
neogfx::game::animation::meta::field_type_id
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition
animation.hpp:122
neogfx::game::animation::meta::id
static const neolib::uuid & id()
Definition
animation.hpp:98
neogfx::game::animation_frame::meta
Definition
animation.hpp:39
neogfx::game::animation_frame::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
animation.hpp:78
neogfx::game::animation_frame::meta::id
static const neolib::uuid & id()
Definition
animation.hpp:40
neogfx::game::animation_frame::meta::field_type_id
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition
animation.hpp:66
neogfx::game::animation_frame::meta::field_count
static uint32_t field_count()
Definition
animation.hpp:50
neogfx::game::animation_frame::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
animation.hpp:54
neogfx::game::animation_frame::meta::name
static const i_string & name()
Definition
animation.hpp:45
neogfx::game::animation_frame
Definition
animation.hpp:34
neogfx::game::animation_frame::duration
scalar duration
Definition
animation.hpp:35
neogfx::game::animation_frame::filter
mesh_filter filter
Definition
animation.hpp:36
neogfx::game::animation
Definition
animation.hpp:93
neogfx::game::animation::frames
animation_frames frames
Definition
animation.hpp:94
neogfx::game::mesh_filter::meta::id
static const neolib::uuid & id()
Definition
mesh_filter.hpp:41
neogfx::game::mesh_filter
Definition
mesh_filter.hpp:34
neolib::ecs::i_component_data::meta::invalid_field_index
Definition
i_component_data.hpp:134
neolib::ecs::i_component_data::meta
Definition
i_component_data.hpp:133
neolib::uuid
Definition
uuid.hpp:51
uuid.hpp
include
neogfx
game
animation.hpp
Generated by
1.9.8