neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
animation_filter.hpp
Go to the documentation of this file.
1
// animation_filter.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/game/animation.hpp
>
26
27
namespace
neogfx::game
28
{
29
struct
animation_filter
30
{
31
shared<animation>
sharedAnimation
;
32
std::optional<animation>
animation
;
33
std::optional<mat44>
transformation
;
34
u32
currentFrame
;
35
bool
autoDestroy
;
36
std::optional<i64>
currentFrameStartTime
;
// ECS internal
37
38
struct
meta
:
i_component_data::meta
39
{
40
static
const
neolib::uuid
&
id
()
41
{
42
static
const
neolib::uuid
sId = { 0xe876ec93, 0x21b2, 0x410e, 0xbd81, { 0x8c, 0x1d, 0x9, 0xec, 0xbc, 0x45 } };
43
return
sId;
44
}
45
static
const
i_string
&
name
()
46
{
47
static
const
string
sName =
"Animation Filter"
;
48
return
sName;
49
}
50
static
uint32_t
field_count
()
51
{
52
return
6;
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::ComponentData | component_data_field_type::Shared;
60
case
1:
61
return
component_data_field_type::ComponentData | component_data_field_type::Optional;
62
case
2:
63
return
component_data_field_type::Mat44 | component_data_field_type::Optional;
64
case
3:
65
return
component_data_field_type::Uint32;
66
case
4:
67
return
component_data_field_type::Bool;
68
case
5:
69
return
component_data_field_type::Int64 | component_data_field_type::Internal;
70
default
:
71
throw
invalid_field_index
();
72
}
73
}
74
static
neolib::uuid
field_type_id
(uint32_t aFieldIndex)
75
{
76
switch
(aFieldIndex)
77
{
78
case
0:
79
case
1:
80
return
animation::meta::id
();
81
case
2:
82
case
3:
83
case
4:
84
case
5:
85
return
neolib::uuid
{};
86
default
:
87
throw
invalid_field_index
();
88
}
89
}
90
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
91
{
92
static
const
string
sFieldNames[] =
93
{
94
"Shared Animation"
,
95
"Animation"
,
96
"Transformation"
,
97
"Current Frame"
,
98
"Auto Destroy"
,
99
"Current Frame Start Time"
100
};
101
return
sFieldNames[aFieldIndex];
102
}
103
};
104
};
105
106
inline
mesh_filter
const
&
current_animation_frame
(
animation_filter
const
& aAnimationFilter)
107
{
108
return
aAnimationFilter.
animation
?
109
aAnimationFilter.
animation
->frames[aAnimationFilter.
currentFrame
].filter :
110
aAnimationFilter.
sharedAnimation
.ptr->frames[aAnimationFilter.
currentFrame
].filter;
111
}
112
113
inline
mat44
const
&
to_transformation_matrix
(
animation_filter
const
& aAnimationFilter)
114
{
115
return
aAnimationFilter.
transformation
? *aAnimationFilter.
transformation
:
mat44::identity
();
116
}
117
}
animation.hpp
neolib::i_string
Definition
i_string.hpp:49
neolib::math::basic_matrix
Definition
numerical.hpp:903
neolib::math::basic_matrix::identity
static const std::enable_if_t< Rows==Columns, SFINAE > & identity()
Definition
numerical.hpp:984
neogfx::game
Definition
aabb_octree.hpp:31
neogfx::game::current_animation_frame
mesh_filter const & current_animation_frame(animation_filter const &aAnimationFilter)
Definition
animation_filter.hpp:106
neogfx::game::to_transformation_matrix
mat44 const & to_transformation_matrix(animation_filter const &aAnimationFilter)
Definition
animation_filter.hpp:113
neolib::ecs::component_data_field_type
component_data_field_type
Definition
i_component_data.hpp:52
neolib::math::u32
uint32_t u32
Definition
numerical.hpp:586
neogfx.hpp
string.hpp
neogfx::game::animation::meta::id
static const neolib::uuid & id()
Definition
animation.hpp:98
neogfx::game::animation_filter::meta
Definition
animation_filter.hpp:39
neogfx::game::animation_filter::meta::id
static const neolib::uuid & id()
Definition
animation_filter.hpp:40
neogfx::game::animation_filter::meta::field_count
static uint32_t field_count()
Definition
animation_filter.hpp:50
neogfx::game::animation_filter::meta::field_type_id
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition
animation_filter.hpp:74
neogfx::game::animation_filter::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
animation_filter.hpp:90
neogfx::game::animation_filter::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
animation_filter.hpp:54
neogfx::game::animation_filter::meta::name
static const i_string & name()
Definition
animation_filter.hpp:45
neogfx::game::animation_filter
Definition
animation_filter.hpp:30
neogfx::game::animation_filter::sharedAnimation
shared< animation > sharedAnimation
Definition
animation_filter.hpp:31
neogfx::game::animation_filter::transformation
std::optional< mat44 > transformation
Definition
animation_filter.hpp:33
neogfx::game::animation_filter::currentFrame
u32 currentFrame
Definition
animation_filter.hpp:34
neogfx::game::animation_filter::autoDestroy
bool autoDestroy
Definition
animation_filter.hpp:35
neogfx::game::animation_filter::currentFrameStartTime
std::optional< i64 > currentFrameStartTime
Definition
animation_filter.hpp:36
neogfx::game::animation_filter::animation
std::optional< animation > animation
Definition
animation_filter.hpp:32
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::ecs::shared
Definition
component.hpp:504
neolib::uuid
Definition
uuid.hpp:51
uuid.hpp
include
neogfx
game
animation_filter.hpp
Generated by
1.9.8