-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactor.cpp
More file actions
139 lines (117 loc) · 2.46 KB
/
actor.cpp
File metadata and controls
139 lines (117 loc) · 2.46 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <QDebug>
#include "actor.h"
Actor::Actor()
{
//TODO
}
Actor::Actor(QString id, float x, float y, float z,
float vx, float vy, float vz)
{
this->id = id;
this->x = x;
this->y = y;
this->z = z;
this->vx = vx;
this->vy = vy;
this->vz = vz;
}
Actor::Actor(QVariantMap map)
{
//Safegard 'cause default value changes ...
x = y = z = vx = vy = vz = cube = 0;
width = height = length = 0.0;
id = map["id"].toString();
x = map["x"].toInt();
y = map["y"].toInt();
z = map["z"].toInt();
r = map["r"].toInt();
g = map["g"].toInt();
b = map["b"].toInt();
vx = map["vx"].toFloat();
vy = map["vy"].toFloat();
vz = map["vz"].toFloat();
width = map["w"].toFloat();
height = map["h"].toFloat();
length = map["l"].toFloat();
cube = map["cube"].toInt();
}
void Actor::update(QVariantMap map)
{
//Position
if (map.contains("x"))
x = map["x"].toInt();
if (map.contains("y"))
y = map["y"].toInt();
if (map.contains("z"))
z = map["z"].toInt();
//Color
if (map.contains("r"))
r = map["r"].toInt();
if (map.contains("g"))
g = map["g"].toInt();
if (map.contains("b"))
b = map["b"].toInt();
//Direction
if (map.contains("vx"))
vx = map["vx"].toFloat();
if (map.contains("vy"))
vy = map["vy"].toFloat();
if (map.contains("vz"))
vz = map["vz"].toFloat();
if (map.contains("w"))
width = map["w"].toFloat();
if (map.contains("h"))
height = map["h"].toFloat();
if (map.contains("l"))
length = map["l"].toFloat();
if (map.contains("cube"))
cube = map["cube"].toInt();
}
QString Actor::toString()
{
QString str = "name : " + id + " x:" + x + " y:" + y + " z:" + z;
return str;
}
QString Actor::getId(){
return id;
}
float Actor::getX(){
return x;
}
float Actor::getY(){
return y;
}
float Actor::getZ(){
return z;
}
float Actor::getVx(){
return vx;
}
float Actor::getVy(){
return vy;
}
float Actor::getVz(){
return vz;
}
float Actor::getWidth(){
return width;
}
float Actor::getLength(){
return length;
}
float Actor::getHeight(){
return height;
}
bool Actor::operator ==(const Actor& a) const{
return (id == a.id);
}
int Actor::getCube()
{
return cube;
}
void Actor::getColor(float* r, float* g, float* b)
{
*r = this->r / 255.0;
*g = this->g / 255.0;
*b = this->b / 255.0;
}