mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 12:44:46 +00:00
- 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
162 lines
7.3 KiB
Plaintext
162 lines
7.3 KiB
Plaintext
//-----------------------------------------------------------------------------
|
|
// Copyright (c) 2012 GarageGames, LLC
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to
|
|
// deal in the Software without restriction, including without limitation the
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
// IN THE SOFTWARE.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Material Editor Written by Dave Calabrese and Travis Vroman of Gaslight Studios
|
|
|
|
function initializeMaterialEditor()
|
|
{
|
|
echo(" % - Initializing Material Editor");
|
|
|
|
//Material Instance viewer
|
|
exec("~/materialEditor/gui/materialInstancesView.ed.gui");
|
|
|
|
exec("./gui/MaterialEditorGui.gui");
|
|
|
|
// Load Client Scripts.
|
|
exec("./scripts/materialEditor.ed." @ $TorqueScriptFileExtension);
|
|
exec("./scripts/materialEditorUndo.ed." @ $TorqueScriptFileExtension);
|
|
exec("./scripts/materialInstanceView.ed." @ $TorqueScriptFileExtension);
|
|
|
|
exec("./scripts/materialAnimationFieldTypes." @ $TorqueScriptFileExtension);
|
|
exec("./scripts/bakeCompositeButtonFieldType." @ $TorqueScriptFileExtension);
|
|
exec("./scripts/ORMSliderFieldType." @ $TorqueScriptFileExtension);
|
|
}
|
|
|
|
function destroyMaterialEditor()
|
|
{
|
|
}
|
|
|
|
// Material Editor
|
|
function MaterialEditorPlugin::onWorldEditorStartup( %this )
|
|
{
|
|
// Add ourselves to the window menu.
|
|
%accel = EditorGui.addToEditorsMenu( "Material Editor", "", MaterialEditorPlugin );
|
|
|
|
// Add ourselves to the ToolsToolbar
|
|
%tooltip = "Material Editor (" @ %accel @ ")";
|
|
EditorGui.addToToolsToolbar( "MaterialEditorPlugin", "MaterialEditorPalette", "ToolsModule:material_editor_n_image", %tooltip );
|
|
|
|
//connect editor windows
|
|
GuiWindowCtrl::attach( MaterialEditorPropertiesWindow, MaterialEditorPreviewWindow);
|
|
|
|
%map = new ActionMap();
|
|
%map.bindCmd( keyboard, "1", "EWorldEditorNoneModeBtn.performClick();", "" ); // Select
|
|
%map.bindCmd( keyboard, "2", "EWorldEditorMoveModeBtn.performClick();", "" ); // Move
|
|
%map.bindCmd( keyboard, "3", "EWorldEditorRotateModeBtn.performClick();", "" ); // Rotate
|
|
%map.bindCmd( keyboard, "4", "EWorldEditorScaleModeBtn.performClick();", "" ); // Scale
|
|
%map.bindCmd( keyboard, "f", "FitToSelectionBtn.performClick();", "" );// Fit Camera to Selection
|
|
%map.bindCmd( keyboard, "z", "EditorGuiStatusBar.setCamera(\"Standard Camera\");", "" );// Free Camera
|
|
%map.bindCmd( keyboard, "n", "ToggleNodeBar->renderHandleBtn.performClick();", "" );// Render Node
|
|
%map.bindCmd( keyboard, "shift n", "ToggleNodeBar->renderTextBtn.performClick();", "" );// Render Node Text
|
|
%map.bindCmd( keyboard, "alt s", "MaterialEditorGui.save();", "" );// Save Material
|
|
//%map.bindCmd( keyboard, "delete", "ToggleNodeBar->renderTextBtn.performClick();", "" );// delete Material
|
|
%map.bindCmd( keyboard, "g", "ESnapOptions-->GridSnapButton.performClick();" ); // Grid Snappping
|
|
%map.bindCmd( keyboard, "t", "SnapToBar->objectSnapDownBtn.performClick();", "" );// Terrain Snapping
|
|
%map.bindCmd( keyboard, "b", "SnapToBar-->objectSnapBtn.performClick();" ); // Soft Snappping
|
|
%map.bindCmd( keyboard, "v", "EWorldEditorToolbar->boundingBoxColBtn.performClick();", "" );// Bounds Selection
|
|
%map.bindCmd( keyboard, "o", "objectCenterDropdown->objectBoxBtn.performClick(); objectCenterDropdown.toggle();", "" );// Object Center
|
|
%map.bindCmd( keyboard, "p", "objectCenterDropdown->objectBoundsBtn.performClick(); objectCenterDropdown.toggle();", "" );// Bounds Center
|
|
%map.bindCmd( keyboard, "k", "objectTransformDropdown->objectTransformBtn.performClick(); objectTransformDropdown.toggle();", "" );// Object Transform
|
|
%map.bindCmd( keyboard, "l", "objectTransformDropdown->worldTransformBtn.performClick(); objectTransformDropdown.toggle();", "" );// World Transform
|
|
|
|
MaterialEditorPlugin.map = %map;
|
|
|
|
MaterialEditorGui.fileSpec = "Torque Material Files (materials." @ $TorqueScriptFileExtension @ ")|materials." @ $TorqueScriptFileExtension @ "|All Files (*.*)|*.*|";
|
|
MaterialEditorGui.textureFormats = "Image Files (*.png, *.jpg, *.dds, *.bmp, *.gif, *.jng. *.tga)|*.png;*.jpg;*.dds;*.bmp;*.gif;*.jng;*.tga|All Files (*.*)|*.*|";
|
|
MaterialEditorGui.modelFormats = "DTS Files (*.dts)|*.dts";
|
|
MaterialEditorGui.lastTexturePath = "";
|
|
MaterialEditorGui.lastTextureFile = "";
|
|
MaterialEditorGui.lastModelPath = "";
|
|
MaterialEditorGui.lastModelFile = "";
|
|
MaterialEditorGui.currentMaterial = "";
|
|
MaterialEditorGui.lastMaterial = "";
|
|
MaterialEditorGui.currentCubemap = "";
|
|
MaterialEditorGui.currentObject = "";
|
|
|
|
MaterialEditorGui.livePreview = "1";
|
|
MaterialEditorGui.currentLayer = "0";
|
|
MaterialEditorGui.currentMode = "Material";
|
|
MaterialEditorGui.currentMeshMode = "EditorShape";
|
|
|
|
new ArrayObject(UnlistedCubemaps);
|
|
UnlistedCubemaps.add( "unlistedCubemaps", matEdCubeMapPreviewMat );
|
|
UnlistedCubemaps.add( "unlistedCubemaps", WarnMatCubeMap );
|
|
|
|
//MaterialEditor persistence manager
|
|
new PersistenceManager(matEd_PersistMan);
|
|
}
|
|
|
|
function MaterialEditorPlugin::onActivated( %this )
|
|
{
|
|
if($gfx::wireframe){
|
|
$wasInWireFrameMode = true;
|
|
$gfx::wireframe = false;
|
|
}else{
|
|
$wasInWireFrameMode = false;
|
|
}
|
|
advancedTextureMapsRollout.Expanded = false;
|
|
accumulationPropertiesRollout.Expanded = false;
|
|
lightingPropertiesRollout.Expanded = false;
|
|
materialAnimationPropertiesRollout.Expanded = false;
|
|
materialAdvancedPropertiesRollout.Expanded = false;
|
|
WorldEditorPlugin.onActivated();
|
|
|
|
//EditorGui-->MatEdPropertiesWindow.setVisible( true );
|
|
//EditorGui-->MatEdPreviewWindow.setVisible( true );
|
|
EditorGui-->WorldEditorToolbar.setVisible( true );
|
|
|
|
MaterialEditorGui.currentObject = $Tools::materialEditorList;
|
|
// Execute the back end scripts that actually do the work.
|
|
MaterialEditorGui.open();
|
|
%this.map.push();
|
|
|
|
// Do resize the windows at start
|
|
MaterialEditorGui.onWake();
|
|
|
|
Canvas.pushDialog(MaterialEditorGui);
|
|
|
|
Parent::onActivated(%this);
|
|
}
|
|
|
|
function MaterialEditorPlugin::onEditMenuSelect( %this, %editMenu )
|
|
{
|
|
WorldEditorPlugin.onEditMenuSelect( %editMenu );
|
|
}
|
|
|
|
function MaterialEditorPlugin::onDeactivated( %this )
|
|
{
|
|
if($wasInWireFrameMode)
|
|
$gfx::wireframe = true;
|
|
|
|
WorldEditorPlugin.onDeactivated();
|
|
|
|
Canvas.popDialog(MaterialEditorGui);
|
|
MaterialEditorGui.quit();
|
|
|
|
//EditorGui-->MatEdPropertiesWindow.setVisible( false );
|
|
//EditorGui-->MatEdPreviewWindow.setVisible( false );
|
|
EditorGui-->WorldEditorToolbar.setVisible( false );
|
|
%this.map.pop();
|
|
|
|
Parent::onDeactivated(%this);
|
|
}
|