mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Converts the ad-hoc design of the Material Editor to utilize the same inspector interface as most everything else does.
- Overhauls the material editor to simplify and streamline the logic behind it since the inspector does most of the work - Tweak a few order positions of materialdefinition fields to work better - Sets AO, Rough and Metal channel fields to use an enum type for human readability - Updates the MaterialPreview gui control to work with assetIds - MatEd now supports setting of parent material to inherit from - Creating a new material now can prompt selecting an existing material to inherit from - Can now edit the mapTo value of a material in the matEd - New standalone Composite Texture Editor window for convering AO, Roughness and Metalness maps in a material to an ORMMap - Can also star the creation of a composite texture via RMB context menu in AB on an image asset - Moved logic of CubemapEditor from MatEd to it's own stuff - Made ImageAsset fields now be more clear when they have nothing assigned, and also have a clear button to empty the field's value so it's consistent across the board - Reorganized the layout of the gui and image files for the MatEd to be easier to navigate - MaterialEditor now overlays the EditorGUI instead of being forcefully embedded in it, allowing easy editing of the MatEd Gui via the Gui editor
This commit is contained in:
parent
8e93753b15
commit
f3cad0d77e
173 changed files with 3713 additions and 6977 deletions
|
|
@ -1,5 +1,39 @@
|
|||
AssetBrowser::registerAssetType("ImageAsset", "Images");
|
||||
|
||||
function ImageAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%filePath = %assetPath @ %assetName @ ".png";
|
||||
|
||||
%asset = new ImageAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
imageFile = %assetName @ ".png";
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%filePath))
|
||||
{
|
||||
%file.close();
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function ImageAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
//%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath())));
|
||||
|
|
@ -96,6 +130,17 @@ function ImageAsset::generatePreviewImage(%this, %previewButton, %forceRegenerat
|
|||
function ImageAsset::onShowActionMenu(%this)
|
||||
{
|
||||
GenericAsset::onShowActionMenu(%this);
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
|
||||
EditAssetPopup.setItemPosition("Create Composite Texture" TAB "" TAB "CompositeTextureEditor.buildComposite(\"" @ %assetId @ "\");", 4);
|
||||
|
||||
EditAssetPopup.objectData = %assetId;
|
||||
EditAssetPopup.objectType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditAssetPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.showPopup(Canvas);
|
||||
}
|
||||
|
||||
function ImageAsset::onEditProperties(%this)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
AssetBrowser::registerAssetType("MaterialAsset", "Materials");
|
||||
|
||||
function MaterialAsset::setupCreateNew()
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Material");
|
||||
NewAssetPropertiesInspector.addField("InheritFrom", "Inherit From", "MaterialInheritList", "What material should this new one inherit from.", "", "", $CurrentAssetBrowser.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
|
||||
function MaterialAsset::onCreateNew()
|
||||
{
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
|
@ -18,6 +26,7 @@ function MaterialAsset::onCreateNew()
|
|||
materialDefinitionName = %assetName;
|
||||
|
||||
new Material(%assetName) {
|
||||
inheritFrom = $CurrentAssetBrowser.newAssetSettings.inheritFrom;
|
||||
mapTo = %assetName;
|
||||
};
|
||||
};
|
||||
|
|
@ -227,3 +236,101 @@ function GuiInspectorTypeMaterialAssetPtr::onControlDropped( %this, %payload, %p
|
|||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
||||
function GuiInspectorGroup::buildMaterialInheritListField(%this, %fieldName, %fieldLabel, %fieldDesc, %fieldDefaultVal, %fieldDataVals, %callbackName, %ownerObj)
|
||||
{
|
||||
%extent = 18;
|
||||
|
||||
%fieldCtrl = %this.createInspectorField();
|
||||
|
||||
%extent = %this.stack.getExtent();
|
||||
|
||||
%width = mRound(%extent/2);
|
||||
%height = 20;
|
||||
%inset = 10;
|
||||
|
||||
%editControl = new GuiPopUpMenuCtrlEx() {
|
||||
class = "materialInheritListField";
|
||||
maxPopupHeight = "200";
|
||||
sbUsesNAColor = "0";
|
||||
reverseTextList = "0";
|
||||
bitmapBounds = "16 16";
|
||||
maxLength = "1024";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "1";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "1";
|
||||
AnchorRight = "0";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiPopUpMenuProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
Position = %fieldCtrl.edit.position;
|
||||
Extent = %fieldCtrl.edit.extent;
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "ToolsGuiToolTipProfile";
|
||||
tooltip = ""; //%tooltip;
|
||||
text = %fieldDefaultVal;
|
||||
hovertime = "1000";
|
||||
ownerObject = %ownerObj;
|
||||
fieldName = %fieldName;
|
||||
callbackName = %callbackName;
|
||||
allowTextSearch = true;
|
||||
};
|
||||
|
||||
//set the field value
|
||||
if(getSubStr(%this.fieldName, 0, 1) $= "$")
|
||||
{
|
||||
if(%fieldName $= "")
|
||||
%editControl.setText(%fieldName);
|
||||
}
|
||||
else if(isObject(%ownerObj))
|
||||
{
|
||||
//regular variable
|
||||
%setCommand = %editControl @ ".setText(" @ %ownerObj @ "." @ %fieldName @ ");";
|
||||
eval(%setCommand);
|
||||
}
|
||||
|
||||
%listCount = getTokenCount(%fieldDataVals, ",;");
|
||||
|
||||
for(%i=0; %i < materialSet.getCount(); %i++)
|
||||
{
|
||||
%matObj = materialSet.getObject(%i);
|
||||
%matName = %matObj.getName();
|
||||
|
||||
if(%matName !$= "")
|
||||
%editControl.add(%matName);
|
||||
}
|
||||
|
||||
%fieldCtrl.setCaption(%fieldLabel);
|
||||
%fieldCtrl.setEditControl(%editControl);
|
||||
|
||||
//echo("GuiInspectorListField - " @ %editControl.getID() @ " - " @ %fieldName);
|
||||
|
||||
%this.addInspectorField(%fieldCtrl);
|
||||
}
|
||||
|
||||
function materialInheritListField::onSelect( %this, %id, %text )
|
||||
{
|
||||
if(getSubStr(%this.fieldName, 0, 1) $= "$")
|
||||
{
|
||||
//ah, a global var, just do it straight, then
|
||||
%setCommand = %this.fieldName @ " = \"" @ %text @ "\";";
|
||||
}
|
||||
else if(isObject(%this.ownerObject))
|
||||
{
|
||||
//regular variable
|
||||
%setCommand = %this.ownerObject @ "." @ %this.fieldName @ " = \"" @ %text @ "\";";
|
||||
}
|
||||
else if(%this.callbackName !$= "")
|
||||
{
|
||||
%setCommand = %this.callbackName @ "(\"" @ %this.fieldName @ "\",\"" @ %text @"\");";
|
||||
}
|
||||
|
||||
echo("materialInheritListField::onSelect() - command: " @ %setCommand);
|
||||
|
||||
eval(%setCommand);
|
||||
}
|
||||
|
|
@ -16,6 +16,11 @@ function AssetBrowser::editAsset(%this, %assetDef)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(AssetDatabase.isDeclaredAsset(%assetDef))
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetDef);
|
||||
}
|
||||
|
||||
if(isObject(%assetDef))
|
||||
{
|
||||
%assetType = AssetDatabase.getAssetType(%assetDef.getAssetId());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue