mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 08:42:35 +00:00
Updated Json Material loader to support passing JSON instead of a stream, and added techset loading code
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
#include "ZBarrier/GdtLoaderZBarrierT6.h"
|
#include "ZBarrier/GdtLoaderZBarrierT6.h"
|
||||||
#include "ZBarrier/RawLoaderZBarrierT6.h"
|
#include "ZBarrier/RawLoaderZBarrierT6.h"
|
||||||
#include "CustomMap/LoaderCustomMapT6.h"
|
#include "CustomMap/LoaderCustomMapT6.h"
|
||||||
|
#include "TechniqueSet/LoaderTechniqueSetT6.h"
|
||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -393,7 +394,7 @@ namespace T6
|
|||||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
// collection.AddAssetCreator(std::make_unique<AssetLoaderXAnim>(memory));
|
||||||
collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone));
|
collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone));
|
||||||
collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath));
|
collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(CreateTechniqueSetLoader(memory, searchPath));
|
collection.AddAssetCreator(technique_set::CreateLoaderT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderEmbeddedT6(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderEmbeddedT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoaderExternalT6(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoaderExternalT6(memory, searchPath));
|
||||||
collection.AddAssetCreator(image::CreateLoadDefLoaderT6(memory, searchPath));
|
collection.AddAssetCreator(image::CreateLoadDefLoaderT6(memory, searchPath));
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ namespace
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace T6
|
namespace technique_set
|
||||||
{
|
{
|
||||||
std::unique_ptr<AssetCreator<AssetTechniqueSet>> CreateTechniqueSetLoader(MemoryManager& memory, ISearchPath& searchPath)
|
std::unique_ptr<AssetCreator<AssetTechniqueSet>> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
return std::make_unique<TechniqueSetLoader>(memory, searchPath);
|
return std::make_unique<TechniqueSetLoader>(memory, searchPath);
|
||||||
}
|
}
|
||||||
} // namespace T6
|
} // namespace technique_set
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace T6
|
namespace technique_set
|
||||||
{
|
{
|
||||||
std::unique_ptr<AssetCreator<AssetTechniqueSet>> CreateTechniqueSetLoader(MemoryManager& memory, ISearchPath& searchPath);
|
std::unique_ptr<AssetCreator<T6::AssetTechniqueSet>> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
} // namespace T6
|
} // namespace technique_set
|
||||||
|
|||||||
@@ -42,7 +42,9 @@
|
|||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using namespace nlohmann;
|
||||||
using namespace GAME;
|
using namespace GAME;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -58,8 +60,6 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Load(json& jRoot, Material& material) const
|
bool Load(json& jRoot, Material& material) const
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
std::string type;
|
std::string type;
|
||||||
unsigned version;
|
unsigned version;
|
||||||
@@ -86,13 +86,6 @@ namespace
|
|||||||
const auto jMaterial = jRoot.get<JsonMaterial>();
|
const auto jMaterial = jRoot.get<JsonMaterial>();
|
||||||
return CreateMaterialFromJson(jMaterial, material);
|
return CreateMaterialFromJson(jMaterial, material);
|
||||||
}
|
}
|
||||||
catch (const json::exception& e)
|
|
||||||
{
|
|
||||||
con::error("Failed to parse json of material: {}", e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void PrintError(const Material& material, const std::string& message)
|
static void PrintError(const Material& material, const std::string& message)
|
||||||
@@ -528,10 +521,18 @@ namespace GAME
|
|||||||
{
|
{
|
||||||
const JsonLoader loader(memory, context, registration);
|
const JsonLoader loader(memory, context, registration);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
auto jRoot = json::parse(stream);
|
auto jRoot = json::parse(stream);
|
||||||
|
|
||||||
return loader.Load(jRoot, material);
|
return loader.Load(jRoot, material);
|
||||||
}
|
}
|
||||||
|
catch (const json::exception& e)
|
||||||
|
{
|
||||||
|
con::error("Failed to parse json of material: {}", e.what());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool LoadMaterialAsJson(
|
bool LoadMaterialAsJson(
|
||||||
json& json, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
json& json, Material& material, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetMaterial>& registration)
|
||||||
|
|||||||
Reference in New Issue
Block a user