CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderLightScene.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
CarlaRecorderLightScene.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
12
void
CarlaRecorderLightScene::Write
(std::ostream &OutFile)
13
{
14
WriteValue<int>
(OutFile, this->
LightId
);
15
WriteValue<float>
(OutFile, this->
Intensity
);
16
WriteValue<FLinearColor>
(OutFile, this->
Color
);
17
WriteValue<bool>
(OutFile, this->
bOn
);
18
WriteValue<uint8>
(OutFile, this->
Type
);
19
}
20
void
CarlaRecorderLightScene::Read
(std::istream &InFile)
21
{
22
ReadValue<int>
(InFile, this->
LightId
);
23
ReadValue<float>
(InFile, this->
Intensity
);
24
ReadValue<FLinearColor>
(InFile, this->
Color
);
25
ReadValue<bool>
(InFile, this->
bOn
);
26
ReadValue<uint8>
(InFile, this->
Type
);
27
}
28
29
// ---------------------------------------------
30
31
void
CarlaRecorderLightScenes::Clear
(
void
)
32
{
33
Lights
.clear();
34
}
35
36
void
CarlaRecorderLightScenes::Add
(
const
CarlaRecorderLightScene
&
Vehicle
)
37
{
38
Lights
.push_back(
Vehicle
);
39
}
40
41
void
CarlaRecorderLightScenes::Write
(std::ostream &OutFile)
42
{
43
if
(
Lights
.size() == 0)
44
{
45
return
;
46
}
47
// write the packet id
48
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::SceneLight
));
49
50
std::streampos PosStart = OutFile.tellp();
51
52
// write a dummy packet size
53
uint32_t Total = 2 +
Lights
.size() *
sizeof
(
CarlaRecorderLightScene
);
54
WriteValue<uint32_t>
(OutFile, Total);
55
56
// write total records
57
Total =
Lights
.size();
58
WriteValue<uint16_t>
(OutFile, Total);
59
60
for
(
auto
& Light :
Lights
)
61
{
62
Light.Write(OutFile);
63
}
64
65
}
66
67
void
CarlaRecorderLightScenes::Read
(std::istream &InFile)
68
{
69
uint16_t Total = 0;
70
CarlaRecorderLightScene
LightScene;
71
72
// read Total light events
73
ReadValue<uint16_t>
(InFile, Total);
74
for
(uint16_t i = 0; (i < Total) && InFile; ++i)
75
{
76
LightScene.
Read
(InFile);
77
Add
(LightScene);
78
}
79
}
80
81
const
std::vector<CarlaRecorderLightScene>&
CarlaRecorderLightScenes::GetLights
()
82
{
83
return
Lights
;
84
}
CarlaRecorderHelpers.h
WriteValue
void WriteValue(std::ostream &OutFile, const T &InObj)
Definition
CarlaRecorderHelpers.h:21
ReadValue
void ReadValue(std::istream &InFile, T &OutObj)
Definition
CarlaRecorderHelpers.h:60
CarlaRecorderLightScene.h
CarlaRecorder.h
CarlaRecorderPacketId::SceneLight
@ SceneLight
Definition
CarlaRecorder.h:62
Vehicle
@ Vehicle
Definition
Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Util/EnvironmentObject.h:21
CarlaRecorderLightScene
Definition
CarlaRecorderLightScene.h:15
CarlaRecorderLightScene::bOn
bool bOn
Definition
CarlaRecorderLightScene.h:20
CarlaRecorderLightScene::Intensity
float Intensity
Definition
CarlaRecorderLightScene.h:18
CarlaRecorderLightScene::LightId
int LightId
Definition
CarlaRecorderLightScene.h:17
CarlaRecorderLightScene::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderLightScene.cpp:12
CarlaRecorderLightScene::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderLightScene.cpp:20
CarlaRecorderLightScene::Type
uint8 Type
Definition
CarlaRecorderLightScene.h:21
CarlaRecorderLightScene::Color
FLinearColor Color
Definition
CarlaRecorderLightScene.h:19
CarlaRecorderLightScenes::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderLightScene.cpp:67
CarlaRecorderLightScenes::Lights
std::vector< CarlaRecorderLightScene > Lights
Definition
CarlaRecorderLightScene.h:45
CarlaRecorderLightScenes::GetLights
const std::vector< CarlaRecorderLightScene > & GetLights()
Definition
CarlaRecorderLightScene.cpp:81
CarlaRecorderLightScenes::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderLightScene.cpp:41
CarlaRecorderLightScenes::Clear
void Clear(void)
Definition
CarlaRecorderLightScene.cpp:31
CarlaRecorderLightScenes::Add
void Add(const CarlaRecorderLightScene &InObj)
Definition
CarlaRecorderLightScene.cpp:36
Generated by
1.18.0