I have a .OBJ file stored locally (let’s say in C:\mesh.obj) and I need to be able to open it when I run the game (I pass the absolute path as a command line parameter).
Here is what I tried:
AFloatingActor::AFloatingActor()
{
PrimaryActorTick.bCanEverTick = true;
FString Str = "file://C:/mesh.obj"; // also tried: "C:/mesh.obj"
UStaticMesh * m = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, *Str));
VisualComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualComponent"));
RootComponent = VisualComponent;
RootComponent->SetMobility(EComponentMobility::Movable);
VisualComponent->SetStaticMesh(m);
this just does nothing, I cannot see the model neither in the editor, nor in the game.
If instead I try
FString Str = "file://C:/mesh.obj"; // also tried: "C:/mesh.obj"
const ConstructorHelpers::FObjectFinder<UStaticMesh> MeshObj(*Str);
VisualComponent->SetStaticMesh(MeshObj.Object);
the compilation fails with the error “Failed to find file://C:/mesh.obj”.