-
Notifications
You must be signed in to change notification settings - Fork 3
/
WeArtTexture.h
81 lines (66 loc) · 2.24 KB
/
WeArtTexture.h
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
/**
* WEART - Texture component
* https://www.weart.it/
*/
#pragma once
#include "WeArtCommon.h"
//! @brief Temperature value to be applied to an effect
struct WeArtTexture {
public:
WeArtTexture() : active(false),
_textureType(DefaultTextureType),
_textureVelocity{ DefaultVelocity },
_volume(DefaultVolume) {};
WeArtTexture(bool active, TextureType type, float velocity, float textureVolume)
: active(active), _textureType(type) {
textureVelocity(velocity);
volume(textureVolume);
}
static constexpr TextureType DefaultTextureType = TextureType::ClickNormal;
static constexpr float DefaultVolume = 100.0f;
static constexpr float MinVolume = 0.0f;
static constexpr float MaxVolume = 100.0f;
static constexpr float DefaultVelocity = 0.0f;
static constexpr float MinVelocity = 0.0f;
static constexpr float MaxVelocity = 0.5f;
bool active;
//! @brief Gets the texture velocity
//! @return current texture velocity value
float textureVelocity() const {
return _textureVelocity;
}
//! @brief Sets the texture velocity (speed at which the vibration is emitted, between 0 and 0.5)
//! @param velocity Texture velocity
void textureVelocity(float velocity) {
_textureVelocity = velocity <= MinVelocity ? MinVelocity : velocity >= MaxVelocity ? MaxVelocity : velocity;
}
//! @brief Texture type getter
//! @return current texture type value
TextureType textureType() const {
return _textureType;
}
//! @brief Texture type setter
//! @param type Texture type value to set
void textureType(TextureType type) {
TextureType lower = TextureType::ClickNormal;
TextureType upper = TextureType::DoubleSidedTape;
_textureType = type <= lower ? lower : type >= upper ? upper : type;
}
//! @brief Volume value getter
//! @return current texture volume
float volume() const {
return _volume;
}
//! @brief Volume value setter
//! @param v Volume to set
void volume(float v) {
_volume = v <= MinVolume ? MinVolume : v >= MaxVolume ? MaxVolume : v;
}
bool operator==(const WeArtTexture& other) const {
return (active == other.active && _textureType == other.textureType() && _textureVelocity == other.textureVelocity() && _volume == other.volume());
};
private:
float _volume;
TextureType _textureType;
float _textureVelocity;
};