Adds isSRGB and invertSmoothness checkboxes to terrain material editor

Added ability for assimp loader to ignore cached DTS shapes on demand when building shape data
Added assimp importer options to asset import config settings set
Moved variableInspector field types folder from tools/assetBrowser/scripts to tools/guis
This commit is contained in:
Areloch 2019-11-11 01:40:55 -06:00
parent d8cc73f5a1
commit 796a95b8a5
14 changed files with 125 additions and 22 deletions

View file

@ -65,7 +65,9 @@ TerrainMaterial::TerrainMaterial()
mMacroSize( 200.0f ),
mMacroStrength( 0.7f ),
mMacroDistance( 500.0f ),
mParallaxScale( 0.0f )
mParallaxScale( 0.0f ),
mIsSRGB(false),
mInvertSmoothness(false)
{
}
@ -97,7 +99,10 @@ void TerrainMaterial::initPersistFields()
addField( "parallaxScale", TypeF32, Offset( mParallaxScale, TerrainMaterial ), "Used to scale the height from the normal map to give some self "
"occlusion effect (aka parallax) to the terrain material" );
addField("pbrConfigMap", TypeStringFilename, Offset(mCompositeMap, TerrainMaterial), "Composite map for the material");
addField("pbrConfigMap", TypeStringFilename, Offset(mCompositeMap, TerrainMaterial), "Composite map for the PBR Configuration of the material");
addField("isSRGB", TypeBool, Offset(mIsSRGB, TerrainMaterial), "Is the PBR Config map's image in sRGB format?");
addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, TerrainMaterial), "Should the smoothness channel of the PBR Config map be inverted?");
Parent::initPersistFields();
// Gotta call this at least once or it won't get created!

View file

@ -77,6 +77,9 @@ protected:
///
F32 mParallaxScale;
bool mIsSRGB;
bool mInvertSmoothness;
public:
TerrainMaterial();

View file

@ -799,7 +799,7 @@ TSShape* assimpLoadShape(const Torque::Path &path)
return tss;
}
DefineEngineFunction(GetShapeInfo, bool, (const char* shapePath, const char* ctrl), ,
DefineEngineFunction(GetShapeInfo, bool, (const char* shapePath, const char* ctrl, bool loadCachedDts), ("", "", true),
"(string shapePath, GuiTreeViewCtrl ctrl) Collect scene information from "
"a shape file and store it in a GuiTreeView control. This function is "
"used by the assimp import gui to show a preview of the scene contents "
@ -820,7 +820,7 @@ DefineEngineFunction(GetShapeInfo, bool, (const char* shapePath, const char* ctr
// Check if a cached DTS is available => no need to import the source file
// if we can load the DTS instead
Torque::Path path(shapePath);
if (AssimpShapeLoader::canLoadCachedDTS(path))
if (loadCachedDts && AssimpShapeLoader::canLoadCachedDTS(path))
return false;
AssimpShapeLoader loader;

View file

@ -17,7 +17,7 @@ function ToolsModule::onCreate(%this)
// ----------------------------------------------------------------------------
ModuleDatabase.LoadExplicit( "MainEditor" );
ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" );
//ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" );
}
function ToolsModule::onDestroy(%this)

View file

@ -96,11 +96,6 @@ function initializeAssetBrowser()
exec("./scripts/assetTypes/folder.cs");
exec("./scripts/assetTypes/terrain.cs");
exec("./scripts/assetTypes/terrainMaterial.cs");
exec("./scripts/fieldTypes/fieldTypes.cs");
exec("./scripts/fieldTypes/listField.cs");
exec("./scripts/fieldTypes/moduleDependencies.cs");
exec("./scripts/fieldTypes/assetDependencies.cs");
new ScriptObject( AssetBrowserPlugin )
{

View file

@ -28,19 +28,32 @@ function setupImportConfigSettingsList()
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ImportMesh", "Import Mesh", "bool", "", "1", "", "ToggleImportMesh");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/DoUpAxisOverride", "Do Up-axis Override", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/UpAxisOverride", "Up-axis Override", "list", "", "Z_AXIS", "X_AXIS,Y_AXIS,Z_AXIS");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ScaleOverride", "Do Scale Override", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/DoScaleOverride", "Do Scale Override", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ScaleOverride", "Scale Override", "float", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/IgnoreNodeScale", "Ignore Node Scale", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/AdjustCenter", "Adjust Center", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/AdjustFloor", "Adjust Floor", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/CollapseSubmeshes", "Collapse Submeshes", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/LODType", "LOD Type", "list", "", "TrailingNumber", "TrailingNumber,DetectDTS");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/LODType", "LOD Type", "list", "", "TrailingNumber", "TrailingNumber,DetectDTS,SingleSize");
//ImportAssetConfigSettingsList.addNewConfigSetting("TrailingNumber", "Trailing Number", "float", "", "2", "", "Mesh");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ImportedNodes", "Imported Nodes", "command", "", "", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/IgnoreNodes", "Ignore Nodes", "command", "", "", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/ImportMeshes", "Import Meshes", "command", "", "", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/IgnoreMeshes", "Imported Meshes", "command", "", "", "");
//Assimp/Collada params
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/convertLeftHanded", "Convert To Left Hand", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/calcTangentSpace", "Calculate Tangent Space", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/removeRedundantMats", "Remove Redundant Materials", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/genUVCoords", "Generate UV Corrdinates", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/TransformUVs", "Transform UV Coordinates", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/flipUVCoords", "Flip UV Coordinates", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/findInstances", "Find Instances", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/limitBoneWeights", "Limit Bone Weights", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/JoinIdenticalVerts", "Join Identical Verts", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/reverseWindingOrder", "Flip Winding Order", "bool", "", "0", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Meshes/invertNormals", "Invert Normals", "bool", "", "0", "");
//Materials
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/ImportMaterials", "Import Materials", "bool", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Materials/CreateComposites", "Create Composites", "bool", "", "1", "");
@ -54,6 +67,8 @@ function setupImportConfigSettingsList()
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/ImportAnimations", "Import Animations", "bool", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/SeparateAnimations", "Separate Animations", "bool", "", "1", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/SeparateAnimationPrefix", "Separate Animation Prefix", "string", "", "", "");
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/animTiming", "Animation Timing", "list", "", "Seconds", "Frames,Seconds,Milliseconds");
ImportAssetConfigSettingsList.addNewConfigSetting("Animations/animFPS", "Animation FPS", "float", "", "2", "");
//Collision
ImportAssetConfigSettingsList.addNewConfigSetting("Collision/GenerateCollisions", "Generate Collisions", "bool", "", "1", "");

View file

@ -60,7 +60,7 @@ function AssetBrowser::prepareImportShapeAsset(%this, %assetItem)
}
else
{
GetShapeInfo(%assetItem.filePath, %shapeInfo);
GetShapeInfo(%assetItem.filePath, %shapeInfo, false);
}
%assetItem.shapeInfo = %shapeInfo;
@ -241,7 +241,33 @@ function AssetBrowser::importShapeAsset(%this, %assetItem)
else
$TSShapeConstructor::neverImportMat = $TSShapeConstructor::neverImportMat TAB getToken(%ignoreMaterialList, ",;", %i);
}
}
}
if(getAssetImportConfigValue("Materials/DoUpAxisOverride", "") $= "1")
%constructor.upAxis = getAssetImportConfigValue("Meshes/UpAxisOverride", "Z_AXIS");
%constructor.lodType = getAssetImportConfigValue("Meshes/LODType", "0");
//%constructor.singleDetailSize = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
%constructor.alwaysImport = getAssetImportConfigValue("Meshes/ImportedNodes", "");
%constructor.neverImport = getAssetImportConfigValue("Meshes/IgnoreNodes", "");
%constructor.alwaysImportMesh = getAssetImportConfigValue("Meshes/ImportMeshes", "");
%constructor.neverImportMesh = getAssetImportConfigValue("Meshes/IgnoreMeshes", "");
%constructor.ignoreNodeScale = getAssetImportConfigValue("Meshes/IgnoreNodeScale", "0");
%constructor.adjustCenter = getAssetImportConfigValue("Meshes/AdjustCenter", "0");
%constructor.adjustFloor = getAssetImportConfigValue("Meshes/AdjustFloor", "0");
%constructor.convertLeftHanded = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
%constructor.calcTangentSpace = getAssetImportConfigValue("Meshes/calcTangentSpace", "0");
%constructor.genUVCoords = getAssetImportConfigValue("Meshes/genUVCoords", "0");
%constructor.flipUVCoords = getAssetImportConfigValue("Meshes/flipUVCoords", "0");
%constructor.findInstances = getAssetImportConfigValue("Meshes/findInstances", "0");
%constructor.limitBoneWeights = getAssetImportConfigValue("Meshes/limitBoneWeights", "0");
%constructor.joinIdenticalVerts = getAssetImportConfigValue("Meshes/joinIdenticalVerts", "0");
%constructor.reverseWindingOrder = getAssetImportConfigValue("Meshes/reverseWindingOrder", "0");
%constructor.invertNormals = getAssetImportConfigValue("Meshes/invertNormals", "0");
%constructor.removeRedundantMats = getAssetImportConfigValue("Meshes/removeRedundantMats", "0");
%constructor.animTiming = getAssetImportConfigValue("Animations/animTiming", "Seconds");
%constructor.animFPS = getAssetImportConfigValue("Animations/animFPS", "2");
%constructor.neverImportMat = $TSShapeConstructor::neverImportMat;
ShapeEditor.saveConstructor( %constructor );

View file

@ -35,4 +35,9 @@ exec("./guiObjectInspector.ed.cs");
exec("./uvEditor.ed.gui");
exec("./objectSelection.ed.cs");
exec("./postFxManager.gui");
exec("./assimpImport.ed.gui");
exec("./assimpImport.ed.gui");
exec("./fieldTypes/assetDependencies.cs");
exec("./fieldTypes/fieldTypes.cs");
exec("./fieldTypes/listField.cs");
exec("./fieldTypes/moduleDependencies.cs");

View file

@ -165,7 +165,7 @@
new GuiBitmapCtrl() {
bitmap = "core/art/gui/images/separator-v";
color = "255 255 255 255";
color = "White";
wrap = "0";
position = "1 0";
extent = "183 2";
@ -739,7 +739,7 @@
anchorLeft = "1";
anchorRight = "0";
position = "6 184";
extent = "185 50";
extent = "185 64";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "bottom";
@ -888,12 +888,52 @@
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = " Is sRGB";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "55 32";
extent = "119 16";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "isSRGb";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiCheckBoxCtrl() {
text = " Invert Smoothness";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
position = "55 48";
extent = "119 16";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiCheckBoxProfile";
visible = "1";
active = "1";
tooltipProfile = "ToolsGuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
internalName = "invertSmoothness";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiBitmapCtrl() {
bitmap = "tools/gui/images/separator-v";
color = "255 255 255 255";
wrap = "0";
position = "6 238";
position = "6 254";
extent = "175 2";
minExtent = "8 2";
horizSizing = "width";
@ -914,7 +954,7 @@
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "6 245";
position = "6 261";
extent = "185 72";
minExtent = "8 2";
horizSizing = "width";
@ -1222,7 +1262,7 @@
bitmap = "tools/gui/images/separator-v";
color = "255 255 255 255";
wrap = "0";
position = "6 320";
position = "6 336";
extent = "175 2";
minExtent = "8 2";
horizSizing = "width";
@ -1243,7 +1283,7 @@
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "6 327";
position = "6 343";
extent = "185 72";
minExtent = "8 2";
horizSizing = "width";

View file

@ -449,6 +449,9 @@ function TerrainMaterialDlg::setActiveMaterial( %this, %mat )
%this-->macroSizeCtrl.setText( %mat.macroSize );
%this-->macroStrengthCtrl.setText( %mat.macroStrength );
%this-->macroDistanceCtrl.setText( %mat.macroDistance );
%this-->isSRGB.setValue( %mat.isSRGB );
%this-->invertSmoothness.setValue( %mat.invertSmoothness );
%this.activateMaterialCtrls( true );
}
@ -508,6 +511,9 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%macroStrength = %this-->macroStrengthCtrl.getText();
%macroDistance = %this-->macroDistanceCtrl.getText();
%isSRGB = %this-->isSRGB.getValue();
%invertSmoothness = %this-->invertSmoothness.getValue();
// If no properties of this materials have changed,
// return.
@ -525,7 +531,9 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.macroSize == %macroSize &&
%mat.macroStrength == %macroStrength &&
%mat.macroDistance == %macroDistance &&
%mat.parallaxScale == %parallaxScale )
%mat.parallaxScale == %parallaxScale &&
%mat.isSRGB == %isSRGB &&
%mat.invertSmoothness == %invertSmoothness)
return;
// Make sure the material name is unique.
@ -560,6 +568,8 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
%mat.macroDistance = %macroDistance;
%mat.useSideProjection = %useSideProjection;
%mat.parallaxScale = %parallaxScale;
%mat.isSRGB = %isSRGB;
%mat.invertSmoothness = %invertSmoothness;
// Mark the material as dirty and needing saving.
@ -606,6 +616,8 @@ function TerrainMaterialDlg::snapshotMaterials( %this )
macroDistance = %mat.macroDistance;
useSideProjection = %mat.useSideProjection;
parallaxScale = %mat.parallaxScale;
isSRGB = %mat.isSRGB;
invertSmoothness = %mat.invertSmoothness;
};
}
}
@ -641,6 +653,8 @@ function TerrainMaterialDlg::restoreMaterials( %this )
%mat.macroDistance = %obj.macroDistance;
%mat.useSideProjection = %obj.useSideProjection;
%mat.parallaxScale = %obj.parallaxScale;
%mat.isSRGB = %obj.isSRGB;
%mat.invertSmoothness = %obj.invertSmoothness;
}
}