Fixed recorder/replayer
- Fixed vehicle wheels rotation and steering angle. - Fixed bikers animations.
This commit is contained in:
parent
82d1dc104e
commit
5543a26871
|
@ -111,6 +111,7 @@ void ACarlaRecorder::Ticking(float DeltaSeconds)
|
|||
AddActorPosition(View);
|
||||
AddVehicleAnimation(View);
|
||||
AddVehicleLight(View);
|
||||
AddVehicleWheelsAnimation(View);
|
||||
if (bAdditionalData)
|
||||
{
|
||||
AddActorKinematics(View);
|
||||
|
@ -194,6 +195,66 @@ void ACarlaRecorder::AddVehicleAnimation(FCarlaActor *CarlaActor)
|
|||
AddAnimVehicle(Record);
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddVehicleWheelsAnimation(FCarlaActor *CarlaActor)
|
||||
{
|
||||
check(CarlaActor != nullptr)
|
||||
if (CarlaActor->IsPendingKill())
|
||||
return;
|
||||
if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
|
||||
return;
|
||||
ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
|
||||
check(CarlaVehicle != nullptr)
|
||||
USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
|
||||
check(SkeletalMesh != nullptr)
|
||||
UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
|
||||
check(VehicleAnim != nullptr)
|
||||
const UWheeledVehicleMovementComponent* WheeledVehicleMovementComponent = VehicleAnim->GetWheeledVehicleMovementComponent();
|
||||
check(WheeledVehicleMovementComponent != nullptr)
|
||||
|
||||
CarlaRecorderAnimWheels Record;
|
||||
Record.DatabaseId = CarlaActor->GetActorId();
|
||||
|
||||
WheelInfo FL;
|
||||
FL.Location = EVehicleWheelLocation::FL_Wheel;
|
||||
FL.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(FL.Location);
|
||||
FL.TireRotation = WheeledVehicleMovementComponent->Wheels[(uint8)FL.Location]->GetRotationAngle();
|
||||
|
||||
WheelInfo FR;
|
||||
FR.Location = EVehicleWheelLocation::FR_Wheel;
|
||||
FR.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(FR.Location);
|
||||
FR.TireRotation = WheeledVehicleMovementComponent->Wheels[(uint8)FR.Location]->GetRotationAngle();
|
||||
|
||||
WheelInfo BL;
|
||||
BL.Location = EVehicleWheelLocation::BL_Wheel;
|
||||
BL.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(BL.Location);
|
||||
BL.TireRotation = WheeledVehicleMovementComponent->Wheels[(uint8)BL.Location]->GetRotationAngle();
|
||||
|
||||
WheelInfo BR;
|
||||
BR.Location = EVehicleWheelLocation::BR_Wheel;
|
||||
BR.SteeringAngle = CarlaVehicle->GetWheelSteerAngle(BR.Location);
|
||||
BR.TireRotation = WheeledVehicleMovementComponent->Wheels[(uint8)BR.Location]->GetRotationAngle();
|
||||
|
||||
Record.WheelValues.reserve(4);
|
||||
Record.WheelValues.push_back(FL);
|
||||
Record.WheelValues.push_back(FR);
|
||||
Record.WheelValues.push_back(BL);
|
||||
Record.WheelValues.push_back(BR);
|
||||
|
||||
AddAnimVehicleWheels(Record);
|
||||
|
||||
if (CarlaVehicle->IsTwoWheeledVehicle())
|
||||
{
|
||||
|
||||
|
||||
AddAnimBiker(CarlaRecorderAnimBiker
|
||||
{
|
||||
CarlaActor->GetActorId(),
|
||||
WheeledVehicleMovementComponent->GetForwardSpeed(),
|
||||
WheeledVehicleMovementComponent->GetEngineRotationSpeed() / WheeledVehicleMovementComponent->GetEngineMaxRotationSpeed()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddWalkerAnimation(FCarlaActor *CarlaActor)
|
||||
{
|
||||
check(CarlaActor != nullptr);
|
||||
|
@ -260,6 +321,7 @@ void ACarlaRecorder::AddActorKinematics(FCarlaActor *CarlaActor)
|
|||
};
|
||||
AddKinematics(Kinematic);
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddActorBoundingBox(FCarlaActor *CarlaActor)
|
||||
{
|
||||
check(CarlaActor != nullptr);
|
||||
|
@ -417,6 +479,8 @@ void ACarlaRecorder::Clear(void)
|
|||
PhysicsControls.Clear();
|
||||
TrafficLightTimes.Clear();
|
||||
WalkersBones.Clear();
|
||||
Wheels.Clear();
|
||||
Bikers.Clear();
|
||||
}
|
||||
|
||||
void ACarlaRecorder::Write(double DeltaSeconds)
|
||||
|
@ -443,6 +507,8 @@ void ACarlaRecorder::Write(double DeltaSeconds)
|
|||
Walkers.Write(File);
|
||||
LightVehicles.Write(File);
|
||||
LightScenes.Write(File);
|
||||
Wheels.Write(File);
|
||||
Bikers.Write(File);
|
||||
|
||||
// additional info
|
||||
if (bAdditionalData)
|
||||
|
@ -555,6 +621,14 @@ void ACarlaRecorder::AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle)
|
|||
}
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels)
|
||||
{
|
||||
if (Enabled)
|
||||
{
|
||||
Wheels.Add(VehicleWheels);
|
||||
}
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
|
||||
{
|
||||
if (Enabled)
|
||||
|
@ -563,6 +637,14 @@ void ACarlaRecorder::AddAnimWalker(const CarlaRecorderAnimWalker &Walker)
|
|||
}
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddAnimBiker(const CarlaRecorderAnimBiker &Biker)
|
||||
{
|
||||
if (Enabled)
|
||||
{
|
||||
Bikers.Add(Biker);
|
||||
}
|
||||
}
|
||||
|
||||
void ACarlaRecorder::AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle)
|
||||
{
|
||||
if (Enabled)
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
#include "CarlaRecorderLightScene.h"
|
||||
#include "CarlaRecorderLightVehicle.h"
|
||||
#include "CarlaRecorderAnimVehicle.h"
|
||||
#include "CarlaRecorderAnimVehicleWheels.h"
|
||||
#include "CarlaRecorderAnimWalker.h"
|
||||
#include "CarlaRecorderAnimBiker.h"
|
||||
#include "CarlaRecorderCollision.h"
|
||||
#include "CarlaRecorderEventAdd.h"
|
||||
#include "CarlaRecorderEventDel.h"
|
||||
|
@ -64,7 +66,9 @@ enum class CarlaRecorderPacketId : uint8_t
|
|||
TriggerVolume,
|
||||
FrameCounter,
|
||||
WalkerBones,
|
||||
VisualTime
|
||||
VisualTime,
|
||||
AnimVehicleWheels,
|
||||
AnimBiker
|
||||
};
|
||||
|
||||
/// Recorder for the simulation
|
||||
|
@ -111,8 +115,12 @@ public:
|
|||
|
||||
void AddAnimVehicle(const CarlaRecorderAnimVehicle &Vehicle);
|
||||
|
||||
void AddAnimVehicleWheels(const CarlaRecorderAnimWheels &VehicleWheels);
|
||||
|
||||
void AddAnimWalker(const CarlaRecorderAnimWalker &Walker);
|
||||
|
||||
void AddAnimBiker(const CarlaRecorderAnimBiker &Biker);
|
||||
|
||||
void AddLightVehicle(const CarlaRecorderLightVehicle &LightVehicle);
|
||||
|
||||
void AddEventLightSceneChanged(const UCarlaLight* Light);
|
||||
|
@ -128,7 +136,7 @@ public:
|
|||
void AddTrafficLightTime(const ATrafficLightBase& TrafficLight);
|
||||
|
||||
void AddActorBones(FCarlaActor *CarlaActor);
|
||||
|
||||
|
||||
// set episode
|
||||
void SetEpisode(UCarlaEpisode *ThisEpisode)
|
||||
{
|
||||
|
@ -186,7 +194,9 @@ private:
|
|||
CarlaRecorderPositions Positions;
|
||||
CarlaRecorderStates States;
|
||||
CarlaRecorderAnimVehicles Vehicles;
|
||||
CarlaRecorderAnimVehicleWheels Wheels;
|
||||
CarlaRecorderAnimWalkers Walkers;
|
||||
CarlaRecorderAnimBikers Bikers;
|
||||
CarlaRecorderLightVehicles LightVehicles;
|
||||
CarlaRecorderLightScenes LightScenes;
|
||||
CarlaRecorderActorsKinematics Kinematics;
|
||||
|
@ -207,7 +217,9 @@ private:
|
|||
void AddExistingActors(void);
|
||||
void AddActorPosition(FCarlaActor *CarlaActor);
|
||||
void AddWalkerAnimation(FCarlaActor *CarlaActor);
|
||||
void AddBikerAnimation(FCarlaActor *CarlaActor);
|
||||
void AddVehicleAnimation(FCarlaActor *CarlaActor);
|
||||
void AddVehicleWheelsAnimation(FCarlaActor *CarlaActor);
|
||||
void AddTrafficLightState(FCarlaActor *CarlaActor);
|
||||
void AddVehicleLight(FCarlaActor *CarlaActor);
|
||||
void AddActorKinematics(FCarlaActor *CarlaActor);
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "CarlaRecorder.h"
|
||||
#include "CarlaRecorderAnimBiker.h"
|
||||
#include "CarlaRecorderHelpers.h"
|
||||
|
||||
void CarlaRecorderAnimBiker::Write(std::ostream &OutFile) const
|
||||
{
|
||||
WriteValue<uint32_t>(OutFile, DatabaseId);
|
||||
WriteValue<float>(OutFile, ForwardSpeed);
|
||||
WriteValue<float>(OutFile, EngineRotation);
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimBiker::Read(std::istream &InFile)
|
||||
{
|
||||
ReadValue<uint32_t>(InFile, DatabaseId);
|
||||
ReadValue<float>(InFile, ForwardSpeed);
|
||||
ReadValue<float>(InFile, EngineRotation);
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
void CarlaRecorderAnimBikers::Clear(void)
|
||||
{
|
||||
Bikers.clear();
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimBikers::Add(const CarlaRecorderAnimBiker &Biker)
|
||||
{
|
||||
Bikers.push_back(Biker);
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimBikers::Write(std::ostream &OutFile) const
|
||||
{
|
||||
// write the packet id
|
||||
WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::AnimBiker));
|
||||
|
||||
// write the packet size
|
||||
uint32_t Total = 2 + Bikers.size() * sizeof(CarlaRecorderAnimBiker);
|
||||
WriteValue<uint32_t>(OutFile, Total);
|
||||
|
||||
// write total records
|
||||
Total = Bikers.size();
|
||||
WriteValue<uint16_t>(OutFile, Total);
|
||||
|
||||
// write records
|
||||
if (Total > 0)
|
||||
{
|
||||
OutFile.write(reinterpret_cast<const char *>(Bikers.data()),
|
||||
Bikers.size() * sizeof(CarlaRecorderAnimBiker));
|
||||
}
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimBikers::Read(std::istream &InFile)
|
||||
{
|
||||
uint16_t i, Total;
|
||||
CarlaRecorderAnimBiker Biker;
|
||||
|
||||
// read Total Bikers
|
||||
ReadValue<uint16_t>(InFile, Total);
|
||||
for (i = 0; i < Total; ++i)
|
||||
{
|
||||
Biker.Read(InFile);
|
||||
Add(Biker);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<CarlaRecorderAnimBiker>& CarlaRecorderAnimBikers::GetBikers()
|
||||
{
|
||||
return Bikers;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct CarlaRecorderAnimBiker
|
||||
{
|
||||
uint32_t DatabaseId;
|
||||
float ForwardSpeed { 0.0f };
|
||||
float EngineRotation { 0.0f };
|
||||
|
||||
void Read(std::istream &InFile);
|
||||
|
||||
void Write(std::ostream &OutFile) const;
|
||||
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
class CarlaRecorderAnimBikers
|
||||
{
|
||||
public:
|
||||
|
||||
void Add(const CarlaRecorderAnimBiker &InObj);
|
||||
|
||||
void Clear(void);
|
||||
|
||||
void Write(std::ostream &OutFile) const;
|
||||
|
||||
void Read(std::istream &InFile);
|
||||
|
||||
const std::vector<CarlaRecorderAnimBiker>& GetBikers();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<CarlaRecorderAnimBiker> Bikers;
|
||||
};
|
|
@ -0,0 +1,104 @@
|
|||
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "CarlaRecorder.h"
|
||||
#include "CarlaRecorderHelpers.h"
|
||||
#include "CarlaRecorderAnimVehicleWheels.h"
|
||||
|
||||
void WheelInfo::Write(std::ostream &OutFile) const
|
||||
{
|
||||
WriteValue<EVehicleWheelLocation>(OutFile, Location);
|
||||
WriteValue<float>(OutFile, SteeringAngle);
|
||||
WriteValue<float>(OutFile, TireRotation);
|
||||
}
|
||||
|
||||
void WheelInfo::Read(std::istream &InFile)
|
||||
{
|
||||
ReadValue<EVehicleWheelLocation>(InFile, Location);
|
||||
ReadValue<float>(InFile, SteeringAngle);
|
||||
ReadValue<float>(InFile, TireRotation);
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimWheels::Write(std::ostream &OutFile)
|
||||
{
|
||||
WriteValue<uint32_t>(OutFile, DatabaseId);
|
||||
WriteValue<uint32_t>(OutFile, WheelValues.size());
|
||||
for (const WheelInfo& Wheel : WheelValues)
|
||||
{
|
||||
Wheel.Write(OutFile);
|
||||
}
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimWheels::Read(std::istream &InFile)
|
||||
{
|
||||
ReadValue<uint32_t>(InFile, DatabaseId);
|
||||
uint32_t NumWheels = 0;
|
||||
ReadValue<uint32_t>(InFile, NumWheels);
|
||||
WheelValues.reserve(NumWheels);
|
||||
for (size_t i = 0; i < NumWheels; ++i)
|
||||
{
|
||||
WheelInfo Wheel;
|
||||
Wheel.Read(InFile);
|
||||
WheelValues.push_back(Wheel);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
void CarlaRecorderAnimVehicleWheels::Clear(void)
|
||||
{
|
||||
VehicleWheels.clear();
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimVehicleWheels::Add(const CarlaRecorderAnimWheels &Vehicle)
|
||||
{
|
||||
VehicleWheels.push_back(Vehicle);
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimVehicleWheels::Write(std::ostream &OutFile)
|
||||
{
|
||||
// write the packet id
|
||||
WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::AnimVehicleWheels));
|
||||
|
||||
std::streampos PosStart = OutFile.tellp();
|
||||
|
||||
// write a dummy packet size
|
||||
uint32_t Total = 0;
|
||||
WriteValue<uint32_t>(OutFile, Total);
|
||||
|
||||
// write total records
|
||||
Total = VehicleWheels.size();
|
||||
WriteValue<uint16_t>(OutFile, Total);
|
||||
|
||||
for (uint16_t i=0; i<Total; ++i)
|
||||
VehicleWheels[i].Write(OutFile);
|
||||
|
||||
// write the real packet size
|
||||
std::streampos PosEnd = OutFile.tellp();
|
||||
Total = PosEnd - PosStart - sizeof(uint32_t);
|
||||
OutFile.seekp(PosStart, std::ios::beg);
|
||||
WriteValue<uint32_t>(OutFile, Total);
|
||||
OutFile.seekp(PosEnd, std::ios::beg);
|
||||
}
|
||||
|
||||
void CarlaRecorderAnimVehicleWheels::Read(std::istream &InFile)
|
||||
{
|
||||
uint16_t i, Total;
|
||||
CarlaRecorderAnimWheels Wheels;
|
||||
|
||||
// read Total Vehicles
|
||||
ReadValue<uint16_t>(InFile, Total);
|
||||
for (i = 0; i < Total; ++i)
|
||||
{
|
||||
Wheels.Read(InFile);
|
||||
Add(Wheels);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<CarlaRecorderAnimWheels>& CarlaRecorderAnimVehicleWheels::GetVehicleWheels()
|
||||
{
|
||||
return VehicleWheels;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct WheelInfo
|
||||
{
|
||||
EVehicleWheelLocation Location = EVehicleWheelLocation::BR_Wheel;
|
||||
float SteeringAngle = 0.0f;
|
||||
float TireRotation = 0.0f;
|
||||
|
||||
void Read(std::istream &InFile);
|
||||
void Write(std::ostream &OutFile) const;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
#pragma pack(push, 1)
|
||||
struct CarlaRecorderAnimWheels
|
||||
{
|
||||
uint32_t DatabaseId;
|
||||
std::vector<WheelInfo> WheelValues;
|
||||
|
||||
void Read(std::istream &InFile);
|
||||
void Write(std::ostream &OutFile);
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
class CarlaRecorderAnimVehicleWheels
|
||||
{
|
||||
public:
|
||||
|
||||
void Add(const CarlaRecorderAnimWheels &InObj);
|
||||
|
||||
void Clear(void);
|
||||
|
||||
void Write(std::ostream &OutFile);
|
||||
|
||||
void Read(std::istream &InFile);
|
||||
|
||||
const std::vector<CarlaRecorderAnimWheels>& GetVehicleWheels();
|
||||
private:
|
||||
|
||||
std::vector<CarlaRecorderAnimWheels> VehicleWheels;
|
||||
};
|
|
@ -339,6 +339,14 @@ void CarlaReplayer::ProcessToTime(double Time, bool IsFirstTime)
|
|||
SkipPacket();
|
||||
break;
|
||||
|
||||
// vehicle wheels animation
|
||||
case static_cast<char>(CarlaRecorderPacketId::AnimVehicleWheels):
|
||||
if (bFrameFound)
|
||||
ProcessAnimVehicleWheels();
|
||||
else
|
||||
SkipPacket();
|
||||
break;
|
||||
|
||||
// walker animation
|
||||
case static_cast<char>(CarlaRecorderPacketId::AnimWalker):
|
||||
if (bFrameFound)
|
||||
|
@ -347,6 +355,14 @@ void CarlaReplayer::ProcessToTime(double Time, bool IsFirstTime)
|
|||
SkipPacket();
|
||||
break;
|
||||
|
||||
// biker animation
|
||||
case static_cast<char>(CarlaRecorderPacketId::AnimBiker):
|
||||
if (bFrameFound)
|
||||
ProcessAnimBiker();
|
||||
else
|
||||
SkipPacket();
|
||||
break;
|
||||
|
||||
// vehicle light animation
|
||||
case static_cast<char>(CarlaRecorderPacketId::VehicleLight):
|
||||
if (bFrameFound)
|
||||
|
@ -370,7 +386,7 @@ void CarlaReplayer::ProcessToTime(double Time, bool IsFirstTime)
|
|||
else
|
||||
SkipPacket();
|
||||
break;
|
||||
|
||||
|
||||
// frame end
|
||||
case static_cast<char>(CarlaRecorderPacketId::FrameEnd):
|
||||
if (bFrameFound)
|
||||
|
@ -543,6 +559,25 @@ void CarlaReplayer::ProcessAnimVehicle(void)
|
|||
}
|
||||
}
|
||||
|
||||
void CarlaReplayer::ProcessAnimVehicleWheels(void)
|
||||
{
|
||||
uint16_t i, Total;
|
||||
|
||||
// read Total Vehicles
|
||||
ReadValue<uint16_t>(File, Total);
|
||||
for (i = 0; i < Total; ++i)
|
||||
{
|
||||
CarlaRecorderAnimWheels Vehicle;
|
||||
Vehicle.Read(File);
|
||||
Vehicle.DatabaseId = MappedId[Vehicle.DatabaseId];
|
||||
// check if ignore this actor
|
||||
if (!(IgnoreHero && IsHeroMap[Vehicle.DatabaseId]))
|
||||
{
|
||||
Helper.ProcessReplayerAnimVehicleWheels(Vehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CarlaReplayer::ProcessAnimWalker(void)
|
||||
{
|
||||
uint16_t i, Total;
|
||||
|
@ -563,6 +598,24 @@ void CarlaReplayer::ProcessAnimWalker(void)
|
|||
}
|
||||
}
|
||||
|
||||
void CarlaReplayer::ProcessAnimBiker(void)
|
||||
{
|
||||
uint16_t i, Total;
|
||||
CarlaRecorderAnimBiker Biker;
|
||||
std::stringstream Info;
|
||||
|
||||
ReadValue<uint16_t>(File, Total);
|
||||
for (i = 0; i < Total; ++i)
|
||||
{
|
||||
Biker.Read(File);
|
||||
Biker.DatabaseId = MappedId[Biker.DatabaseId];
|
||||
if (!(IgnoreHero && IsHeroMap[Biker.DatabaseId]))
|
||||
{
|
||||
Helper.ProcessReplayerAnimBiker(Biker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CarlaReplayer::ProcessLightVehicle(void)
|
||||
{
|
||||
uint16_t Total;
|
||||
|
|
|
@ -144,7 +144,9 @@ private:
|
|||
void ProcessStates(void);
|
||||
|
||||
void ProcessAnimVehicle(void);
|
||||
void ProcessAnimVehicleWheels(void);
|
||||
void ProcessAnimWalker(void);
|
||||
void ProcessAnimBiker(void);
|
||||
|
||||
void ProcessLightVehicle(void);
|
||||
void ProcessLightScene(void);
|
||||
|
@ -155,4 +157,4 @@ private:
|
|||
void UpdatePositions(double Per, double DeltaTime);
|
||||
|
||||
void InterpolatePosition(const CarlaRecorderPosition &Start, const CarlaRecorderPosition &End, double Per, double DeltaTime);
|
||||
};
|
||||
};
|
|
@ -311,6 +311,29 @@ bool CarlaReplayerHelper::ProcessReplayerPosition(CarlaRecorderPosition Pos1, Ca
|
|||
return false;
|
||||
}
|
||||
|
||||
void CarlaReplayerHelper::ProcessReplayerAnimVehicleWheels(CarlaRecorderAnimWheels VehicleAnimWheels)
|
||||
{
|
||||
check(Episode != nullptr)
|
||||
FCarlaActor *CarlaActor = Episode->FindCarlaActor(VehicleAnimWheels.DatabaseId);
|
||||
if (CarlaActor == nullptr)
|
||||
return;
|
||||
if (CarlaActor->GetActorType() != FCarlaActor::ActorType::Vehicle)
|
||||
return;
|
||||
ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
|
||||
check(CarlaVehicle != nullptr)
|
||||
USkeletalMeshComponent* SkeletalMesh = CarlaVehicle->GetMesh();
|
||||
check(SkeletalMesh != nullptr)
|
||||
UVehicleAnimInstance* VehicleAnim = Cast<UVehicleAnimInstance>(SkeletalMesh->GetAnimInstance());
|
||||
check(VehicleAnim != nullptr)
|
||||
|
||||
for (uint32_t i = 0; i < VehicleAnimWheels.WheelValues.size(); ++i)
|
||||
{
|
||||
const WheelInfo& Element = VehicleAnimWheels.WheelValues[i];
|
||||
VehicleAnim->SetWheelRotYaw((uint8)Element.Location, Element.SteeringAngle);
|
||||
VehicleAnim->SetWheelPitchAngle((uint8)Element.Location, Element.TireRotation);
|
||||
}
|
||||
}
|
||||
|
||||
// reposition the camera
|
||||
bool CarlaReplayerHelper::SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
|
||||
{
|
||||
|
@ -419,6 +442,18 @@ void CarlaReplayerHelper::ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walk
|
|||
SetWalkerSpeed(Walker.DatabaseId, Walker.Speed);
|
||||
}
|
||||
|
||||
void CarlaReplayerHelper::ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
|
||||
{
|
||||
check(Episode != nullptr);
|
||||
FCarlaActor * CarlaActor = Episode->FindCarlaActor(Biker.DatabaseId);
|
||||
if (CarlaActor == nullptr)
|
||||
return;
|
||||
ACarlaWheeledVehicle* CarlaVehicle = Cast<ACarlaWheeledVehicle>(CarlaActor->GetActor());
|
||||
check(CarlaVehicle != nullptr)
|
||||
CarlaVehicle->SetSpeedAnim(Biker.ForwardSpeed);
|
||||
CarlaVehicle->SetRotationAnim(Biker.EngineRotation);
|
||||
}
|
||||
|
||||
// set walker bones
|
||||
void CarlaReplayerHelper::ProcessReplayerWalkerBones(const CarlaRecorderWalkerBones &WalkerBones)
|
||||
{
|
||||
|
|
|
@ -54,10 +54,16 @@ public:
|
|||
|
||||
// set the animation for Vehicles
|
||||
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle);
|
||||
|
||||
// set the animation for Vehicles Wheels
|
||||
void ProcessReplayerAnimVehicleWheels(CarlaRecorderAnimWheels Vehicle);
|
||||
|
||||
// set the animation for walkers
|
||||
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker);
|
||||
|
||||
// set the animation for bikers
|
||||
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker);
|
||||
|
||||
// set the vehicle light
|
||||
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle);
|
||||
|
||||
|
|
|
@ -452,4 +452,19 @@ private:
|
|||
|
||||
|
||||
FTimerHandle TimerHandler;
|
||||
public:
|
||||
float SpeedAnim { 0.0f };
|
||||
float RotationAnim { 0.0f };
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
float GetSpeedAnim() const { return SpeedAnim; }
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void SetSpeedAnim(float Speed) { SpeedAnim = Speed; }
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
float GetRotationAnim() const { return RotationAnim; }
|
||||
|
||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||
void SetRotationAnim(float Rotation) { RotationAnim = Rotation; }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue