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:
JeffR 2025-08-03 12:03:02 -05:00
parent 8e93753b15
commit f3cad0d77e
173 changed files with 3713 additions and 6977 deletions

View file

@ -2,6 +2,6 @@
canSave="true"
canSaveDynamicFields="true"
AssetName="CubemapEditor"
scriptFile="@assetFile=cubemapEditor.gui"
scriptFile="@assetFile=cubemapEditor.tscript"
GUIFile="@assetFile=cubemapEditor.gui"
VersionId="1" />

View file

@ -0,0 +1,437 @@
//--- OBJECT WRITE BEGIN ---
$guiContent = new GuiControl(CompositeTextureEditor) {
extent = "1920 1080";
horizSizing = "width";
vertSizing = "height";
profile = "ToolsGuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
isContainer = "1";
canSaveDynamicFields = "1";
enabled = "1";
new GuiWindowCtrl(CompositeTextureEditorWindow) {
Text = "Composite Texture Editor";
resizeWidth = "0";
resizeHeight = "0";
canMinimize = "0";
canMaximize = "0";
closeCommand = "Canvas.popDialog(CompositeTextureEditor);";
position = "721 416";
extent = "478 248";
minExtent = "478 248";
horizSizing = "center";
vertSizing = "center";
profile = "ToolsGuiWindowProfile";
tooltipProfile = "GuiToolTipProfile";
new GuiContainer(CompTextureEd_RedChan) {
position = "11 39";
extent = "107 174";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
className = "CompositeTextureSlotContainer";
new GuiTextCtrl() {
Text = "Red Channel";
position = "5 -2";
extent = "100 15";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 20";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "InputMode";
className = "CompositeTextureChannelMode";
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueContainer";
new GuiTextEditCtrl() {
position = "0 8";
extent = "28 20";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueTxtEdit";
className = "CompositeTextureRawValueEdit";
};
new GuiSliderCtrl() {
position = "38 9";
extent = "68 19";
profile = "GuiSliderProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueSlider";
className = "CompositeTextureRawValueSlider";
Command = "$thisControl.onDragComplete();";
range = 0 SPC 1;
ticks = 0.01;
};
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "TextureContainer";
new GuiBitmapCtrl() {
BitmapAsset = "ToolsModule:unknownImage_image";
BitmapFile = "tools/materialEditor/images/unknownImage.png";
position = "21 9";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "Bitmap";
};
new GuiBitmapButtonCtrl() {
BitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
position = "21 9";
extent = "64 64";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
command = "$CompTexSourceChannel = 0;AssetBrowser.showDialog(\"ImageAsset\", \"CompositeTextureEditor.setSourceTex\");";
tooltipProfile = "ToolsGuiDefaultProfile";
ToolTip = "Set the source of the texture for this channel to sample from when baking a composite.";
};
new GuiTextCtrl() {
Text = "Source Channel";
position = "5 85";
extent = "100 10";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 97";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "sourceChannel";
className = "CompositeTextureTexSrcChannel";
};
};
};
new GuiContainer(CompTextureEd_GreenChan) {
position = "129 39";
extent = "107 174";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
className = "CompositeTextureSlotContainer";
new GuiTextCtrl() {
Text = "Green Channel";
position = "5 -2";
extent = "100 15";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 20";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "InputMode";
className = "CompositeTextureChannelMode";
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueContainer";
new GuiTextEditCtrl() {
position = "0 8";
extent = "28 20";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueTxtEdit";
className = "CompositeTextureRawValueEdit";
};
new GuiSliderCtrl() {
position = "38 9";
extent = "68 19";
profile = "GuiSliderProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueSlider";
className = "CompositeTextureRawValueSlider";
Command = "$thisControl.onDragComplete();";
range = 0 SPC 1;
ticks = 0.01;
};
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "TextureContainer";
new GuiBitmapCtrl() {
BitmapAsset = "ToolsModule:unknownImage_image";
BitmapFile = "tools/materialEditor/images/unknownImage.png";
position = "21 9";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "Bitmap";
};
new GuiBitmapButtonCtrl() {
BitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
position = "21 9";
extent = "64 64";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
command = "$CompTexSourceChannel = 1;AssetBrowser.showDialog(\"ImageAsset\", \"CompositeTextureEditor.setSourceTex\");";
tooltipProfile = "ToolsGuiDefaultProfile";
ToolTip = "Set the source of the texture for this channel to sample from when baking a composite.";
};
new GuiTextCtrl() {
Text = "Source Channel";
position = "5 85";
extent = "100 10";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 97";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "sourceChannel";
className = "CompositeTextureTexSrcChannel";
};
};
};
new GuiContainer(CompTextureEd_BlueChan) {
position = "247 39";
extent = "107 174";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
className = "CompositeTextureSlotContainer";
new GuiTextCtrl() {
Text = "Blue Channel";
position = "5 -2";
extent = "100 15";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 20";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "InputMode";
className = "CompositeTextureChannelMode";
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueContainer";
new GuiTextEditCtrl() {
position = "0 8";
extent = "28 20";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueTxtEdit";
className = "CompositeTextureRawValueEdit";
};
new GuiSliderCtrl() {
position = "38 9";
extent = "68 19";
profile = "GuiSliderProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueSlider";
className = "CompositeTextureRawValueSlider";
Command = "$thisControl.onDragComplete();";
range = 0 SPC 1;
ticks = 0.01;
};
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "TextureContainer";
new GuiBitmapCtrl() {
BitmapAsset = "ToolsModule:unknownImage_image";
BitmapFile = "tools/materialEditor/images/unknownImage.png";
position = "21 9";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "Bitmap";
};
new GuiBitmapButtonCtrl() {
BitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
position = "21 9";
extent = "64 64";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
command = "$CompTexSourceChannel = 2;AssetBrowser.showDialog(\"ImageAsset\", \"CompositeTextureEditor.setSourceTex\");";
tooltipProfile = "ToolsGuiDefaultProfile";
ToolTip = "Set the source of the texture for this channel to sample from when baking a composite.";
};
new GuiTextCtrl() {
Text = "Source Channel";
position = "5 85";
extent = "100 10";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 97";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "sourceChannel";
className = "CompositeTextureTexSrcChannel";
};
};
};
new GuiContainer(CompTextureEd_AlphaChan) {
position = "361 39";
extent = "107 174";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
className = "CompositeTextureSlotContainer";
new GuiTextCtrl() {
Text = "Alpha Channel";
position = "5 -2";
extent = "100 15";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 20";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "InputMode";
className = "CompositeTextureChannelMode";
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueContainer";
new GuiTextEditCtrl() {
position = "0 8";
extent = "28 20";
profile = "ToolsGuiTextEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueTxtEdit";
className = "CompositeTextureRawValueEdit";
};
new GuiSliderCtrl() {
position = "38 9";
extent = "68 19";
profile = "GuiSliderProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "RawValueSlider";
className = "CompositeTextureRawValueSlider";
Command = "$thisControl.onDragComplete();";
range = 0 SPC 1;
ticks = 0.01;
};
};
new GuiContainer() {
position = "0 41";
extent = "107 125";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "TextureContainer";
new GuiBitmapCtrl() {
BitmapAsset = "ToolsModule:unknownImage_image";
BitmapFile = "tools/materialEditor/images/unknownImage.png";
position = "21 9";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "Bitmap";
};
new GuiBitmapButtonCtrl() {
BitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
position = "21 9";
extent = "64 64";
horizSizing = "center";
profile = "ToolsGuiDefaultProfile";
command = "$CompTexSourceChannel = 3;AssetBrowser.showDialog(\"ImageAsset\", \"CompositeTextureEditor.setSourceTex\");";
tooltipProfile = "ToolsGuiDefaultProfile";
ToolTip = "Set the source of the texture for this channel to sample from when baking a composite.";
};
new GuiTextCtrl() {
Text = "Source Channel";
position = "5 85";
extent = "100 10";
horizSizing = "width";
profile = "ToolsGuiTextProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiPopUpMenuCtrl() {
position = "1 97";
extent = "106 23";
horizSizing = "width";
profile = "ToolsGuiPopUpMenuEditProfile";
tooltipProfile = "GuiToolTipProfile";
internalName = "sourceChannel";
className = "CompositeTextureTexSrcChannel";
};
};
};
new GuiButtonCtrl() {
Text = "Save";
position = "339 216";
extent = "74 24";
profile = "ToolsGuiButtonProfile";
command = "CompositeTextureEditor.saveComposite();";
tooltipProfile = "GuiToolTipProfile";
};
new GuiButtonCtrl() {
Text = "Cancel";
position = "417 216";
extent = "52 24";
profile = "ToolsGuiButtonProfile";
command = "Canvas.popDialog(CompositeTextureEditor);";
tooltipProfile = "GuiToolTipProfile";
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,192 @@
function CompositeTextureEditor::buildComposite(%this, %sourceTex0, %sourceTex1, %sourceTex2, %sourceTex3, %sourceChan0, %sourceChan1, %sourceChan2, %sourceChan3, %callback)
{
Canvas.pushDialog(%this);
CompTextureEd_RedChan.setChannelData(%sourceTex0, %sourceChan0);
CompTextureEd_GreenChan.setChannelData(%sourceTex1, %sourceChan1);
CompTextureEd_BlueChan.setChannelData(%sourceTex2, %sourceChan2);
CompTextureEd_AlphaChan.setChannelData(%sourceTex3, %sourceChan3);
%this.callbackFunc = %callback;
}
function CompositeTextureSlotContainer::onWake(%this)
{
%this-->InputMode.clear();
%this-->InputMode.add("Raw Value");
%this-->InputMode.add("Texture");
%this-->InputMode.setSelected(1);
%this-->InputMode.active = false;
%this-->sourceChannel.clear();
%this-->sourceChannel.add("Red");
%this-->sourceChannel.add("Green");
%this-->sourceChannel.add("Blue");
%this-->sourceChannel.add("Alpha");
}
function CompositeTextureSlotContainer::setChannelData(%this, %sourceValue, %sourceChannel)
{
//for now, hard-force Texture mode
%this-->InputMode.setSelected(1);
if(AssetDatabase.isDeclaredAsset(%sourceValue))
{
%this-->InputMode.setSelected(1);
%this-->bitmap.setBitmap(%sourceValue);
if(%sourceChannel $= "")
%sourceChannel = "Red";
%this-->sourceChannel.setText(%sourceChannel);
}
/*else
{
%this-->InputMode.setSelected(0);
%value = 0;
if(%sourceValue !$= "" && (isFloat(%sourceValue) || isFloat(%sourceValue)))
{
%value = %sourceValue;
}
%this-->RawValueTxtEdit.setText(%value);
%this-->RawValueSlider.setValue(%value);
}*/
}
function CompositeTextureSlotContainer::getChannelData(%this)
{
return "";
}
function CompositeTextureChannelMode::onSelect(%this, %id, %text)
{
%isRawValueMode = %text $= "Raw Value";
%this.getParent()-->RawValueContainer.setVisible(%isRawValueMode);
%this.getParent()-->TextureContainer.setVisible(!%isRawValueMode);
}
function CompositeTextureEditor::setSourceTex(%this, %assetId)
{
if($CompTexSourceChannel $= "")
$CompTexSourceChannel = 0;
%channelContainer = CompositeTextureEditorWindow.getObject($CompTexSourceChannel);
%channelContainer-->bitmap.setBitmap(%assetId);
}
function CompositeTextureEditor::saveComposite(%this)
{
%cubemap = CubemapEditor.currentCubemap;
%aoMap = CompTextureEd_RedChan-->Bitmap.getBitmap();
%roughMap = CompTextureEd_GreenChan-->Bitmap.getBitmap();
%metalMap = CompTextureEd_BlueChan-->Bitmap.getBitmap();
if(%aoMap $= "ToolsModule:unknownImage_image")
%aoMap = "";
if(%roughMap $= "ToolsModule:unknownImage_image")
%roughMap = "";
if(%metalMap $= "ToolsModule:unknownImage_image")
%metalMap = "";
if(%aoMap $= "" && %roughMap $= "" && %metalMap $= "")
{
toolsMessageBoxOK("Error", "Saving a composite map requires at least one channel slot to have source data!");
return;
}
AssetBrowser.setupCreateNewAsset("ImageAsset", AssetBrowser.selectedModule, "CompositeEditorDoSaveComposite");
}
function CompositeEditorDoSaveComposite(%assetId)
{
%assetDef = AssetDatabase.acquireAsset(%assetId);
if(!isObject(%assetDef))
{
toolsMessageBoxOK("Error", "We somehow failed to successfully create a new ImageAsset!");
return;
}
%targetFilePath = %assetDef.getImagePath();
%aoMapAsset = CompTextureEd_RedChan-->Bitmap.getBitmap();
%roughMapAsset = CompTextureEd_GreenChan-->Bitmap.getBitmap();
%metalMapAsset = CompTextureEd_BlueChan-->Bitmap.getBitmap();
if(%aoMapAsset $= "ToolsModule:unknownImage_image")
{
%aoMap = "";
}
else
{
%aoAssetDef = AssetDatabase.acquireAsset(%aoMapAsset);
%aoMap = %aoAssetDef.getImagePath();
}
if(%roughMapAsset $= "ToolsModule:unknownImage_image")
{
%roughMap = "";
}
else
{
%roughAssetDef = AssetDatabase.acquireAsset(%roughMapAsset);
%roughMap = %roughAssetDef.getImagePath();
}
if(%metalMapAsset $= "ToolsModule:unknownImage_image")
{
%metalMap = "";
}
else
{
%metalAssetDef = AssetDatabase.acquireAsset(%metalMapAsset);
%metalMap = %roughAssetDef.getImagePath();
}
if(%aoMap $= "" && %roughMap $= "" && %metalMap $= "")
{
toolsMessageBoxOK("Error", "Attempted to create a composite texture but all three source textures are blank or invalid!");
return;
}
%redChanSource = CompTextureEd_RedChan-->sourceChannel;
%greenChanSource = CompTextureEd_GreenChan-->sourceChannel;
%blueChanSource = CompTextureEd_BlueChan-->sourceChannel;
%aoChan = %redChanSource.findText(%redChanSource.getText());
%aoChan = %aoChan == -1 ? 0 : %aoChan;
%roughChan = %greenChanSource.findText(%greenChanSource.getText());
%roughChan = %roughChan == -1 ? 1 : %roughChan;
%metalChan = %blueChanSource.findText(%blueChanSource.getText());
%metalChan = %metalChan == -1 ? 2 : %metalChan;
%channelKey = %aoChan SPC %roughChan SPC %metalChan SPC 3;
error("Storing: \"" @ %aoMap @"\" \""@ %roughMap @"\" \""@ %metalMap @"\" \""@ %channelKey @"\" \""@ %targetFilePath @"\"");
saveCompositeTexture(%aoMap, %roughMap, %metalMap, "", %channelKey, %targetFilePath);
%assetDef.refreshAsset();
%command = CompositeTextureEditor.callbackFunc @ "(\"" @ %assetId @ "\");";
if(CompositeTextureEditor.callbackFunc !$= "")
{
eval(%command);
CompositeTextureEditor.callbackFunc = "";
}
Canvas.popDialog(CompositeTextureEditor);
}
function CompositeTextureRawValueEdit::onReturn(%this)
{
%this.getParent()-->RawValueSlider.setValue(%this.getText());
}
function CompositeTextureRawValueSlider::onDragComplete(%this)
{
%value = %this.getValue();
%this.getParent()-->RawValueTxtEdit.setText(%value);
}

View file

@ -39,7 +39,7 @@ $guiContent = new GuiControl(CubemapEditor) {
canMaximize = "0";
minSize = "50 50";
EdgeSnap = "1";
closeCommand = "MaterialEditorGui.hideCubemapEditor(true);";
closeCommand = "CubemapEditor.hideCubemapEditor(true);";
text = "Cubemap Editor";
new GuiTextCtrl(){
@ -69,23 +69,23 @@ $guiContent = new GuiControl(CubemapEditor) {
AnchorRight = "0";
text = "myCubemap 1";
maxLength = "1024";
AltCommand = "MaterialEditorGui.editCubemapName($ThisControl.getText());";
AltCommand = "CubemapEditor.editCubemapName($ThisControl.getText());";
};
new GuiButtonCtrl(){
Profile = "ToolsGuiButtonProfile";
position = "339 216";
Extent = "74 24";
text = "Select";
command = "MaterialEditorGui.selectCubemap();"; // needs hookup use selected cubemap
command = "CubemapEditor.selectCubemap();"; // needs hookup use selected cubemap
};
new GuiButtonCtrl(){
Profile = "ToolsGuiButtonProfile";
position = "417 216";
Extent = "52 24";
text = "Cancel";
command = "MaterialEditorGui.hideCubemapEditor(true);"; // needs hookup Cancel
command = "CubemapEditor.hideCubemapEditor(true);"; // needs hookup Cancel
};
new GuiScrollCtrl(matEd_cubemapEd_availableCubemapScroller) {
new GuiScrollCtrl(cubemapEd_availableCubemapScroller) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "1";
@ -106,7 +106,7 @@ $guiContent = new GuiControl(CubemapEditor) {
constantThumbHeight = "0";
childMargin = "0 0";
new GuiListBoxCtrl(matEd_cubemapEd_availableCubemapList) {
new GuiListBoxCtrl(cubemapEd_availableCubemapList) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -130,7 +130,7 @@ $guiContent = new GuiControl(CubemapEditor) {
text = "Cubemaps";
};
// ------------------------------ Right X Positive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_XPos) {
new GuiBitmapCtrl(cubemapEd_XPos) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -146,12 +146,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_xPosTxt) {
new GuiTextCtrl(cubeMapEd_xPosTxt) {
position = "304 110";
Extent = "57 10";
text = "+ X Right";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXPOSImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateXPOSImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -163,7 +163,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"0\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"0\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -173,7 +173,7 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
};
// ------------------------------ X Negitive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_XNeg) {
new GuiBitmapCtrl(cubemapEd_XNeg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -189,12 +189,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_xNegTxt) {
new GuiTextCtrl(cubeMapEd_xNegTxt) {
position = "171 110";
Extent = "57 10";
text = "- X Left";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXNEGImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateXNEGImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -206,7 +206,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"1\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"1\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -216,7 +216,7 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
};
// ------------------------------ Y Positive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_YPos) {
new GuiBitmapCtrl(cubemapEd_YPos) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -232,12 +232,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_yPosTxt) {
new GuiTextCtrl(cubeMapEd_yPosTxt) {
position = "237 175";
Extent = "57 10";
text = "+ Y Front";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYPOSImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateYPOSImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -249,7 +249,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"3\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"3\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -259,7 +259,7 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
};
// ------------------------------ Y Negitive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_YNeG) {
new GuiBitmapCtrl(cubemapEd_YNeG) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -275,12 +275,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_yNegTxt) {
new GuiTextCtrl(cubeMapEd_yNegTxt) {
position = "237 44";
Extent = "57 10";
text = "- Y Back";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYNegImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateYNegImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -292,7 +292,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"2\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"2\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -302,7 +302,7 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
};
// ------------------------------ Z Positive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_ZPos) {
new GuiBitmapCtrl(cubemapEd_ZPos) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -318,12 +318,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_zPosTxt) {
new GuiTextCtrl(cubeMapEd_zPosTxt) {
position = "237 110";
Extent = "57 10";
text = "+ Z Top";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZPosImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateZPosImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -335,7 +335,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"4\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"4\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -345,7 +345,7 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:cubemapBtnBorder_n_image";
};
// ------------------------------ Z Negitive ------------------------------------
new GuiBitmapCtrl(matEd_cubemapEd_ZNeg) {
new GuiBitmapCtrl(cubemapEd_ZNeg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -361,12 +361,12 @@ $guiContent = new GuiControl(CubemapEditor) {
bitmapAsset = "ToolsModule:unknownImage_image";
wrap = "0";
};
new GuiTextCtrl(matEd_cubeMapEd_zNegTxt) {
new GuiTextCtrl(cubeMapEd_zNegTxt) {
position = "369 110";
Extent = "57 10";
text = "- Z Bottom";
};
new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZNegImg) {
new GuiBitmapButtonCtrl(cubeMapEd_updateZNegImg) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
@ -378,7 +378,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.editCubemapImage(\"5\", $ThisControl.bitmap );";
Command = "CubemapEditor.editCubemapImage(\"5\", $ThisControl.bitmap );";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here.";
hovertime = "1000";
@ -401,7 +401,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "matEd_addCubemapWindow.setVisible(1);"; // -------------- Needs Hookup Create New Cubemap
Command = "addCubemapWindow.setVisible(1);"; // -------------- Needs Hookup Create New Cubemap
hovertime = "1000";
tooltip = "Create New Cubemap";
bitmapAsset = "ToolsModule:new_n_image";
@ -421,7 +421,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.showDeleteCubemapDialog();"; // -------------- Needs Hookup Delete Cubemap
Command = "CubemapEditor.showDeleteCubemapDialog();"; // -------------- Needs Hookup Delete Cubemap
hovertime = "1000";
tooltip = "Delete Cubemap";
bitmapAsset = "ToolsModule:delete_n_image";
@ -442,7 +442,7 @@ $guiContent = new GuiControl(CubemapEditor) {
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.showSaveCubemapDialog();"; // -------------- Needs Hookup Save Cubemap
Command = "CubemapEditor.showSaveCubemapDialog();"; // -------------- Needs Hookup Save Cubemap
hovertime = "1000";
tooltip = "Save Cubemap";
bitmapAsset = "ToolsModule:save_icon_n_image";
@ -451,4 +451,123 @@ $guiContent = new GuiControl(CubemapEditor) {
useMouseEvents = "0";
};
};
new GuiWindowCtrl(addCubemapWindow) {
canSaveDynamicFields = "0";
isContainer = "1";
Profile = "ToolsGuiWindowProfile";
HorizSizing = "center";
VertSizing = "center";
position = "362 333";
Extent = "300 99";
MinExtent = "48 92";
canSave = "1";
Visible = "0";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
resizeWidth = "1";
resizeHeight = "1";
canMove = "1";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
EdgeSnap = "1";
text = "Create Cubemap";
new GuiTextEditCtrl() {
canSaveDynamicFields = "0";
internalName = "cubemapName";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "96 35";
Extent = "196 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
maxLength = "1024";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
AltCommand = "";
passwordMask = "*";
};
new GuiTextCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "ToolsGuiTextProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "12 36";
Extent = "77 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
maxLength = "1024";
text = "Cubemap Name";
};
new GuiButtonCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "ToolsGuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "96 68";
Extent = "126 22";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
text = "Create";
Command = "CubemapEditor.addCubemap( addCubemapWindow-->cubemapName.getText() );addCubemapWindow.setVisible(0);";
};
new GuiButtonCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "ToolsGuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "228 68";
Extent = "64 22";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
text = "Cancel";
Command = "addCubemapWindow.setVisible(0);";
};
};
};

View file

@ -0,0 +1,367 @@
function CubemapEditor::onWake(%this)
{
cubemapEd_availableCubemapList.clear();
}
function CubemapEditor::cancelCubemap(%this)
{
%cubemap = CubemapEditor.currentCubemap;
%idx = cubemapEd_availableCubemapList.findItemText( %cubemap.getName() );
cubemapEd_availableCubemapList.setItemText( %idx, notDirtyCubemap.originalName );
%cubemap.setName( notDirtyCubemap.originalName );
CubemapEditor.copyCubemaps( notDirtyCubemap, %cubemap );
CubemapEditor.copyCubemaps( notDirtyCubemap, matEdCubeMapPreviewMat);
%cubemap.updateFaces();
matEdCubeMapPreviewMat.updateFaces();
}
function CubemapEditor::showCubemapEditor(%this)
{
if (cubemapEditor.isVisible())
return;
CubemapEditor.currentCubemap = "";
cubemapEditor.setVisible(1);
new PersistenceManager(cubemapEdPerMan);
CubemapEditor.setCubemapNotDirty();
for( %i = 0; %i < RootGroup.getCount(); %i++ )
{
if( RootGroup.getObject(%i).getClassName()!$= "CubemapData" )
continue;
for( %k = 0; %k < UnlistedCubemaps.count(); %k++ )
{
%unlistedFound = 0;
if( UnlistedCubemaps.getValue(%k) $= RootGroup.getObject(%i).name )
{
%unlistedFound = 1;
break;
}
}
if( %unlistedFound )
continue;
cubemapEd_availableCubemapList.addItem( RootGroup.getObject(%i).name );
}
singleton CubemapData(notDirtyCubemap);
// if there was no cubemap, pick the first, select, and bail, these are going to take
// care of themselves in the selected function
if( !isObject( CubemapEditor.currentMaterial.cubemap ) )
{
if( cubemapEd_availableCubemapList.getItemCount() > 0 )
{
cubemapEd_availableCubemapList.setSelected(0, true);
return;
}
else
{
// if there are no cubemaps, then create one, select, and bail
%cubemap = CubemapEditor.createNewCubemap();
cubemapEd_availableCubemapList.addItem( %cubemap.name );
cubemapEd_availableCubemapList.setSelected(0, true);
return;
}
}
// do not directly change activeMat!
CubemapEditor.currentCubemap = CubemapEditor.currentMaterial.cubemap.getId();
%cubemap = CubemapEditor.currentCubemap;
notDirtyCubemap.originalName = %cubemap.getName();
CubemapEditor.copyCubemaps( %cubemap, notDirtyCubemap);
CubemapEditor.copyCubemaps( %cubemap, matEdCubeMapPreviewMat);
CubemapEditor.syncCubemap( %cubemap );
}
function CubemapEditor::hideCubemapEditor(%this,%cancel)
{
if(%cancel)
CubemapEditor.cancelCubemap();
cubemapEd_availableCubemapList.clearItems();
cubemapEdPerMan.delete();
cubemapEditor.setVisible(0);
}
// create category and update current material if there is one
function CubemapEditor::addCubemap( %this,%cubemapName )
{
if( %cubemapName $= "" )
{
toolsMessageBoxOK( "Error", "Can not create a cubemap without a valid name.");
return;
}
for(%i = 0; %i < RootGroup.getCount(); %i++)
{
if( %cubemapName $= RootGroup.getObject(%i).getName() )
{
toolsMessageBoxOK( "Error", "There is already an object with the same name.");
return;
}
}
// Create and select a new cubemap
%cubemap = CubemapEditor.createNewCubemap( %cubemapName );
%idx = cubemapEd_availableCubemapList.addItem( %cubemap.name );
cubemapEd_availableCubemapList.setSelected( %idx, true );
// material category text field to blank
addCubemapWindow-->cubemapName.setText("");
}
function CubemapEditor::createNewCubemap( %this, %cubemap )
{
if( %cubemap $= "" )
{
for(%i = 0; ; %i++)
{
%cubemap = "newCubemap_" @ %i;
if( !isObject(%cubemap) )
break;
}
}
new CubemapData(%cubemap)
{
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;
};
cubemapEdPerMan.setDirty( %cubemap, "art/materials." @ $TorqueScriptFileExtension );
cubemapEdPerMan.saveDirty();
return %cubemap;
}
function CubemapEditor::setCubemapDirty(%this)
{
%propertyText = "Create Cubemap *";
cubemapEditor.text = %propertyText;
cubemapEditor.dirty = true;
cubemapEditor-->saveCubemap.setActive(true);
%cubemap = CubemapEditor.currentCubemap;
// materials created in the materail selector are given that as its filename, so we run another check
if( CubemapEditor.isMatEditorMaterial( %cubemap ) )
cubemapEdPerMan.setDirty(%cubemap, "art/materials." @ $TorqueScriptFileExtension);
else
cubemapEdPerMan.setDirty(%cubemap);
}
function CubemapEditor::setCubemapNotDirty(%this)
{
%propertyText= strreplace("Create Cubemap" , "*" , "");
cubemapEditor.text = %propertyText;
cubemapEditor.dirty = false;
cubemapEditor-->saveCubemap.setActive(false);
%cubemap = CubemapEditor.currentCubemap;
cubemapEdPerMan.removeDirty(%cubemap);
}
function CubemapEditor::showDeleteCubemapDialog(%this)
{
%idx = cubemapEd_availableCubemapList.getSelectedItem();
%cubemap = cubemapEd_availableCubemapList.getItemText( %idx );
%cubemap = %cubemap.getId();
if( %cubemap == -1 || !isObject(%cubemap) )
return;
if( isObject( %cubemap ) )
{
toolsMessageBoxYesNoCancel("Delete Cubemap?",
"Are you sure you want to delete<br><br>" @ %cubemap.getName() @ "<br><br> Cubemap deletion won't take affect until the engine is quit.",
"CubemapEditor.deleteCubemap( " @ %cubemap @ ", " @ %idx @ " );",
"",
"" );
}
}
function CubemapEditor::deleteCubemap( %this, %cubemap, %idx )
{
cubemapEd_availableCubemapList.deleteItem( %idx );
UnlistedCubemaps.add( "unlistedCubemaps", %cubemap.getName() );
if( !CubemapEditor.isMatEditorMaterial( %cubemap ) )
{
cubemapEdPerMan.removeDirty( %cubemap );
cubemapEdPerMan.removeObjectFromFile( %cubemap );
}
if( cubemapEd_availableCubemapList.getItemCount() > 0 )
{
cubemapEd_availableCubemapList.setSelected(0, true);
}
else
{
// if there are no cubemaps, then create one, select, and bail
%cubemap = CubemapEditor.createNewCubemap();
cubemapEd_availableCubemapList.addItem( %cubemap.getName() );
cubemapEd_availableCubemapList.setSelected(0, true);
}
}
function cubemapEd_availableCubemapList::onSelect( %this, %id, %cubemap )
{
%cubemap = %cubemap.getId();
if( CubemapEditor.currentCubemap $= %cubemap )
return;
if( cubemapEditor.dirty )
{
%savedCubemap = CubemapEditor.currentCubemap;
toolsMessageBoxYesNoCancel("Save Existing Cubemap?",
"Do you want to save changes to <br><br>" @ %savedCubemap.getName(),
"CubemapEditor.saveCubemap(" @ true @ ");",
"CubemapEditor.saveCubemapDialogDontSave(" @ %cubemap @ ");",
"CubemapEditor.saveCubemapDialogCancel();" );
}
else
CubemapEditor.changeCubemap( %cubemap );
}
function CubemapEditor::showSaveCubemapDialog( %this )
{
%cubemap = CubemapEditor.currentCubemap;
if( !isObject(%cubemap) )
return;
toolsMessageBoxYesNoCancel("Save Cubemap?",
"Do you want to save changes to <br><br>" @ %cubemap.getName(),
"CubemapEditor.saveCubemap( " @ %cubemap @ " );",
"",
"" );
}
function CubemapEditor::saveCubemap( %this, %cubemap )
{
notDirtyCubemap.originalName = %cubemap.getName();
CubemapEditor.copyCubemaps( %cubemap, notDirtyCubemap );
CubemapEditor.copyCubemaps( %cubemap, matEdCubeMapPreviewMat);
cubemapEdPerMan.saveDirty();
CubemapEditor.setCubemapNotDirty();
}
function CubemapEditor::saveCubemapDialogDontSave( %this, %newCubemap)
{
//deal with old cubemap first
%oldCubemap = CubemapEditor.currentCubemap;
%idx = cubemapEd_availableCubemapList.findItemText( %oldCubemap.getName() );
cubemapEd_availableCubemapList.setItemText( %idx, notDirtyCubemap.originalName );
%oldCubemap.setName( notDirtyCubemap.originalName );
CubemapEditor.copyCubemaps( notDirtyCubemap, %oldCubemap);
CubemapEditor.copyCubemaps( notDirtyCubemap, matEdCubeMapPreviewMat);
CubemapEditor.syncCubemap( %oldCubemap );
CubemapEditor.changeCubemap( %newCubemap );
}
function CubemapEditor::saveCubemapDialogCancel( %this )
{
%cubemap = CubemapEditor.currentCubemap;
%idx = cubemapEd_availableCubemapList.findItemText( %cubemap.getName() );
cubemapEd_availableCubemapList.clearSelection();
cubemapEd_availableCubemapList.setSelected( %idx, true );
}
function CubemapEditor::changeCubemap( %this, %cubemap )
{
CubemapEditor.setCubemapNotDirty();
CubemapEditor.currentCubemap = %cubemap;
notDirtyCubemap.originalName = %cubemap.getName();
CubemapEditor.copyCubemaps( %cubemap, notDirtyCubemap);
CubemapEditor.copyCubemaps( %cubemap, matEdCubeMapPreviewMat);
CubemapEditor.syncCubemap( %cubemap );
}
function CubemapEditor::editCubemapImage( %this, %face )
{
CubemapEditor.setCubemapDirty();
%cubemap = CubemapEditor.currentCubemap;
%bitmap = CubemapEditor.openFile("texture");
if( %bitmap !$= "" && %bitmap !$= "tools/materialEditor/gui/cubemapBtnBorder" )
{
%cubemap.cubeFace[%face] = %bitmap;
CubemapEditor.copyCubemaps( %cubemap, matEdCubeMapPreviewMat);
CubemapEditor.syncCubemap( %cubemap );
}
}
function CubemapEditor::editCubemapName( %this, %newName )
{
CubemapEditor.setCubemapDirty();
%cubemap = CubemapEditor.currentCubemap;
%idx = cubemapEd_availableCubemapList.findItemText( %cubemap.getName() );
cubemapEd_availableCubemapList.setItemText( %idx, %newName );
%cubemap.setName(%newName);
CubemapEditor.syncCubemap( %cubemap );
}
function CubemapEditor::syncCubemap( %this, %cubemap )
{
%xpos = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[0]);
if( %xpos !$= "" )
cubemapEd_XPos.setBitmap( %xpos );
%xneg = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[1]);
if( %xneg !$= "" )
cubemapEd_XNeg.setBitmap( %xneg );
%yneg = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[2]);
if( %yneg !$= "" )
cubemapEd_YNeG.setBitmap( %yneg );
%ypos = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[3]);
if( %ypos !$= "" )
cubemapEd_YPos.setBitmap( %ypos );
%zpos = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[4]);
if( %zpos !$= "" )
cubemapEd_ZPos.setBitmap( %zpos );
%zneg = CubemapEditor.searchForTexture(%cubemap.getName(), %cubemap.cubeFace[5]);
if( %zneg !$= "" )
cubemapEd_ZNeg.setBitmap( %zneg );
cubemapEd_activeCubemapNameTxt.setText(%cubemap.getName());
%cubemap.updateFaces();
matEdCubeMapPreviewMat.updateFaces();
}
function CubemapEditor::copyCubemaps( %this, %copyFrom, %copyTo)
{
%copyTo.cubeFace[0] = %copyFrom.cubeFace[0];
%copyTo.cubeFace[1] = %copyFrom.cubeFace[1];
%copyTo.cubeFace[2] = %copyFrom.cubeFace[2];
%copyTo.cubeFace[3] = %copyFrom.cubeFace[3];
%copyTo.cubeFace[4] = %copyFrom.cubeFace[4];
%copyTo.cubeFace[5] = %copyFrom.cubeFace[5];
}