mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
fix material editor
material editor now handles named targets propertly when loading also update preview image in material editor
This commit is contained in:
parent
16d219769f
commit
e1a2a6d9f9
2 changed files with 23 additions and 10 deletions
|
|
@ -2772,6 +2772,7 @@ function AssetBrowser::importLooseFiles(%this)
|
||||||
|
|
||||||
function getAssetPreviewImage(%asset)
|
function getAssetPreviewImage(%asset)
|
||||||
{
|
{
|
||||||
|
echo(%asset);
|
||||||
if(isFile(%asset))
|
if(isFile(%asset))
|
||||||
{
|
{
|
||||||
%aq = new AssetQuery();
|
%aq = new AssetQuery();
|
||||||
|
|
@ -2793,7 +2794,7 @@ function getAssetPreviewImage(%asset)
|
||||||
%moduleName = AssetDatabase.getAssetModule(%asset).ModuleId;
|
%moduleName = AssetDatabase.getAssetModule(%asset).ModuleId;
|
||||||
%assetName = AssetDatabase.getAssetName(%asset);
|
%assetName = AssetDatabase.getAssetName(%asset);
|
||||||
%previewAssetName = "ToolsModule:" @ %moduleName @ "_" @ %assetName @ "_PreviewImage";
|
%previewAssetName = "ToolsModule:" @ %moduleName @ "_" @ %assetName @ "_PreviewImage";
|
||||||
|
echo(%previewAssetName);
|
||||||
if(AssetDatabase.isDeclaredAsset(%previewAssetName))
|
if(AssetDatabase.isDeclaredAsset(%previewAssetName))
|
||||||
{
|
{
|
||||||
%previewDef = AssetDatabase.acquireAsset(%previewAssetName);
|
%previewDef = AssetDatabase.acquireAsset(%previewAssetName);
|
||||||
|
|
|
||||||
|
|
@ -747,8 +747,8 @@ function MaterialEditorGui::setActiveMaterial( %this, %material )
|
||||||
|
|
||||||
// we create or recreate a material to hold in a pristine state
|
// we create or recreate a material to hold in a pristine state
|
||||||
// or, this crashes the ap. fix properly - BJR
|
// or, this crashes the ap. fix properly - BJR
|
||||||
// if(isObject(notDirtyMaterial))
|
//if(isObject(notDirtyMaterial))
|
||||||
// notDirtyMaterial.delete();
|
// notDirtyMaterial.delete();
|
||||||
|
|
||||||
singleton Material(notDirtyMaterial)
|
singleton Material(notDirtyMaterial)
|
||||||
{
|
{
|
||||||
|
|
@ -860,16 +860,27 @@ function MaterialEditorGui::convertTextureFields(%this)
|
||||||
}
|
}
|
||||||
|
|
||||||
function MaterialEditorGui::convertMaterialTextureField(%this, %material, %mapName)
|
function MaterialEditorGui::convertMaterialTextureField(%this, %material, %mapName)
|
||||||
{
|
{
|
||||||
for(%index = 0; %index < 4; %index++)
|
for(%index = 0; %index < 4; %index++)
|
||||||
{
|
{
|
||||||
%mapFile = %material.call("get" @ %mapName, %index);
|
%mapFile = %material.call("get" @ %mapName, %index);
|
||||||
if(%mapFile !$= "" && !isFile(%mapFile))
|
if(%mapFile !$= "" && !isFile(%mapFile))
|
||||||
{
|
{
|
||||||
//see if we can't go finding it
|
if(isFile(%mapFile))
|
||||||
%mapFile = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %mapFile);
|
{
|
||||||
MaterialEditorGui.currentMaterial.call("set" @ %mapName, %mapFile, %index);
|
//see if we can't go finding it
|
||||||
}
|
%mapFile = MaterialEditorGui.searchForTexture(MaterialEditorGui.currentMaterial, %mapFile);
|
||||||
|
MaterialEditorGui.currentMaterial.call("set" @ %mapName, %mapFile, %index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
%assetPtr = %material.call("get" @ %mapName @ "Asset", %index);
|
||||||
|
if(%assetPtr.isNamedTarget())
|
||||||
|
{
|
||||||
|
MaterialEditorGui.currentMaterial.call("set" @ %mapName, %assetPtr, %index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1088,8 +1099,9 @@ function MaterialEditorGui::guiSync( %this, %material )
|
||||||
//Diffuse
|
//Diffuse
|
||||||
%diffuseMap = (%material).getDiffuseMap(%layer);
|
%diffuseMap = (%material).getDiffuseMap(%layer);
|
||||||
%diffuseMapText = %diffuseMap !$= "" && %diffuseMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getDiffuseMapAsset(%layer) : "None";
|
%diffuseMapText = %diffuseMap !$= "" && %diffuseMap !$=$MaterialEditor::emptyMaterialImage ? (%material).getDiffuseMapAsset(%layer) : "None";
|
||||||
|
|
||||||
MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( %diffuseMapText );
|
MaterialEditorPropertiesWindow-->diffuseMapNameText.setText( %diffuseMapText );
|
||||||
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( getAssetPreviewImage(%diffuseMap) );
|
MaterialEditorPropertiesWindow-->diffuseMapDisplayBitmap.setBitmap( getAssetPreviewImage(%diffuseMapText) );
|
||||||
|
|
||||||
//Normal
|
//Normal
|
||||||
%normalMap = (%material).getNormalMap(%layer);
|
%normalMap = (%material).getNormalMap(%layer);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue