Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving of DynamicMesh runtime as an archive/file and load it back later #2

Open
ashishdasari148 opened this issue Feb 9, 2023 · 2 comments

Comments

@ashishdasari148
Copy link

I am looking for a way to save the meshes generated to the drive and load it back

@ashishdasari148
Copy link
Author

I am able to export and import the meshes into .obj files with the functions RTGUtils::WriteOBJMesh and URuntimeToolsFrameworkSubsystem::ImportMeshSceneObject respectively. But When I have done a boolean operation with 2 objects namely A and B, the WriteOBJMesh function is only giving me the original mesh A. I want to write the final mesh to an OBJ file.

This is my code for writing the obj files:

void AToolsFrameworkPlayerController::WriteMeshesToDrive() const
{
	TArray<TObjectPtr<AActor>> OutActors;
	UGameplayStatics::GetAllActorsOfClass(this, ADynamicSDMCActor::StaticClass(), OutActors);
	for (TObjectPtr<AActor> Actor : OutActors)
	{
		if (TObjectPtr<ADynamicSDMCActor> DynamicSdmcActor = Cast<ADynamicSDMCActor>(Actor))
		{
			FString Path = FPaths::ProjectContentDir() + FGuid::NewGuid().ToString(EGuidFormats::DigitsWithHyphens) + TEXT(".obj");
			UE_LOG(LogTemp, Warning, TEXT("Exporting Mesh to path %s with status %d"), *Path,
			       RTGUtils::WriteOBJMesh(Path, DynamicSdmcActor->GetMeshRef(), true));
		}
	}
}

@ashishdasari148
Copy link
Author

ashishdasari148 commented Feb 10, 2023

[SOLVED]
The code below can write the mesh into an OBJ file. But when loading back. The polygroups are lost.

void AToolsFrameworkPlayerController::WriteMeshesToDrive() const
{
	for(const TObjectPtr<URuntimeMeshSceneObject> RuntimeMeshSceneObject : URuntimeMeshSceneSubsystem::Get()->GetSceneObjects())
	{
		FString Path = FPaths::ProjectContentDir() + FGuid::NewGuid().ToString(EGuidFormats::DigitsWithHyphens) + TEXT(".obj");
		UE_LOG(LogTemp, Warning, TEXT("Exporting Mesh to path %s with status %d"), *Path,
			   RTGUtils::WriteOBJMesh(Path, *RuntimeMeshSceneObject->GetSourceMesh().Get(), true));
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant