From 686975c8ee57aacbeabeb3273c3447b5ec952c2d Mon Sep 17 00:00:00 2001 From: Areloch Date: Thu, 13 Aug 2020 01:35:24 -0500 Subject: [PATCH] shifts getImageFilename to getImagePath on ImageAsset Adjusts references to utilize getImagePath to ensure things using the image asset gets the proper full path Adjusts image import logic to import finding associated images Adds logic so if a roughness map is imported, the generated material asset has the invertSmoothness flag on. --- Engine/source/T3D/assets/ImageAsset.cpp | 4 ++-- Engine/source/T3D/assets/assetImporter.cpp | 10 +++++++++- .../tools/assetBrowser/scripts/assetTypes/image.cs | 4 ++-- .../game/tools/convexEditor/convexEditorGui.cs | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index 4f7196540..c00a15c77 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -353,11 +353,11 @@ ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name) return (ImageTypes)ret; } -DefineEngineMethod(ImageAsset, getImageFilename, const char*, (), , +DefineEngineMethod(ImageAsset, getImagePath, const char*, (), , "Creates an instance of the given GameObject given the asset definition.\n" "@return The GameObject entity created from the asset.") { - return object->getImageFileName(); + return object->getImagePath(); } DefineEngineMethod(ImageAsset, getImageInfo, const char*, (), , diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index d292e531b..0ca2cbea6 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1317,7 +1317,7 @@ void AssetImporter::processImageAsset(AssetImportObject* assetItem) { if (!assetItem->filePath.isEmpty()) { - materialAsset = addImportingAsset("MaterialAsset", "", nullptr, noSuffixName); + materialAsset = addImportingAsset("MaterialAsset", assetItem->filePath, nullptr, noSuffixName); } } @@ -2466,6 +2466,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) dSprintf(lineBuffer, 1024, " mapTo=\"%s\";", assetName); file->writeLine((U8*)lineBuffer); + bool hasRoughness = false; for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) { AssetImportObject* childItem = assetItem->childAssetItems[i]; @@ -2502,6 +2503,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) else if (imageType == ImageAsset::ImageTypes::Roughness) { mapFieldName = "RoughnessMap"; + hasRoughness = true; } assetFieldName = mapFieldName + "Asset"; @@ -2515,6 +2517,12 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) file->writeLine((U8*)lineBuffer); } + if (hasRoughness) + { + file->writeLine((U8*)" invertSmoothness = true;"); + + } + file->writeLine((U8*)"};"); file->writeLine((U8*)"//--- OBJECT WRITE END ---"); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs index 93de0c2fe..4a40bdfcd 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs @@ -176,7 +176,7 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData) %previewData.assetPath = %assetDef.scriptFile; //%previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );"; - %imageFilePath = %assetDef.getImageFilename(); + %imageFilePath = %assetDef.getImagePath(); if(isFile(%imageFilePath)) %previewData.previewImage = %imageFilePath; else @@ -201,7 +201,7 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData) //Renames the asset function AssetBrowser::renameImageAsset(%this, %assetDef, %newAssetName) { - %newFilename = renameAssetLooseFile(%assetDef.imageFile, %newAssetName); + %newFilename = renameAssetLooseFile(%assetDef.getImagePath(), %newAssetName); if(!%newFilename $= "") return; diff --git a/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.cs b/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.cs index 1d8762848..c9a9325de 100644 --- a/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.cs +++ b/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.cs @@ -163,7 +163,7 @@ function ConvexEditorMaterialBtn::gotMaterialName(%this, %name) if(%diffuseAsset !$= "") { %diffuseAssetDef = AssetDatabase.acquireAsset(%diffuseAsset); - %diffusemap = %diffuseAssetDef.imageFile; + %diffusemap = %diffuseAssetDef.getImagePath(); } } @@ -228,7 +228,7 @@ function ConvexEditorDefaultMaterialBtn::gotMaterialName(%this, %name) if(%diffuseAsset !$= "") { %diffuseAssetDef = AssetDatabase.acquireAsset(%diffuseAsset); - %diffusemap = %diffuseAssetDef.imageFile; + %diffusemap = %diffuseAssetDef.getImagePath(); } }