Most game development projects have a well-developed pipeline that handles packaging game assets together and streaming them into memory when needed at runtime. If you have such a system in place, you can easily package your NavData along with other types of game assets that are used in the same sectors (such as textures and models).
After a successful generation run, you can use the code below to access the NavData for each sector as raw data, and copy it into an array of unsigned int 8 or char. You can then package up this raw data in any way that fits in with your pipeline.
bool Generate() { ... // Launch the generation process using the configuration we set up. if (Kaim::Result::Fail(generator.Generate(generatorInputOutput))) { return false; } // Get a GeneratorSector object for each sector. // (we only generated one sector) Kaim::GeneratorSector* generatorSector = generatorInputOutput.GetSectorWithIndex(0); // Get the NavData. Kaim::NavData* pathDataPtr = generatorSector->GetNavData(); // Access the blob aggregate and retrieve its size. Kaim::BlobAggregate& aggregate = *pathDataPtr->m_blobAggregate; KyUInt32 aggregateSize = aggregate.ComputeByteSize(); // Allocate your own array. char* myArray = new char[aggregateSize]; // Copy the NavData there. aggregate.SaveToMemory(myArray); // Embed your copy into your own actor, an entity, or into your system. myLevel.m_navDataBlob = myArray; return true; }
After you load the block of data that contains your sector's NavData into memory at runtime, you can use it to set up a NavData object by calling NavData::LoadFromMemory() and passing the buffer.
class MyGameLevel { public: bool Initialize(Kaim::World* world); protected: Kaim::Ptr<Kaim::NavData> m_navData; char* m_navDataBlob; }; bool MyGameLevel::Initialize(Kaim::World* world) { // Instantiate and load the NavData from the buffer array m_navData = *KY_NEW Kaim::NavData; KyResult loadingResult = KY_ERROR; loadingResult = m_navData->LoadFromMemory(m_navDataBlob); // Check that the NavData have been correctly loaded if (KY_FAILED(loadingResult)) return false; // Add the NavData to the database m_navData->Init(world->GetDatabase(0)); m_navData->AddToDatabaseImmediate(); return true; }