CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderAnimBiker.cpp
浏览该文件的文档.
1
// Copyright (c) 2017 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 "
CarlaRecorder.h
"
8
#include "
CarlaRecorderAnimBiker.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderAnimBiker::Write
(std::ostream &OutFile)
const
12
{
13
WriteValue<uint32_t>(OutFile,
DatabaseId
);
14
WriteValue<float>(OutFile,
ForwardSpeed
);
15
WriteValue<float>(OutFile,
EngineRotation
);
16
}
17
18
void
CarlaRecorderAnimBiker::Read
(std::istream &InFile)
19
{
20
ReadValue<uint32_t>(InFile,
DatabaseId
);
21
ReadValue<float>(InFile,
ForwardSpeed
);
22
ReadValue<float>(InFile,
EngineRotation
);
23
}
24
25
// ---------------------------------------------
26
27
void
CarlaRecorderAnimBikers::Clear
(
void
)
28
{
29
Bikers
.clear();
30
}
31
32
void
CarlaRecorderAnimBikers::Add
(
const
CarlaRecorderAnimBiker
&Biker)
33
{
34
Bikers
.push_back(Biker);
35
}
36
37
void
CarlaRecorderAnimBikers::Write
(std::ostream &OutFile)
const
38
{
39
// write the packet id
40
WriteValue<char>(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::AnimBiker
));
41
42
// write the packet size
43
uint32_t Total = 2 +
Bikers
.size() *
sizeof
(
CarlaRecorderAnimBiker
);
44
WriteValue<uint32_t>(OutFile, Total);
45
46
// write total records
47
Total =
Bikers
.size();
48
WriteValue<uint16_t>(OutFile, Total);
49
50
// write records
51
if
(Total > 0)
52
{
53
OutFile.write(
reinterpret_cast<
const
char
*
>
(
Bikers
.data()),
54
Bikers
.size() *
sizeof
(
CarlaRecorderAnimBiker
));
55
}
56
}
57
58
void
CarlaRecorderAnimBikers::Read
(std::istream &InFile)
59
{
60
uint16_t i, Total;
61
CarlaRecorderAnimBiker
Biker;
62
63
// read Total Bikers
64
ReadValue<uint16_t>(InFile, Total);
65
for
(i = 0; i < Total; ++i)
66
{
67
Biker.
Read
(InFile);
68
Add
(Biker);
69
}
70
}
71
72
const
std::vector<CarlaRecorderAnimBiker>&
CarlaRecorderAnimBikers::GetBikers
()
73
{
74
return
Bikers
;
75
}
CarlaRecorderAnimBiker.h
CarlaRecorderHelpers.h
CarlaRecorder.h
CarlaRecorderPacketId::AnimBiker
@ AnimBiker
CarlaRecorderAnimBikers::Write
void Write(std::ostream &OutFile) const
Definition
CarlaRecorderAnimBiker.cpp:37
CarlaRecorderAnimBikers::Clear
void Clear(void)
Definition
CarlaRecorderAnimBiker.cpp:27
CarlaRecorderAnimBikers::Bikers
std::vector< CarlaRecorderAnimBiker > Bikers
Definition
CarlaRecorderAnimBiker.h:42
CarlaRecorderAnimBikers::Add
void Add(const CarlaRecorderAnimBiker &InObj)
Definition
CarlaRecorderAnimBiker.cpp:32
CarlaRecorderAnimBikers::GetBikers
const std::vector< CarlaRecorderAnimBiker > & GetBikers()
Definition
CarlaRecorderAnimBiker.cpp:72
CarlaRecorderAnimBikers::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderAnimBiker.cpp:58
CarlaRecorderAnimBiker
Definition
CarlaRecorderAnimBiker.h:14
CarlaRecorderAnimBiker::ForwardSpeed
float ForwardSpeed
Definition
CarlaRecorderAnimBiker.h:16
CarlaRecorderAnimBiker::Write
void Write(std::ostream &OutFile) const
Definition
CarlaRecorderAnimBiker.cpp:11
CarlaRecorderAnimBiker::EngineRotation
float EngineRotation
Definition
CarlaRecorderAnimBiker.h:17
CarlaRecorderAnimBiker::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderAnimBiker.cpp:18
CarlaRecorderAnimBiker::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderAnimBiker.h:15
制作者
1.10.0