Merge remote-tracking branch 'devhead/Preview4_0' into tsneo

# Conflicts:
#	Templates/BaseGame/game/data/ui/guis/loadingGui.gui
#	Templates/BaseGame/game/data/ui/guis/mainMenu.gui
#	Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui
#	Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui
#	Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
Jeff Hutchinson 2021-08-13 20:14:39 -04:00
commit 717c7acca9
2266 changed files with 48780 additions and 26034 deletions

View file

@ -0,0 +1,7 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="materialEd_justAlphaMaterial"
scriptFile="@assetFile=materialEditor.ed.tscript"
materialDefinitionName="materialEd_justAlphaMaterial"
VersionId="1" />

View file

@ -0,0 +1,7 @@
<MaterialAsset
canSave="true"
canSaveDynamicFields="true"
AssetName="materialEd_previewMaterial"
scriptFile="@assetFile=materialEditor.ed.tscript"
materialDefinitionName="materialEd_previewMaterial"
VersionId="1" />

View file

@ -21,18 +21,19 @@
//-----------------------------------------------------------------------------
// Material Editor originally created by Dave Calabrese and Travis Vroman of Gaslight Studios
$MaterialEditor::emptyMaterialImage = "ToolsModule:unknownImage_image";
function MaterialEditorGui::establishMaterials(%this)
{
//Cubemap used to preview other cubemaps in the editor.
singleton CubemapData( matEdCubeMapPreviewMat )
{
cubeFace[0] = "tools/materialEditor/gui/cube_xNeg";
cubeFace[1] = "tools/materialEditor/gui/cube_xPos";
cubeFace[2] = "tools/materialEditor/gui/cube_ZNeg";
cubeFace[3] = "tools/materialEditor/gui/cube_ZPos";
cubeFace[4] = "tools/materialEditor/gui/cube_YNeg";
cubeFace[5] = "tools/materialEditor/gui/cube_YPos";
cubeMapFaceAsset[0] = "ToolsModule:cube_xNeg_image";
cubeMapFaceAsset[1] = "ToolsModule:cube_xPos_image";
cubeMapFaceAsset[2] = "ToolsModule:cube_zNeg_image";
cubeMapFaceAsset[3] = "ToolsModule:cube_zPos_image";
cubeMapFaceAsset[4] = "ToolsModule:cube_yNeg_image";
cubeMapFaceAsset[5] = "ToolsModule:cube_yPos_image";
parentGroup = "RootGroup";
};
@ -40,7 +41,7 @@ function MaterialEditorGui::establishMaterials(%this)
singleton Material(materialEd_previewMaterial)
{
mapTo = "matEd_mappedMat";
diffuseMap[0] = "tools/materialEditor/gui/matEd_mappedMat";
diffuseMapAsset[0] = "ToolsModule:matEd_mappedMat_image";
};
singleton CustomMaterial( materialEd_justAlphaMaterial )
@ -230,6 +231,11 @@ function MaterialEditorGui::openFile( %this, %fileType )
return makeRelativePath( %filename, getMainDotCsDir() );
}
function MaterialEditorGui::selectMaterialAsset(%this, %assetId)
{
AssetBrowser.editAsset(%assetId);
}
//==============================================================================
// SubMaterial(Material Target) -- Supports different ways to grab the
// material from the dropdown list. We're here either because-
@ -253,7 +259,16 @@ function SubMaterialSelector::onSelect( %this )
// object does not have a valid method to grab a material
if( !isObject( %material ) )
{
// look for a newMaterial name to grab
if(!AssetDatabase.isDeclaredAsset(%material))
{
return;
}
else
{
%assetDef = AssetDatabase.acquireAsset(%material);
%material = %assetDef.materialDefinitionName;
}
/*// look for a newMaterial name to grab
// addiitonally, convert "." to "_" in case we have something like: "base.texname" as a material name
// at the end we will have generated material name: "base_texname_mat"
%material = getUniqueName( strreplace(%material, ".", "_") @ "_mat" );
@ -268,7 +283,7 @@ function SubMaterialSelector::onSelect( %this )
eval( "MaterialEditorGui.currentObject." @ strreplace(%this.getText(),".","_") @ " = " @ %material @ ";");
if( MaterialEditorGui.currentObject.isMethod("postApply") )
MaterialEditorGui.currentObject.postApply();
MaterialEditorGui.currentObject.postApply();*/
}
MaterialEditorGui.prepareActiveMaterial( %material.getId() );
@ -325,7 +340,7 @@ function MaterialEditorGui::prepareActiveObject( %this, %override )
{
%fieldName = %obj.getField(%i);
if( %obj.getFieldType(%fieldName) !$= "TypeMaterialName" )
if( %obj.getFieldType(%fieldName) !$= "TypeMaterialAssetId" /*&& %obj.getFieldType(%fieldName) !$= "TypeMaterialName"*/)
continue;
if( !%canSupportMaterial )
@ -409,7 +424,8 @@ function MaterialEditorGui::prepareActiveMaterial(%this, %material, %override)
{
// If were not valid, grab the first valid material out of the materialSet
if( !isObject(%material) )
%material = MaterialSet.getObject(0);
return;
//%material = MaterialSet.getObject(0);
// Check made in order to avoid loading the same material. Overriding
// made in special cases
@ -448,7 +464,7 @@ function MaterialEditorGui::setActiveMaterial( %this, %material )
singleton Material(notDirtyMaterial)
{
mapTo = "matEd_mappedMat";
diffuseMap[0] = "tools/materialEditor/gui/matEd_mappedMat";
diffuseMapAsset[0] = "ToolsModule:matEd_mappedMat_image";
};
// Converts the texture files into absolute paths.
@ -501,7 +517,13 @@ function MaterialEditorGui::setMaterialDirty(%this)
// materials created in the material selector are given that as its filename, so we run another check
if( MaterialEditorGui.isMatEditorMaterial( MaterialEditorGui.currentMaterial ) )
{
if( MaterialEditorGui.currentMaterial.isAutoGenerated() )
%currentMatFilename = MaterialEditorGui.currentMaterial.getFilename();
if(%currentMatFilename !$= "")
{
matEd_PersistMan.setDirty(MaterialEditorGui.currentMaterial, %currentMatFilename);
}
else if( MaterialEditorGui.currentMaterial.isAutoGenerated() )
{
%obj = MaterialEditorGui.currentObject;
@ -525,13 +547,9 @@ function MaterialEditorGui::setMaterialDirty(%this)
matEd_PersistMan.setDirty(MaterialEditorGui.currentMaterial, %savePath);
}
else
{
matEd_PersistMan.setDirty(MaterialEditorGui.currentMaterial, "art/materials." @ $TorqueScriptFileExtension);
}
}
else
matEd_PersistMan.setDirty(MaterialEditorGui.currentMaterial);
matEd_PersistMan.setDirty(MaterialEditorGui.currentMaterial, MaterialEditorGui.defaultMaterialFile);
}
function MaterialEditorGui::convertTextureFields(%this)
@ -539,88 +557,30 @@ function MaterialEditorGui::convertTextureFields(%this)
// Find the absolute paths for the texture filenames so that
// we can properly wire up the preview materials and controls.
for(%diffuseI = 0; %diffuseI < 4; %diffuseI++)
{
%diffuseMap = MaterialEditorGui.currentMaterial.diffuseMap[%diffuseI];
%diffuseMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %diffuseMap);
MaterialEditorGui.currentMaterial.diffuseMap[%diffuseI] = %diffuseMap;
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "DiffuseMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "NormalMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "OverlayMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "DetailMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "LightMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "ToneMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "ORMConfigMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "RoughMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "AOMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "MetalMap");
%this.convertMaterialTextureField(MaterialEditorGui.currentMaterial, "GlowMap");
}
for(%normalI = 0; %normalI < 4; %normalI++)
function MaterialEditorGui::convertMaterialTextureField(%this, %material, %mapName)
{
%normalMap = MaterialEditorGui.currentMaterial.normalMap[%normalI];
%normalMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %normalMap);
MaterialEditorGui.currentMaterial.normalMap[%normalI] = %normalMap;
for(%index = 0; %index < 4; %index++)
{
%mapFile = %material.call("get" @ %mapName, %index);
if(%mapFile !$= "" && !isFile(%mapFile))
{
//see if we can't go finding it
%mapFile = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %mapFile);
MaterialEditorGui.currentMaterial.call("set" @ %mapName, %mapFile, %index);
}
for(%overlayI = 0; %overlayI < 4; %overlayI++)
{
%overlayMap = MaterialEditorGui.currentMaterial.overlayMap[%overlayI];
%overlayMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %overlayMap);
MaterialEditorGui.currentMaterial.overlayMap[%overlayI] = %overlayMap;
}
for(%detailI = 0; %detailI < 4; %detailI++)
{
%detailMap = MaterialEditorGui.currentMaterial.detailMap[%detailI];
%detailMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %detailMap);
MaterialEditorGui.currentMaterial.detailMap[%detailI] = %detailMap;
}
for(%detailNormalI = 0; %detailNormalI < 4; %detailNormalI++)
{
%detailNormalMap = MaterialEditorGui.currentMaterial.detailNormalMap[%detailNormalI];
%detailNormalMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %detailNormalMap);
MaterialEditorGui.currentMaterial.detailNormalMap[%detailNormalI] = %detailNormalMap;
}
for(%lightI = 0; %lightI < 4; %lightI++)
{
%lightMap = MaterialEditorGui.currentMaterial.lightMap[%lightI];
%lightMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %lightMap);
MaterialEditorGui.currentMaterial.lightMap[%lightI] = %lightMap;
}
for(%toneI = 0; %toneI < 4; %toneI++)
{
%toneMap = MaterialEditorGui.currentMaterial.toneMap[%toneI];
%toneMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %toneMap);
MaterialEditorGui.currentMaterial.toneMap[%toneI] = %toneMap;
}
for(%specI = 0; %specI < 4; %specI++)
{
%ORMConfigMap = MaterialEditorGui.currentMaterial.ORMConfigMap[%specI];
%ORMConfigMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %ORMConfigMap);
MaterialEditorGui.currentMaterial.ORMConfigMap[%specI] = %ORMConfigMap;
}
for(%roughI = 0; %roughI < 4; %roughI++)
{
%roughMap = MaterialEditorGui.currentMaterial.roughMap[%roughI];
%roughMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %roughMap);
MaterialEditorGui.currentMaterial.roughMap[%specI] = %roughMap;
}
for(%aoI = 0; %aoI < 4; %aoI++)
{
%aoMap = MaterialEditorGui.currentMaterial.aoMap[%aoI];
%aoMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %aoMap);
MaterialEditorGui.currentMaterial.aoMap[%specI] = %aoMap;
}
for(%metalI = 0; %metalI < 4; %metalI++)
{
%metalMap = MaterialEditorGui.currentMaterial.metalMap[%metalI];
%metalMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %metalMap);
MaterialEditorGui.currentMaterial.metalMap[%metalI] = %metalMap;
}
for(%glowI = 0; %glowI < 4; %glowI++)
{
%glowMap = MaterialEditorGui.currentMaterial.glowMap[%glowI];
%glowMap = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %glowMap);
MaterialEditorGui.currentMaterial.glowMap[%glowI] = %glowMap;
}
}
@ -629,6 +589,14 @@ function MaterialEditorGui::searchForTexture(%this,%material, %texture)
{
if( %texture !$= "" )
{
if(AssetDatabase.isDeclaredAsset(%texture))
{
%assetDef = AssetDatabase.acquireAsset(%texture);
%imagePath = %assetDef.getImagePath();
AssetDatabase.releaseAsset(%texture);
return %imagePath;
}
// set the find signal as false to start out with
%isFile = false;
// sete the formats we're going to be looping through if need be
@ -785,15 +753,6 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->castShadows.setValue((%material).castShadows);
MaterialEditorPropertiesWindow-->castDynamicShadows.setValue((%material).castDynamicShadows);
MaterialEditorPropertiesWindow-->translucentCheckbox.setValue((%material).translucent);
/*
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(preMul,1);
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(LerpAlpha,2);
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(Mul,3);
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(Add,4);
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(AddAlpha,5);
MaterialEditorPropertiesWindow-->blendingTypePopUp.add(Sub,6);
*/
switch$((%material).translucentBlendOp)
{
case "None": %selectedNum = 0;
@ -837,138 +796,174 @@ function MaterialEditorGui::guiSync( %this, %material )
//layer specific controls are located here
%layer = MaterialEditorGui.currentLayer;
if((%material).diffuseMap[%layer] $= "")
//Diffuse
if((%material).getDiffuseMap(%layer) !$= "" && (%material).getDiffuseMapAsset(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
%difAsset = (%material).getDiffuseMapAsset(%layer);
MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( (%material).getDiffuseMapAsset(%layer) );
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( (%material).getDiffuseMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( (%material).diffuseMap[%layer] );
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( (%material).diffuseMap[%layer] );
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
if((%material).normalMap[%layer] $= "")
//Normal
if((%material).getNormalMap(%layer) !$= "" && (%material).getNormalMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->normalMapNameText.setText( (%material).getNormalMapAsset(%layer) );
MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( (%material).getNormalMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->normalMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->normalMapNameText.setText( (%material).normalMap[%layer] );
MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( (%material).normalMap[%layer] );
MaterialEditorPropertiesWindow-->normalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
if((%material).overlayMap[%layer] $= "")
//ORM Config
if((%material).getORMConfigMap(%layer) !$= "" && (%material).getORMConfigMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->overlayMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->overlayMapNameText.setText( (%material).overlayMap[%layer] );
MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( (%material).overlayMap[%layer] );
}
if((%material).detailMap[%layer] $= "")
{
MaterialEditorPropertiesWindow-->detailMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->detailMapNameText.setText( (%material).detailMap[%layer] );
MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( (%material).detailMap[%layer] );
}
if((%material).detailNormalMap[%layer] $= "")
{
MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( (%material).detailNormalMap[%layer] );
MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( (%material).detailNormalMap[%layer] );
}
if((%material).lightMap[%layer] $= "")
{
MaterialEditorPropertiesWindow-->lightMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->lightMapNameText.setText( (%material).lightMap[%layer] );
MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( (%material).lightMap[%layer] );
}
if((%material).toneMap[%layer] $= "")
{
MaterialEditorPropertiesWindow-->toneMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->toneMapNameText.setText( (%material).toneMap[%layer] );
MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( (%material).toneMap[%layer] );
}
MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]);
MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setValue((%material).invertRoughness[%layer]);
MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( (%material).getORMConfigMapAsset(%layer) );
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( (%material).getORMConfigMap(%layer) );
//hide unused
MaterialEditorPropertiesWindow-->RoughnessTextEdit.setVisible(false);
MaterialEditorPropertiesWindow-->RoughnessSlider.setVisible(false);
MaterialEditorPropertiesWindow-->MetalnessTextEdit.setVisible(false);
MaterialEditorPropertiesWindow-->MetalnessSlider.setVisible(false);
if((%material).ORMConfigMap[%layer] $= "")
MaterialEditorPropertiesWindow-->isSRGBCheckbox.setValue((%material).isSRGB[%layer]);
MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setValue((%material).invertRoughness[%layer]);
//show used
MaterialEditorPropertiesWindow-->isSRGBCheckbox.setVisible(true);
MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setVisible(true);
}
else
{
MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( "tools/materialEditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText( (%material).ORMConfigMap[%layer] );
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( (%material).ORMConfigMap[%layer] );
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
MaterialEditorPropertiesWindow-->RoughnessTextEdit.setText((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->RoughnessSlider.setValue((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]);
//show used
MaterialEditorPropertiesWindow-->RoughnessTextEdit.setVisible(true);
MaterialEditorPropertiesWindow-->RoughnessSlider.setVisible(true);
MaterialEditorPropertiesWindow-->MetalnessTextEdit.setVisible(true);
MaterialEditorPropertiesWindow-->MetalnessSlider.setVisible(true);
//hide unused
MaterialEditorPropertiesWindow-->isSRGBCheckbox.setVisible(false);
MaterialEditorPropertiesWindow-->invertRoughnessCheckbox.setVisible(false);
}
if((%material).roughMap[%layer] $= "")
//AOMap
if((%material).getAOMap(%layer) !$= "" && (%material).getAOMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->roughMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" );
MaterialEditorPropertiesWindow-->aoMapNameText.setText( (%material).getAOMapAsset(%layer) );
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( (%material).getAOMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->roughMapNameText.setText( (%material).roughMap[%layer] );
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( (%material).roughMap[%layer] );
}
if((%material).aoMap[%layer] $= "")
{
MaterialEditorPropertiesWindow-->aoMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" );
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//RoughMap
if((%material).getRoughMap(%layer) !$= "" && (%material).getRoughMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->roughMapNameText.setText( (%material).getRoughMapAsset(%layer) );
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( (%material).getRoughMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->aoMapNameText.setText( (%material).aoMap[%layer] );
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap( (%material).aoMap[%layer] );
MaterialEditorPropertiesWindow-->roughMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
if((%material).metalMap[%layer] $= "")
//MetalMap
if((%material).getMetalMap(%layer) !$= "" && (%material).getMetalMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->metalMapNameText.setText( (%material).getMetalMapAsset(%layer) );
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( (%material).getMetalMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->metalMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" );
}
else
{
MaterialEditorPropertiesWindow-->metalMapNameText.setText( (%material).metalMap[%layer] );
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( (%material).metalMap[%layer] );
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
if((%material).glowMap[%layer] $= "")
//GlowMap
if((%material).getGlowMap(%layer) !$= "" && (%material).getGlowMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->glowMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( "tools/materialeditor/gui/unknownImage" );
MaterialEditorPropertiesWindow-->glowMapNameText.setText( (%material).getGlowMapAsset(%layer) );
MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( (%material).getGlowMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->glowMapNameText.setText( (%material).glowMap[%layer] );
MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( (%material).glowMap[%layer] );
MaterialEditorPropertiesWindow-->glowMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->glowMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//Overlay
if((%material).getOverlayMap(%layer) !$= "" && (%material).getOverlayMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->overlayMapNameText.setText( (%material).getOverlayMapAsset(%layer) );
MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( (%material).getOverlayMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->overlayMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->overlayMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//Detail
if((%material).getDetailMap(%layer) !$= "" && (%material).getDetailMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->detailMapNameText.setText( (%material).getDetailMapAsset(%layer) );
MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( (%material).getDetailMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->detailMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->detailMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//Detail Normal
if((%material).getDetailNormalMap(%layer) !$= "" && (%material).getDetailNormalMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( (%material).getDetailNormalMapAsset(%layer) );
MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( (%material).getDetailNormalMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->detailNormalMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->detailNormalMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//Light
if((%material).getLightMap(%layer) !$= "" && (%material).getLightMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->lightMapNameText.setText( (%material).getLightMapAsset(%layer) );
MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( (%material).getLightMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->lightMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->lightMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
//Tone
if((%material).getToneMap(%layer) !$= "" && (%material).getToneMap(%layer) !$= $MaterialEditor::emptyMaterialImage)
{
MaterialEditorPropertiesWindow-->toneMapNameText.setText( (%material).getToneMapAsset(%layer) );
MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( (%material).getToneMap(%layer) );
}
else
{
MaterialEditorPropertiesWindow-->toneMapNameText.setText( "None" );
MaterialEditorPropertiesWindow-->toneMapDisplayBitmap.setBitmap( $MaterialEditor::emptyMaterialImage );
}
MaterialEditorPropertiesWindow-->accuScaleTextEdit.setText((%material).accuScale[%layer]);
@ -988,10 +983,6 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->colorTintSwatch.color = (%material).diffuseColor[%layer];
MaterialEditorPropertiesWindow-->specularColorSwatch.color = (%material).specular[%layer];
MaterialEditorPropertiesWindow-->RoughnessTextEdit.setText((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->RoughnessSlider.setValue((%material).Roughness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessTextEdit.setText((%material).Metalness[%layer]);
MaterialEditorPropertiesWindow-->MetalnessSlider.setValue((%material).Metalness[%layer]);
MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]);
MaterialEditorPropertiesWindow-->glowMulSlider.setValue((%material).glowMul[%layer]);
MaterialEditorPropertiesWindow-->glowCheckbox.setValue((%material).glow[%layer]);
@ -1235,29 +1226,56 @@ function MaterialEditorGui::updateTextureMap( %this, %type, %action )
{
%layer = MaterialEditorGui.currentLayer;
%this.updatingTextureType = %type;
%bitmapCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapDisplayBitmap", true );
%textCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapNameText", true );
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
%bitmapCtrl.setBitmap(%texture);
%bitmap = %bitmapCtrl.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
%bitmapCtrl.setBitmap(%bitmap);
%textCtrl.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial(%type @ "Map[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
AssetBrowser.showDialog("ImageAsset", %this@".doUpdateTextureMap");
}
else
{
%textCtrl.setText("None");
%bitmapCtrl.setBitmap("tools/materialEditor/gui/unknownImage");
%bitmapCtrl.setBitmap($MaterialEditor::emptyMaterialImage);
MaterialEditorGui.updateActiveMaterial(%type @ "Map[" @ %layer @ "]","");
MaterialEditorGui.updateActiveMaterial(%type @ "MapAsset[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::doUpdateTextureMap( %this, %assetId )
{
if(%assetId !$= "")
{
%layer = MaterialEditorGui.currentLayer;
%type = %this.updatingTextureType;
%bitmapCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapDisplayBitmap", true );
%textCtrl = MaterialEditorPropertiesWindow.findObjectByInternalName( %type @ "MapNameText", true );
%assetDef = AssetDatabase.acquireAsset(%assetId);
%texture = %assetDef.getImagePath();
//%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
%bitmapCtrl.setBitmap(%texture);
%bitmap = %bitmapCtrl.getBitmap();
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
%bitmapCtrl.setBitmap(%bitmap);
%textCtrl.setText(%assetId);
MaterialEditorGui.updateActiveMaterial(%type @ "Map[" @ %layer @ "]","\"\"");
MaterialEditorGui.updateActiveMaterial(%type @ "MapAsset[" @ %layer @ "]","\"" @ %assetId @ "\"");
}
}
%this.updatingTextureType = "";
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateDetailScale(%this,%newScale)
@ -1266,8 +1284,8 @@ function MaterialEditorGui::updateDetailScale(%this,%newScale)
%detailScale = "\"" @ %newScale SPC %newScale @ "\"";
MaterialEditorGui.updateActiveMaterial("detailScale[" @ %layer @ "]", %detailScale);
}
}
function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength)
{
%layer = MaterialEditorGui.currentLayer;
@ -1276,148 +1294,6 @@ function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength)
MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength);
}
function MaterialEditorGui::updateORMConfigMap(%this,%action)
{
%layer = MaterialEditorGui.currentLayer;
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", 0);
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("ORMConfigMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
}
else
{
MaterialEditorPropertiesWindow-->ORMConfigMapNameText.setText("None");
MaterialEditorPropertiesWindow-->ORMConfigMapDisplayBitmap.setBitmap("tools/materialEditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("ORMConfigMap[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateRoughMap(%this,%action)
{
%layer = MaterialEditorGui.currentLayer;
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->roughMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("roughMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
}
else
{
MaterialEditorPropertiesWindow-->roughMapNameText.setText("None");
MaterialEditorPropertiesWindow-->roughMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("roughMap[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateaoMap(%this,%action)
{
%layer = MaterialEditorGui.currentLayer;
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->aoMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("aoMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
}
else
{
MaterialEditorPropertiesWindow-->aoMapNameText.setText("None");
MaterialEditorPropertiesWindow-->aoMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("aoMap[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updatemetalMap(%this,%action)
{
%layer = MaterialEditorGui.currentLayer;
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->metalMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("metalMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
}
else
{
MaterialEditorPropertiesWindow-->metalMapNameText.setText("None");
MaterialEditorPropertiesWindow-->metalMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("metalMap[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateGlowMap(%this,%action)
{
%layer = MaterialEditorGui.currentLayer;
if( %action )
{
%texture = MaterialEditorGui.openFile("texture");
if( %texture !$= "" )
{
MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%texture);
%bitmap = MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.bitmap;
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap(%bitmap);
MaterialEditorPropertiesWindow-->GlowMapNameText.setText(%bitmap);
MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]","\"" @ %bitmap @ "\"");
}
}
else
{
MaterialEditorPropertiesWindow-->GlowMapNameText.setText("None");
MaterialEditorPropertiesWindow-->GlowMapDisplayBitmap.setBitmap("tools/materialeditor/gui/unknownImage");
MaterialEditorGui.updateActiveMaterial("glowMap[" @ %layer @ "]","");
}
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateRotationOffset(%this, %isSlider, %onMouseUp)
{
%layer = MaterialEditorGui.currentLayer;
@ -1600,12 +1476,6 @@ function MaterialEditorGui::updateColorMultiply(%this,%color)
%this.syncGuiColor(MaterialEditorPropertiesWindow-->colorTintSwatch, %propName, %color);
}
function MaterialEditorGui::updateSpecularCheckbox(%this,%value)
{
MaterialEditorGui.updateActiveMaterial("pixelSpecular[" @ MaterialEditorGui.currentLayer @ "]", %value);
MaterialEditorGui.guiSync( materialEd_previewMaterial );
}
function MaterialEditorGui::updateSpecular(%this, %color)
{
%propName = "specular[" @ MaterialEditorGui.currentLayer @ "]";
@ -1831,12 +1701,12 @@ function MaterialEditorGui::createNewCubemap( %this, %cubemap )
new CubemapData(%cubemap)
{
cubeFace[0] = "tools/materialEditor/gui/cube_xNeg";
cubeFace[1] = "tools/materialEditor/gui/cube_xPos";
cubeFace[2] = "tools/materialEditor/gui/cube_ZNeg";
cubeFace[3] = "tools/materialEditor/gui/cube_ZPos";
cubeFace[4] = "tools/materialEditor/gui/cube_YNeg";
cubeFace[5] = "tools/materialEditor/gui/cube_YPos";
cubeMapFaceAsset[0] = "ToolsModule:cube_xNeg_image";
cubeMapFaceAsset[1] = "ToolsModule:cube_xPos_image";
cubeMapFaceAsset[2] = "ToolsModule:cube_zNeg_image";
cubeMapFaceAsset[3] = "ToolsModule:cube_zPos_image";
cubeMapFaceAsset[4] = "ToolsModule:cube_yNeg_image";
cubeMapFaceAsset[5] = "ToolsModule:cube_yPos_image";
parentGroup = RootGroup;
};
@ -2165,6 +2035,16 @@ function MaterialEditorGui::save( %this )
function MaterialEditorGui::createNewMaterial( %this )
{
AssetBrowser_SelectModule.showDialog("MaterialEditorGui.pickedNewMaterialTargetModule");
AssetBrowser_SelectModuleWindow.selectWindow();
}
function MaterialEditorGui::pickedNewMaterialTargetModule( %this, %module )
{
%moduleDef = ModuleDatabase.findModule(%module);
PE_EmitterEditor.targetModule = %module;
MaterialEditorGui.defaultMaterialFile = %moduleDef.ModulePath @ "/scripts/managedData/materials." @ $TorqueScriptFileExtension;
%action = %this.createUndo(ActionCreateNewMaterial, "Create New Material");
%action.object = "";
@ -2572,10 +2452,10 @@ function MaterialEditorGui::saveCompositeMap(%this)
%material = %this.currentMaterial;
%layer = %this.currentLayer;
%roughMap = %material.roughMap[%layer];
%aoMap = %material.aoMap[%layer];
%metalMap = %material.metalMap[%layer];
%glowMap = %material.glowMap[%layer];
%roughMap = %material.getRoughMap(%layer);
%aoMap = %material.getAOMap(%layer);
%metalMap = %material.getMetalMap(%layer);
%glowMap = %material.getGlowMap(%layer);
%roughness = %material.RoughnessChan[%layer];
%ao = %material.AOChan[%layer];