-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDOF.cpp
125 lines (105 loc) · 1.81 KB
/
DOF.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "DOF.h"
QHash<DOF::Type, QString> DOF::_names = {
{DOF::RotationX, "Rotation X"},
{DOF::RotationY, "Rotation Y"},
{DOF::RotationZ, "Rotation Z"},
{DOF::TranslationX, "Translation X"},
{DOF::TranslationY, "Translation Y"},
{DOF::TranslationZ, "Translation Z"},
{DOF::ColorR, "Color R"},
{DOF::ColorG, "Color G"},
{DOF::ColorB, "Color B"},
{DOF::ColorA, "Color A"},
{DOF::Diffuse, "Diffuse"},
{DOF::Specular, "Specular"},
{DOF::MorphTarget, "Level"},
{DOF::AnimSpeed, "Anim Speed"}
};
DOF::DOF(Type type, bool enabled)
{
_hasMin = false;
_min = 0;
_hasMax = false;
_max = 0;
_value = 0;
_enabled = enabled;
_type = type;
_name = _names[type];
}
DOF::~DOF()
{
}
float DOF::value() const
{
return _value;
}
void DOF::setValue(float val)
{
if (_hasMin && val < _min)
val = _min;
else if (_hasMax && val > _max)
val = _max;
_value = val;
}
bool DOF::hasMin() const
{
return _hasMin;
}
void DOF::setHasMin(bool hasMin)
{
_hasMin = hasMin;
}
float DOF::min() const
{
return _min;
}
void DOF::setMin(float val)
{
_min = val;
if (_value < _min)
_value = _min;
_hasMin = true;
}
bool DOF::hasMax() const
{
return _hasMax;
}
void DOF::setHasMax(bool hasMax)
{
_hasMax = hasMax;
}
float DOF::max() const
{
return _max;
}
void DOF::setMax(float val)
{
_max = val;
if (_value > _max)
_value = _max;
_hasMax = true;
}
bool DOF::isEnabled() const
{
return _enabled;
}
void DOF::setEnabled(bool enabled)
{
_enabled = enabled;
}
const QString &DOF::name() const
{
return _name;
}
void DOF::setName(const QString &name)
{
_name = name;
}
DOF::Type DOF::type() const
{
return _type;
}
void DOF::setType(DOF::Type type)
{
_type = type;
}