2021-01-04 09:39:07 +01:00
|
|
|
#include "Framework/InputGeom.h"
|
|
|
|
|
|
|
|
#include "NavMeshGenerator.h"
|
|
|
|
#include "RecastContext.h"
|
|
|
|
|
2021-01-05 04:19:21 +01:00
|
|
|
using namespace std::filesystem;
|
|
|
|
|
2021-01-04 09:39:07 +01:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2021-01-05 04:19:21 +01:00
|
|
|
path inputPath;
|
|
|
|
path outputPath;
|
|
|
|
path outputPath2;
|
2021-01-04 09:39:07 +01:00
|
|
|
bool enableLogging = false;
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (!_stricmp(argv[i], "--input"))
|
|
|
|
{
|
|
|
|
inputPath = argv[++i];
|
|
|
|
}
|
|
|
|
else if (!_stricmp(argv[i], "--output"))
|
|
|
|
{
|
|
|
|
outputPath = argv[++i];
|
|
|
|
}
|
2021-01-05 04:19:21 +01:00
|
|
|
else if (!_stricmp(argv[i], "--output2"))
|
|
|
|
{
|
|
|
|
outputPath2 = argv[++i];
|
|
|
|
}
|
2021-01-04 09:39:07 +01:00
|
|
|
else if (!_stricmp(argv[i], "--enableLogging"))
|
|
|
|
{
|
|
|
|
enableLogging = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 04:19:21 +01:00
|
|
|
const auto context = std::make_shared<RecastContext>(enableLogging);
|
|
|
|
|
|
|
|
auto geom = std::make_shared<InputGeom>();
|
|
|
|
geom->load(context.get(), inputPath.string());
|
2021-01-04 09:39:07 +01:00
|
|
|
|
|
|
|
if (outputPath.empty())
|
|
|
|
{
|
|
|
|
printf("Warning: no output path set, no file will be generated.\n");
|
|
|
|
}
|
|
|
|
|
2021-01-05 04:19:21 +01:00
|
|
|
|
2021-01-04 09:39:07 +01:00
|
|
|
NavMeshGenerator generator(geom, context);
|
|
|
|
bool success = generator.BuildNavMesh();
|
|
|
|
|
|
|
|
float totalTime = context->getAccumulatedTime(RC_TIMER_TOTAL) / 1000.0f;
|
|
|
|
|
|
|
|
printf("Success: %d\n", success);
|
|
|
|
printf("Total time in milliseconds: %.2f\n", totalTime);
|
|
|
|
|
|
|
|
if (!outputPath.empty())
|
|
|
|
{
|
|
|
|
generator.Serialize(outputPath);
|
2021-01-05 04:19:21 +01:00
|
|
|
|
|
|
|
if (!outputPath2.empty())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2021-01-10 01:49:39 +01:00
|
|
|
copy_file(outputPath, outputPath2, copy_options::overwrite_existing);
|
2021-01-05 04:19:21 +01:00
|
|
|
}
|
|
|
|
catch (const filesystem_error& ex)
|
|
|
|
{
|
|
|
|
printf("Unable to copy output file to secondary path: %s.\n", ex.what());
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 09:39:07 +01:00
|
|
|
}
|
|
|
|
}
|