示例#1
0
FExecStatus FCameraCommandHandler::GetActorRotation(const TArray<FString>& Args)
{
	APawn* Pawn = FUE4CVServer::Get().GetPawn();
	FRotator CameraRotation = Pawn->GetControlRotation();
	FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll);
	return FExecStatus::OK(Message);
}
示例#2
0
FExecStatus FCameraCommandHandler::GetCameraRotation(const TArray<FString>& Args)
{
	if (Args.Num() == 1)
	{
		bool bIsMatinee = false;

		FRotator CameraRotation;
		ACineCameraActor* CineCameraActor = nullptr;
		for (AActor* Actor : this->GetWorld()->GetCurrentLevel()->Actors)
		{
			// if (Actor && Actor->IsA(AMatineeActor::StaticClass())) // AMatineeActor is deprecated
			if (Actor && Actor->IsA(ACineCameraActor::StaticClass()))
			{
				bIsMatinee = true;
				CameraRotation = Actor->GetActorRotation();
				break;
			}
		}

		if (!bIsMatinee)
		{
			int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras
			APawn* Pawn = FUE4CVServer::Get().GetPawn();
			CameraRotation = Pawn->GetControlRotation();
		}

		FString Message = FString::Printf(TEXT("%.3f %.3f %.3f"), CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll);

		return FExecStatus::OK(Message);
	}
	return FExecStatus::Error("Number of arguments incorrect");
}
示例#3
0
FExecStatus FCameraCommandHandler::GetCameraPose(const TArray<FString>& Args)
{
  if (Args.Num() == 1)
  {
    bool bIsMatinee = false;

    FVector CameraLocation;
    FRotator CameraRotation;
    ACineCameraActor* CineCameraActor = nullptr;
    for (AActor* Actor : this->GetWorld()->GetCurrentLevel()->Actors)
    {
      // if (Actor && Actor->IsA(AMatineeActor::StaticClass())) // AMatineeActor is deprecated
      if (Actor && Actor->IsA(ACineCameraActor::StaticClass()))
      {
        bIsMatinee = true;
        CameraLocation = Actor->GetActorLocation();
        CameraRotation = Actor->GetActorRotation();
        break;
      }
    }

    if (!bIsMatinee)
    {
//      int32 CameraId = FCString::Atoi(*Args[0]); // TODO: Add support for multiple cameras
      // This should support multiple cameras
//      UGTCaptureComponent* CaptureComponent = FCaptureManager::Get().GetCamera(CameraId);
//      if (CaptureComponent == nullptr)
//      {
//        return FExecStatus::Error(FString::Printf(TEXT("Camera %d can not be found."), CameraId));
//      }
//      CameraLocation = CaptureComponent->GetComponentLocation();
//      CameraRotation = CaptureComponent->GetComponentRotation();

      APawn* Pawn = FUE4CVServer::Get().GetPawn();
      CameraLocation = Pawn->GetActorLocation();
      CameraRotation = Pawn->GetControlRotation();
    }

    FString Message = FString::Printf(TEXT("%.3f %.3f %.3f %.3f %.3f %.3f"),
                                      CameraLocation.X, CameraLocation.Y, CameraLocation.Z,
                                      CameraRotation.Pitch, CameraRotation.Yaw, CameraRotation.Roll);

    return FExecStatus::OK(Message);
  }
  return FExecStatus::Error("Number of arguments incorrect");
}