Implemented proper ScriptAsset execution on load

Implemented script dependency handling
Added test-case of script dependency handling in ExampleModule
Cleanup of redundant getSceneCount calls
Properly get scene count in callGamemodeFunction
Remove unneeded TODO comment in shaders
Converted onMissionEnded gamemode func call to use callGameModeFunction function
Convert ExampleGameMode to be container-object based, and updated callGamemodeFunction to handle that
Correct import settings typoe so image suffixes are read correctly
Largely fixed companion image scanning when importing images and streamlined image-material interop during import preprocessing
Added handling for reading in PBR maps and creating a composite image + asset
Added WIP of Cubemap asset, and editing integration with a standalone cubemap editor
Added ability to create new Cubemap asset in Asset Browser
This commit is contained in:
Areloch 2019-09-13 00:27:48 -05:00
parent 7c3bd49615
commit 9db95f4fb2
28 changed files with 1325 additions and 746 deletions

View file

@ -381,6 +381,7 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA
statusInfo = "";
skip = false;
processed = false;
generatedAsset = false;
};
//little bit of interception here
@ -425,6 +426,11 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA
}
}
if(%assetType $= "Material")
{
%assetItem.generatedAsset = true;
}
if(%parentAssetItem $= "")
{
ImportAssetTree.insertObject(1, %assetItem);
@ -723,10 +729,10 @@ function ImportAssetWindow::_findImportingAssetByName(%this, %id, %assetName)
function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
{
//diffuse
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/DiffuseTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/DiffuseTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -735,10 +741,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
}
//normal
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/NormalTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/NormalTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -747,10 +753,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
}
//roughness
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/RoughnessTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/RoughnessTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -759,10 +765,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
}
//Ambient Occlusion
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/AOTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/AOTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -771,10 +777,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
}
//metalness
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/MetalnessTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/MetalnessTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -783,10 +789,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem)
}
//composite
%suffixCount = getTokenCount(getAssetImportConfigValue("Image/CompositeTypeSuffixes", ""), ",;");
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;");
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
{
%suffixToken = getToken(getAssetImportConfigValue("Image/CompositeTypeSuffixes", ""), ",;", %sfx);
%suffixToken = getToken(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;", %sfx);
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
{
%assetItem.imageSuffixType = %suffixToken;
@ -1017,10 +1023,10 @@ function ImportAssetWindow::refreshChildItem(%this, %id)
//Check if it's a generated type, like materials
%inputPathProfile = ToolsGuiTextEditProfile;
%generatedField = false;
if(%assetType $= "Material")
if(%assetItem.generatedAsset)
{
%inputField = "(Generated)";
%generatedField = true;
%inputField = "(Generated)";
}
else
{
@ -1251,7 +1257,7 @@ function ImportAssetWindow::validateAsset(%this, %id)
}
//Check if we were given a file path(so not generated) but somehow isn't a valid file
if(%assetItem.filePath !$= "" && %assetItem.AssetType !$= "Material" && !isFile(%assetItem.filePath))
if(%assetItem.filePath !$= "" && !%assetItem.generatedAsset && !isFile(%assetItem.filePath))
{
%hasIssues = true;
%assetItem.status = "error";

View file

@ -0,0 +1,70 @@
function AssetBrowser::createCubemapAsset(%this)
{
Canvas.pushDialog(CubemapEditor);
return;
%moduleName = AssetBrowser.newAssetSettings.moduleName;
%modulePath = "data/" @ %moduleName;
%assetName = AssetBrowser.newAssetSettings.assetName;
%tamlpath = %modulePath @ "/cubemaps/" @ %assetName @ ".asset.taml";
%shapeFilePath = %modulePath @ "/cubemaps/" @ %assetName @ ".dae";
%asset = new CubemapAsset()
{
AssetName = %assetName;
versionId = 1;
friendlyName = AssetBrowser.newAssetSettings.friendlyName;
description = AssetBrowser.newAssetSettings.description;
fileName = %assetName @ ".dae";
};
TamlWrite(%asset, %tamlpath);
Canvas.popDialog(AssetBrowser_newComponentAsset);
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
AssetBrowser.loadFilters();
%treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName);
%smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "CubemapAsset");
AssetBrowserFilterTree.onSelect(%smItem);
return %tamlpath;
}
function AssetBrowser::editCubemapAsset(%this, %assetDef)
{
%this.hideDialog();
CubemapEditor.openCubemapAsset(%assetDef);
}
function GuiInspectorTypeCubemapAssetPtr::onControlDropped( %this, %payload, %position )
{
Canvas.popDialog(EditorDragAndDropLayer);
// Make sure this is a color swatch drag operation.
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
return;
%assetType = %payload.dragSourceControl.parentGroup.assetType;
if(%assetType $= "CubemapAsset")
{
echo("DROPPED A CUBEMAP ON A CUBEMAP ASSET COMPONENT FIELD!");
%module = %payload.dragSourceControl.parentGroup.moduleName;
%asset = %payload.dragSourceControl.parentGroup.assetName;
%targetComponent = %this.ComponentOwner;
%targetComponent.CubemapAsset = %module @ ":" @ %asset;
//Inspector.refresh();
}
EWorldEditor.isDirty = true;
}

View file

@ -18,11 +18,17 @@ function AssetBrowser::prepareImportImageAsset(%this, %assetItem)
//Check if our material already exists
//First, lets double-check that we don't already have an
%materialAsset = ImportAssetWindow.findImportingAssetByName(%noSuffixName);
%cratedNewMaterial = false;
if(%materialAsset == 0)
{
%filePath = %assetItem.filePath;
if(%filePath !$= "")
%materialAsset = AssetBrowser.addImportingAsset("Material", "", "", %noSuffixName);
%materialAsset.filePath = filePath(%assetItem.filePath) @ "/" @ %noSuffixName;
%cratedNewMaterial = true;
}
if(isObject(%materialAsset))
@ -45,51 +51,60 @@ function AssetBrowser::prepareImportImageAsset(%this, %assetItem)
//if we find these, we'll just populate into the original's material
//If we need to append the diffuse suffix and indeed didn't find a suffix on the name, do that here
if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1)
if(%foundSuffixType $= "")
{
if(%foundSuffixType $= "")
if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1)
{
%diffuseToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",", 0);
%assetItem.AssetName = %assetItem.AssetName @ %diffuseToken;
if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
%materialAsset.diffuseImageAsset = %assetItem;
}
else if(%foundSuffixType !$= "")
{
//otherwise, if we have some sort of suffix, we'll want to figure out if we've already got an existing material, and should append to it
if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
if(%foundSuffixType $= "")
{
if(%foundSuffixType $= "diffuse")
%materialAsset.diffuseImageAsset = %assetItem;
else if(%foundSuffixType $= "normal")
%materialAsset.normalImageAsset = %assetItem;
else if(%foundSuffixType $= "metalness")
%materialAsset.metalnessImageAsset = %assetItem;
else if(%foundSuffixType $= "roughness")
%materialAsset.roughnessImageAsset = %assetItem;
else if(%foundSuffixType $= "specular")
%materialAsset.specularImageAsset = %assetItem;
else if(%foundSuffixType $= "AO")
%materialAsset.AOImageAsset = %assetItem;
else if(%foundSuffixType $= "composite")
%materialAsset.compositeImageAsset = %assetItem;
%diffuseToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",", 0);
%assetItem.AssetName = %assetItem.AssetName @ %diffuseToken;
}
}
}
else
{
//We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix
//we'll give it a generic one
if(%materialAsset.assetName $= %assetItem.assetName)
else
{
%assetItem.AssetName = %assetItem.AssetName @ "_image";
//We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix
//we'll give it a generic one
if(%materialAsset.assetName $= %assetItem.assetName)
{
%assetItem.AssetName = %assetItem.AssetName @ "_image";
}
}
%foundSuffixType = "diffuse";
}
if(%foundSuffixType !$= "")
{
//otherwise, if we have some sort of suffix, we'll want to figure out if we've already got an existing material, and should append to it
if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
{
if(%foundSuffixType $= "diffuse")
%materialAsset.diffuseImageAsset = %assetItem;
else if(%foundSuffixType $= "normal")
%materialAsset.normalImageAsset = %assetItem;
else if(%foundSuffixType $= "metalness")
%materialAsset.metalnessImageAsset = %assetItem;
else if(%foundSuffixType $= "roughness")
%materialAsset.roughnessImageAsset = %assetItem;
else if(%foundSuffixType $= "specular")
%materialAsset.specularImageAsset = %assetItem;
else if(%foundSuffixType $= "AO")
%materialAsset.AOImageAsset = %assetItem;
else if(%foundSuffixType $= "composite")
%materialAsset.compositeImageAsset = %assetItem;
}
}
%assetItem.processed = true;
//If we JUST created this material, we need to do a process pass on it to do any other setup for it
if(%cratedNewMaterial)
{
AssetBrowser.prepareImportMaterialAsset(%materialAsset);
}
}
%assetItem.processed = true;
}
function AssetBrowser::importImageAsset(%this, %assetItem)

View file

@ -84,29 +84,15 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
if(%assetItem.diffuseImageAsset $= "")
{
//First, load our diffuse map, as set to the material in the shape
//We're going to presume(for now) that the specifically-mentioned file for a given material is the diffuse/albedo
%diffuseImagePath = %fileDir @ "/" @ %filename @ %fileExt;
%diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
%diffuseImageSuffix = ImportAssetWindow.parseImagePathSuffixes(%diffuseImagePath);
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes);
if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImage", "1") == 1 && %diffuseImageSuffix $= "")
if(%targetFilePath !$= "")
{
%diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
%diffuseFilename = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes);
if(%diffuseFilename !$= "")
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseFilename, %assetItem, fileBase(%diffuseFilename));
else
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %assetItem, %filename @ getToken(%diffuseTypeSuffixes, ",;", 0));
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem);
%assetItem.diffuseImageAsset = %diffuseAsset;
}
else
{
%diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %assetItem);
}
%assetItem.diffuseImageAsset = %diffuseAsset;
}
//Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any.
@ -209,7 +195,25 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
%assetItem.compositeImageAsset = %compositeAsset;
}
}
//If after the above we didn't find any, check to see if we should be generating one
if(%assetItem.compositeImageAsset $= "" && getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
{
%assetItem.roughnessImageAsset.skip = true;
%assetItem.AOImageAsset.skip = true;
%assetItem.metalnessImageAsset.skip = true;
%compositeAssetPath = "data/" @ %assetItem.moduleName @ "/images";
%saveAsPath = %compositeAssetPath @ "/" @ %assetItem.assetName @ "_composite.png";
%compositeAsset = AssetBrowser.addImportingAsset("Image", "", %assetItem, %assetItem.assetName @ "_composite");
%compositeAsset.generatedAsset = true;
%compositeAsset.filePath = %saveAsPath;
%assetItem.compositeImageAsset = %compositeAsset;
}
}
%assetItem.processed = true;
}
function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixesList)
@ -291,6 +295,28 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem)
%assetImportSuccessful = TamlWrite(%newAsset, %tamlpath);
//if we're set to save a composite image, we do that first
if(getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
{
//don't save a composite if we've already got one bound
if(%assetItem.compositeImageAsset !$= "" && %assetItem.compositeImageAsset.generatedAsset)
{
if(%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "")
{
%channelKey = "0 1 2 3";
saveCompositeTexture(%assetItem.AOImageAsset.filePath,
%assetItem.roughnessImageAsset.filePath,
%assetItem.metalnessImageAsset.filePath,"",
%channelKey,
%assetItem.compositeImageAsset.filePath);
%compositeAssetId = %moduleName @ ":" @ assetItem.compositeImageAsset.assetName;
AssetDatabase.refreshAsset(%compositeAssetId);
}
}
}
%file = new FileObject();
if(%file.openForWrite(%scriptPath))
@ -317,22 +343,22 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem)
%file.writeline(" SpecularMap[0] = \"" @ %assetItem.specularImageAsset.filePath @"\";");
%file.writeline(" SpecularMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.specularImageAsset.assetName @"\";");
}*/
if(%assetItem.roughnessImageAsset)
if(%assetItem.roughnessImageAsset && %assetItem.roughnessImageAsset.skip == false)
{
%file.writeline(" RoughMap[0] = \"" @ %assetItem.roughnessImageAsset.filePath @"\";");
%file.writeline(" RoughMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.roughnessImageAsset.assetName @"\";");
}
if(%assetItem.smoothnessImageAsset)
if(%assetItem.smoothnessImageAsset && %assetItem.smoothnessImageAsset.skip == false)
{
%file.writeline(" SmoothnessMap[0] = \"" @ %assetItem.smoothnessImageAsset.filePath @"\";");
%file.writeline(" SmoothnessMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.smoothnessImageAsset.assetName @"\";");
}
if(%assetItem.metalnessImageAsset)
if(%assetItem.metalnessImageAsset && %assetItem.metalnessImageAsset.skip == false)
{
%file.writeline(" MetalMap[0] = \"" @ %assetItem.metalnessImageAsset.filePath @"\";");
%file.writeline(" MetalMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.metalnessImageAsset.assetName @"\";");
}
if(%assetItem.AOImageAsset)
if(%assetItem.AOImageAsset && %assetItem.AOImageAsset.skip == false)
{
%file.writeline(" AOMap[0] = \"" @ %assetItem.AOImageAsset.filePath @"\";");
%file.writeline(" AOMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.AOImageAsset.assetName @"\";");

View file

@ -115,6 +115,8 @@ function AssetBrowser::buildPopupMenus(%this)
item[ 10 ] = "Create Sound" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"SoundAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewSoundAsset(\"NewSound\", AssetBrowser.selectedModule);";
item[ 11 ] = "-";
item[ 12 ] = "Create Particle Effect" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ParticleEffectAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewParticleEffectAsset(\"NewParticleEffect\", AssetBrowser.selectedModule);";
item[ 13 ] = "-";
item[ 14 ] = "Create Cubemap" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"CubemapAsset\", AssetBrowser.selectedModule);";
};
}