CARLA
CarlaRecorderLightScene.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020 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 
8 #include "CarlaRecorder.h"
9 #include "CarlaRecorderHelpers.h"
10 
11 
12 void CarlaRecorderLightScene::Write(std::ofstream &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::ifstream &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 
32 {
33  Lights.clear();
34 }
35 
37 {
38  Lights.push_back(Vehicle);
39 }
40 
41 void CarlaRecorderLightScenes::Write(std::ofstream &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 }
void Add(const CarlaRecorderLightScene &InObj)
void Write(std::ofstream &OutFile)
void Read(std::ifstream &InFile)
void Write(std::ofstream &OutFile)