Re-implement functionality for importing materials as instances.
This commit is contained in:
@@ -385,6 +385,8 @@ void ModelTool::Options::Serialize(SerializeStream& stream, const void* otherObj
|
||||
SERIALIZE(LODCount);
|
||||
SERIALIZE(TriangleReduction);
|
||||
SERIALIZE(ImportMaterials);
|
||||
SERIALIZE(ImportMaterialsAsInstances);
|
||||
SERIALIZE(InstanceToImportAs);
|
||||
SERIALIZE(ImportTextures);
|
||||
SERIALIZE(RestoreMaterialsOnReimport);
|
||||
SERIALIZE(GenerateSDF);
|
||||
@@ -426,6 +428,8 @@ void ModelTool::Options::Deserialize(DeserializeStream& stream, ISerializeModifi
|
||||
DESERIALIZE(LODCount);
|
||||
DESERIALIZE(TriangleReduction);
|
||||
DESERIALIZE(ImportMaterials);
|
||||
DESERIALIZE(ImportMaterialsAsInstances);
|
||||
DESERIALIZE(InstanceToImportAs);
|
||||
DESERIALIZE(ImportTextures);
|
||||
DESERIALIZE(RestoreMaterialsOnReimport);
|
||||
DESERIALIZE(GenerateSDF);
|
||||
@@ -977,17 +981,17 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
|
||||
if (options.ImportMaterialsAsInstances)
|
||||
{
|
||||
AssetsImportingManager::Create(AssetsImportingManager::CreateMaterialInstanceTag, assetPath, material.AssetID);
|
||||
MaterialInstance* materialInstance = (MaterialInstance*) LoadAsset(assetPath, MaterialInstance::TypeInitializer);
|
||||
MaterialInstance* materialInstance = (MaterialInstance*)LoadAsset(assetPath, MaterialInstance::TypeInitializer);
|
||||
if (materialInstance->WaitForLoaded())
|
||||
{
|
||||
LOG(Error, "Failed to load material instance after creation. ({0})", assetPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
MaterialBase* materialInstanceOf = (MaterialBase*) LoadAsset(options.InstanceToImportAs, MaterialBase::TypeInitializer);
|
||||
MaterialBase* materialInstanceOf = options.InstanceToImportAs;
|
||||
if (materialInstanceOf->WaitForLoaded())
|
||||
{
|
||||
LOG(Error, "Failed to load material to create an instance of. ({0})", options.InstanceToImportAs);
|
||||
LOG(Error, "Failed to load material to create an instance of. ({0})", options.InstanceToImportAs->GetID());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Engine/Graphics/Models/SkeletonData.h"
|
||||
#include "Engine/Animations/AnimationData.h"
|
||||
#include <Engine/Content/Assets/Material.h>
|
||||
#include <Engine/Graphics/GPUDevice.h>
|
||||
|
||||
class JsonWriter;
|
||||
|
||||
@@ -329,6 +330,12 @@ public:
|
||||
// If checked, the importer will create materials for model meshes as specified in the file.
|
||||
API_FIELD(Attributes="EditorOrder(400), EditorDisplay(\"Materials\"), VisibleIf(nameof(ShowGeometry))")
|
||||
bool ImportMaterials = true;
|
||||
// If checked, the importer will create the model's materials as instances of a base material.
|
||||
API_FIELD(Attributes = "EditorOrder(401), EditorDisplay(\"Materials\"), VisibleIf(nameof(ImportMaterials))")
|
||||
bool ImportMaterialsAsInstances = false;
|
||||
// The material to import the model's materials as an instance of.
|
||||
API_FIELD(Attributes = "EditorOrder(402), EditorDisplay(\"Materials\"), VisibleIf(nameof(ImportMaterialsAsInstances))")
|
||||
AssetReference<Material> InstanceToImportAs = (Material*) GPUDevice::Instance->GetDefaultMaterial();
|
||||
// If checked, the importer will import texture files used by the model and any embedded texture resources.
|
||||
API_FIELD(Attributes="EditorOrder(410), EditorDisplay(\"Materials\"), VisibleIf(nameof(ShowGeometry))")
|
||||
bool ImportTextures = true;
|
||||
|
||||
Reference in New Issue
Block a user