// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license. 

#include <string>
#include <stdlib.h>
#include <filesystem>
#include <future>
#include "SimplygonLoader.h"

class CustomObserver : public Simplygon::Observer
{
	public:
	bool OnProgress(Simplygon::spObject subject, Simplygon::real progressPercent) override
	{
		printf("Progress: %f\n", progressPercent);
		// return false to abort the processing
		return true;
	}
} customObserver;


void RunReduction(Simplygon::ISimplygon* sg)
{
	// Create the reduction pipeline. 
	Simplygon::spReductionPipeline sgReductionPipeline = sg->CreateReductionPipeline();

	// Add the custom observer to the reduction pipeline. 
	sgReductionPipeline->AddObserver(&customObserver);

	// Start the reduction pipeline. 
	sgReductionPipeline->RunSceneFromFile("../Assets/RiggedSimplygonMan/RiggedSimplygonMan.fbx", "output.fbx", Simplygon::EPipelineRunMode::RunInNewProcess);

}

void main()
{
	Simplygon::ISimplygon* sg = NULL;
	Simplygon::EErrorCodes initval = Simplygon::Initialize( &sg );
	if( initval != Simplygon::EErrorCodes::NoError )
	{
		return;
	}

	RunReduction(sg);

	Simplygon::Deinitialize(sg);
}

