forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlignHelper.cpp
More file actions
75 lines (63 loc) · 2.34 KB
/
Copy pathAlignHelper.cpp
File metadata and controls
75 lines (63 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "AlignHelper.hpp"
#include "EntitySystem.hpp"
#include "Components.hpp"
void AlignHelper::set_material(EntitySystem& ents, std::size_t id, std::size_t state, const std::string& val)
{
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
comp->states[state].material = val;
}
const std::string& AlignHelper::get_material(EntitySystem& ents, std::size_t id, std::size_t state)
{
static const std::string NO_MAT{"colour/pink"};
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
return comp->states[state].material;
else
return NO_MAT;
}
void AlignHelper::set_mesh(EntitySystem& ents, std::size_t id, std::size_t state, const std::string& val)
{
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
comp->states[state].mesh = val;
}
const std::string& AlignHelper::get_mesh(EntitySystem& ents, std::size_t id, std::size_t state)
{
static const std::string NO_MESH{"cube.mesh"};
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
return comp->states[state].mesh;
else
return NO_MESH;
}
void AlignHelper::set_position_offset(EntitySystem& ents, std::size_t id, std::size_t state, const Ogre::Vector3& val)
{
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
comp->states[state].position_offset = val;
}
const Ogre::Vector3 & AlignHelper::get_position_offset(EntitySystem& ents, std::size_t id, std::size_t state)
{
static const Ogre::Vector3 NO_OFFSET{0.f, 0.f, 0.f};
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
return comp->states[state].position_offset;
else
return NO_OFFSET;
}
void AlignHelper::set_scale(EntitySystem& ents, std::size_t id, std::size_t state, const Ogre::Vector3& val)
{
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
comp->states[state].scale = val;
}
const Ogre::Vector3 & AlignHelper::get_scale(EntitySystem& ents, std::size_t id, std::size_t state)
{
static const Ogre::Vector3 NO_SCALE{1.f, 1.f, 1.f};
auto comp = ents.get_component<AlignComponent>(id);
if(comp && state < AlignComponent::state_count)
return comp->states[state].scale;
else
return NO_SCALE;
}