mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Shifts handling of material and terrain material definitions to be written into the asset definition taml file instead of having an extra loose file
Also updates importers to correctly handle this change Adds ability for taml XML serialization to properly assign array'd fields Adds 'inheritFrom' field to simobjects for when objects with parent objects are serialized AssetBase how inherits from SimGroup so it can have objects like material definitions embedded in them for save/load in the taml definition file Updated loading/handling logic in terrain material asset to be more similar to regular material assets
This commit is contained in:
parent
656475deaf
commit
630285def6
20 changed files with 791 additions and 318 deletions
|
|
@ -47,7 +47,7 @@
|
|||
<Setting name="AlwaysAddMaterialSuffix">0</Setting>
|
||||
<Setting name="CreateComposites">1</Setting>
|
||||
<Setting name="CreateORMConfig">1</Setting>
|
||||
<Setting name="IgnoreMaterials">DefaultMaterial</Setting>
|
||||
<Setting name="IgnoreMaterials">DefaultMaterial,ColorEffect*</Setting>
|
||||
<Setting name="ImportMaterials">1</Setting>
|
||||
<Setting name="PopulateMaterialMaps">1</Setting>
|
||||
<Setting name="UseDiffuseSuffixOnOriginImage">1</Setting>
|
||||
|
|
@ -130,6 +130,7 @@
|
|||
<Setting name="AlwaysAddMaterialSuffix">1</Setting>
|
||||
<Setting name="CreateComposites">1</Setting>
|
||||
<Setting name="ImportMaterials">1</Setting>
|
||||
<Setting name="IgnoreMaterials">DefaultMaterial,ColorEffect*</Setting>
|
||||
<Setting name="PopulateMaterialMaps">1</Setting>
|
||||
<Setting name="UseDiffuseSuffixOnOriginImage">1</Setting>
|
||||
<Setting name="UseExistingMaterials">1</Setting>
|
||||
|
|
|
|||
|
|
@ -2444,7 +2444,6 @@ function AssetBrowserFilterTree::onControlDropped( %this, %payload, %position )
|
|||
|
||||
function AssetBrowserFilterTree::onDragDropped( %this )
|
||||
{
|
||||
%asdgadfhg =true;
|
||||
}
|
||||
|
||||
function AssetBrowser::hasLooseFilesInDir(%this)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ function AssetBrowser::createMaterialAsset(%this)
|
|||
%assetPath = AssetBrowser.dirHandler.currentAddress @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
|
||||
%asset = new MaterialAsset()
|
||||
{
|
||||
|
|
@ -16,13 +15,13 @@ function AssetBrowser::createMaterialAsset(%this)
|
|||
versionId = 1;
|
||||
materialDefinitionName = %assetName;
|
||||
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
|
||||
new Material(%assetName) {
|
||||
};
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%mat = new Material(%assetName);
|
||||
%mat.save(%scriptPath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
|
|
@ -42,6 +41,7 @@ function AssetBrowser::editMaterialAsset(%this, %assetDef)
|
|||
|
||||
EditorGui.setEditor(MaterialEditorPlugin);
|
||||
|
||||
MaterialEditorGui.currentMaterialAsset = %assetDef.getAssetId();
|
||||
MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
|
||||
MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,37 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
|
|||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
materialDefinitionName = %assetName;
|
||||
};
|
||||
|
||||
%matDef = new TerrainMaterial(%assetName)
|
||||
{
|
||||
internalName = %moduleName @ ":" @ %assetName;
|
||||
diffuseMap = "";
|
||||
detailMap = "";
|
||||
detailSize = "10";
|
||||
isManaged = "1";
|
||||
detailBrightness = "1";
|
||||
Enabled = "1";
|
||||
diffuseSize = "200";
|
||||
};
|
||||
|
||||
%fxMatDef = new Material("TerrainFX_" @ %assetName)
|
||||
{
|
||||
mapTo = %assetName;
|
||||
footstepSoundId = 0;
|
||||
terrainMaterials = "1";
|
||||
ShowDust = "1";
|
||||
showFootprints = "1";
|
||||
materialTag0 = "Terrain";
|
||||
effectColor[0] = "0.42 0.42 0 1";
|
||||
effectColor[1] = "0.42 0.42 0 1";
|
||||
impactSoundId = "0";
|
||||
};
|
||||
|
||||
%asset.add(%matDef);
|
||||
%asset.add(%fxMatDef);
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
|
|
@ -28,35 +55,6 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
|
|||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
//AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%templateFilePath = %this.templateFilesPath @ "terrainMaterial." @ $TorqueScriptFileExtension @ ".template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
//echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateNewTerrainMaterialAsset - Something went wrong and we couldn't write thescript file!");
|
||||
}
|
||||
|
||||
//If we've got the terrain mat editor open, go ahead and update it all
|
||||
TerrainMaterialDlg.onWake();
|
||||
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ function SubMaterialSelector::onSelect( %this )
|
|||
}
|
||||
else
|
||||
{
|
||||
MaterialEditorGui.currentMaterialAsset = %material;
|
||||
%assetDef = AssetDatabase.acquireAsset(%material);
|
||||
%material = %assetDef.materialDefinitionName;
|
||||
}
|
||||
|
|
@ -1906,6 +1907,7 @@ function MaterialEditorGui::saveDialogDontSave( %this, %material )
|
|||
|
||||
if(AssetDatabase.isDeclaredAsset(%material))
|
||||
{
|
||||
MaterialEditorGui.currentMaterialAsset = %material;
|
||||
%material = AssetDatabase.acquireAsset(%material).materialDefinitionName;
|
||||
}
|
||||
|
||||
|
|
@ -1916,6 +1918,7 @@ function MaterialEditorGui::saveDialogSave( %this, %material )
|
|||
{
|
||||
if(AssetDatabase.isDeclaredAsset(%material))
|
||||
{
|
||||
MaterialEditorGui.currentMaterialAsset = %material;
|
||||
%material = AssetDatabase.acquireAsset(%material).materialDefinitionName;
|
||||
}
|
||||
|
||||
|
|
@ -1945,8 +1948,18 @@ function MaterialEditorGui::save( %this )
|
|||
if( %currentMaterial.isAutoGenerated() )
|
||||
%currentMaterial.setAutoGenerated( false );
|
||||
|
||||
// Save the material using the persistence manager
|
||||
matEd_PersistMan.saveDirty();
|
||||
if(MaterialEditorGui.currentMaterialAsset !$= "")
|
||||
{
|
||||
MaterialEditorGui.copyMaterials( materialEd_previewMaterial, notDirtyMaterial );
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(MaterialEditorGui.currentMaterialAsset);
|
||||
%assetDef.saveAsset(); //write it out
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save the material using the persistence manager
|
||||
matEd_PersistMan.saveDirty();
|
||||
}
|
||||
|
||||
// Clean up the Material Editor
|
||||
MaterialEditorGui.copyMaterials( materialEd_previewMaterial, notDirtyMaterial );
|
||||
|
|
@ -2211,6 +2224,7 @@ function MaterialEditorGui::changeMaterial(%this, %fromMaterial, %toMaterial)
|
|||
if(AssetDatabase.isDeclaredAsset(%toMaterial))
|
||||
{
|
||||
%isMatAsset = true;
|
||||
MaterialEditorGui.currentMaterialAsset = %toMaterial;
|
||||
%assetDef = AssetDatabase.acquireAsset(%toMaterial);
|
||||
%toMaterialDefinition = %assetDef.materialDefinitionName;
|
||||
%filename = %assetDef.getScriptPath();
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ function T3Dpre4ProjectImporter::writeImportingFiles(%this)
|
|||
if($ProjectImporter::useExistingModule)
|
||||
{
|
||||
//clean up legact files if they've been renamed or whatnot
|
||||
if(%file !$= %rootFileSectionObject.fileDestination)
|
||||
if(makeRelativePath(%file) !$= %rootFileSectionObject.fileDestination)
|
||||
{
|
||||
fileDelete(%file);
|
||||
}
|
||||
|
|
@ -659,8 +659,6 @@ function T3Dpre4ProjectImporter::processAssetFile(%this, %assetObj)
|
|||
if(!isObject(%assetObj))
|
||||
return;
|
||||
|
||||
%assetObj.echo();
|
||||
|
||||
//really, we only care here about ensuring the file extensions are cleaned up
|
||||
for(%l=0; %l < %assetObj.count(); %l++)
|
||||
{
|
||||
|
|
@ -691,6 +689,9 @@ function T3Dpre4ProjectImporter::beginAssetAndModuleImport(%this)
|
|||
|
||||
if(%fileExt $= ".module")
|
||||
{
|
||||
if(%rootFileSectionObject.skip)
|
||||
continue;
|
||||
|
||||
projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
|
||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
||||
%this.processModuleFile(%rootFileSectionObject);
|
||||
|
|
@ -698,6 +699,9 @@ function T3Dpre4ProjectImporter::beginAssetAndModuleImport(%this)
|
|||
}
|
||||
else if(%fileExt $= ".asset.taml")
|
||||
{
|
||||
if(%rootFileSectionObject.skip)
|
||||
continue;
|
||||
|
||||
projectImporterLog("T3Dpre4ProjectImporter::beginAssetAndModuleImport() - processing file: " @ %file);
|
||||
$ProjectImporter::currentFilePath = filePath(%rootFileSectionObject.fileDestination) @ "/";
|
||||
%this.processAssetFile(%rootFileSectionObject);
|
||||
|
|
@ -913,12 +917,11 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %obje
|
|||
versionId = 1;
|
||||
shaderData = "";
|
||||
materialDefinitionName = %assetName;
|
||||
scriptFile = fileBase(%scriptPath);
|
||||
};
|
||||
|
||||
//Now we make our scripted definition "real", and append it to our asset
|
||||
//so it is serialized.
|
||||
/*%objectDefinition = "";
|
||||
%objectDefinition = "";
|
||||
for(%l=0; %l < %fileObject.count(); %l++)
|
||||
{
|
||||
%objectLine = %fileObject.getKey(%l);
|
||||
|
|
@ -932,8 +935,14 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %obje
|
|||
|
||||
if(isObject(%objectName))
|
||||
{
|
||||
//if we created it successfully, set up inheritance for serialization if needed
|
||||
if(%fileObject.parentName !$= "")
|
||||
{
|
||||
%objectName.setFieldValue("inheritFrom",%fileObject.parentName);
|
||||
}
|
||||
|
||||
%asset.add(%objectName);
|
||||
}*/
|
||||
}
|
||||
|
||||
if(!isDirectory(%assetPath))
|
||||
{
|
||||
|
|
@ -943,26 +952,6 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %obje
|
|||
%success = false;
|
||||
if(TamlWrite(%asset, %tamlpath))
|
||||
{
|
||||
//now write the script file
|
||||
if ( $ProjectImporter::fileObject.openForWrite( %scriptPath ) )
|
||||
{
|
||||
for(%i=0; %i < %fileObject.count(); %i++)
|
||||
{
|
||||
%objectLine = %fileObject.getKey(%i);
|
||||
if(isObject(%objectLine))
|
||||
{
|
||||
%defineLine = %fileObject.getKey(0);
|
||||
$ProjectImporter::fileObject.writeLine(%defineLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ProjectImporter::fileObject.writeLine(%objectLine);
|
||||
}
|
||||
}
|
||||
|
||||
$ProjectImporter::fileObject.close();
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
|
||||
%success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
|
@ -971,6 +960,43 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %obje
|
|||
if(!%success)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//process an existing material asset, if needbe
|
||||
%assetDef = AssetDatabase.acquireAsset(%matAsset);
|
||||
|
||||
%assetScriptPath = %assetDef.getScriptPath();
|
||||
|
||||
if(isFile(%assetScriptPath) && isObject(%objectName))
|
||||
{
|
||||
//Regular material in a companion file, so we'll want to write it to the
|
||||
//asset def file instead of the loose file
|
||||
%assetDef.scriptFile = ""; //clear the old script path reference
|
||||
%assetDef.add(%objectName); //child the definition to the asset def
|
||||
|
||||
if(%fileObject.parentName !$= "")
|
||||
{
|
||||
%objectName.setFieldValue("inheritFrom",%fileObject.parentName);
|
||||
}
|
||||
|
||||
if(%assetDef.saveAsset())
|
||||
{
|
||||
%fileObject.processed = true;
|
||||
%fileObject.skip = true; //don't write the def back out to script, it's not needed now
|
||||
|
||||
%assetFileObj = findFileInImporting(makeFullPath(AssetDatabase.getAssetFilePath(%matAsset)));
|
||||
|
||||
echo(%assetFileObj.fileDestination);
|
||||
%assetFileObj.processed = true;
|
||||
%assetFileObj.skip = true; //this asset definition has been processed
|
||||
//so nothing else need be done
|
||||
}
|
||||
else
|
||||
{
|
||||
projectImporterLog("T3Dpre4ProjectImporter::processMaterialObject() - failed to save out modified material asset for: " @ %matAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1017,9 +1043,36 @@ function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %fileObject
|
|||
versionId = 1;
|
||||
shaderData = "";
|
||||
materialDefinitionName = %objectName;
|
||||
scriptFile = fileName(%scriptPath);
|
||||
};
|
||||
|
||||
//Now we make our scripted definition "real", and append it to our asset
|
||||
//so it is serialized.
|
||||
%objectDefinition = "";
|
||||
for(%l=0; %l < %fileObject.count(); %l++)
|
||||
{
|
||||
%objectLine = %fileObject.getKey(%l);
|
||||
if(!isObject(%objectLine))
|
||||
{
|
||||
%objectDefinition = %objectDefinition @ %objectLine;
|
||||
}
|
||||
}
|
||||
|
||||
//Shift to object name, internal name will be used for assetID store
|
||||
%objectDefinition.name = findObjectField(%fileObject, "internalName");
|
||||
|
||||
eval(%objectDefinition);
|
||||
|
||||
if(isObject(%objectName))
|
||||
{
|
||||
//if we created it successfully, set up inheritance for serialization if needed
|
||||
if(%fileObject.parentName !$= "")
|
||||
{
|
||||
%objectName.setFieldValue("inheritFrom",%fileObject.parentName);
|
||||
}
|
||||
|
||||
%asset.add(%objectName);
|
||||
}
|
||||
|
||||
%success = false;
|
||||
if(TamlWrite(%asset, %tamlpath))
|
||||
{
|
||||
|
|
@ -1031,6 +1084,43 @@ function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %fileObject
|
|||
if(!%success)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//process an existing material asset, if needbe
|
||||
%assetDef = AssetDatabase.acquireAsset(%matAsset);
|
||||
|
||||
%assetScriptPath = %assetDef.getScriptPath();
|
||||
|
||||
if(isFile(%assetScriptPath) && isObject(%objectName))
|
||||
{
|
||||
//Regular material in a companion file, so we'll want to write it to the
|
||||
//asset def file instead of the loose file
|
||||
%assetDef.scriptFile = ""; //clear the old script path reference
|
||||
%assetDef.add(%objectName); //child the definition to the asset def
|
||||
|
||||
if(%fileObject.parentName !$= "")
|
||||
{
|
||||
%objectName.setFieldValue("inheritFrom",%fileObject.parentName);
|
||||
}
|
||||
|
||||
if(%assetDef.saveAsset())
|
||||
{
|
||||
%fileObject.processed = true;
|
||||
%fileObject.skip = true; //don't write the def back out to script, it's not needed now
|
||||
|
||||
%assetFileObj = findFileInImporting(makeFullPath(AssetDatabase.getAssetFilePath(%matAsset)));
|
||||
|
||||
echo(%assetFileObj.fileDestination);
|
||||
%assetFileObj.processed = true;
|
||||
%assetFileObj.skip = true; //this asset definition has been processed
|
||||
//so nothing else need be done
|
||||
}
|
||||
else
|
||||
{
|
||||
projectImporterLog("T3Dpre4ProjectImporter::processTerrainMaterialObject() - failed to save out modified material asset for: " @ %matAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1122,25 +1212,12 @@ function T3Dpre4ProjectImporter::processSFXProfileObject(%this, %file, %objectNa
|
|||
}
|
||||
else
|
||||
{
|
||||
%objFileFinder = "";
|
||||
//first check our cache
|
||||
if(isObject($ProjectImporter::SFXDescriptionCache) &&
|
||||
$ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName) !$= "")
|
||||
{
|
||||
%key = $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName);
|
||||
%objFileFinder = $ProjectImporter::SFXDescriptionCache.getValue(%key);
|
||||
}
|
||||
else
|
||||
{
|
||||
%objFileFinder = findObjectInFiles(%descriptionName);
|
||||
}
|
||||
%fileObj = findObjectInFiles(%descriptionName);
|
||||
|
||||
if(%objFileFinder !$= "")
|
||||
if(%fileObj !$= "")
|
||||
{
|
||||
%valueArray = new ArrayObject();
|
||||
|
||||
%fileObj = getField(%objFileFinder, 0);
|
||||
|
||||
%valueArray.add("sourceGroup" SPC findObjectField(%fileObj, "sourceGroup"));
|
||||
%valueArray.add("volume" SPC findObjectField(%fileObj, "volume"));
|
||||
%valueArray.add("pitch" SPC findObjectField(%fileObj, "pitch"));
|
||||
|
|
@ -1157,10 +1234,7 @@ function T3Dpre4ProjectImporter::processSFXProfileObject(%this, %file, %objectNa
|
|||
%valueArray.add("rolloffFactor" SPC findObjectField(%fileObj, "rolloffFactor"));
|
||||
%valueArray.add("isStreaming" SPC findObjectField(%fileObj, "isStreaming"));
|
||||
|
||||
if(isObject($ProjectImporter::SFXDescriptionCache))
|
||||
{
|
||||
$ProjectImporter::SFXDescriptionCache.add(%descriptionName, %objFileFinder);
|
||||
}
|
||||
%fileObj.skip = true;
|
||||
|
||||
for(%v=0; %v < %valueArray.Count(); %v++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ function ProjectImportWizardPage3::openPage(%this)
|
|||
%dataFullPath = makeFullPath("data/");
|
||||
%coreFullPath = makeFullPath("core/");
|
||||
%toolsFullPath = makeFullPath("tools/");
|
||||
if(startsWith(makeFullPath("data/"), $ProjectImporter::sourceContentFolder))
|
||||
if(startsWith($ProjectImporter::sourceContentFolder, makeFullPath("data/")))
|
||||
{
|
||||
%moduleDef = AssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath($ProjectImporter::sourceContentFolder));
|
||||
if(isObject(%moduleDef))
|
||||
|
|
@ -254,8 +254,8 @@ function ProjectImportWizardPage3::openPage(%this)
|
|||
ProjectImportWindow.setStep(4);
|
||||
}
|
||||
}
|
||||
else if(startsWith(makeFullPath("core/"), $ProjectImporter::sourceContentFolder) ||
|
||||
startsWith(makeFullPath("tools/"), $ProjectImporter::sourceContentFolder))
|
||||
else if(startsWith($ProjectImporter::sourceContentFolder, makeFullPath("core/")) ||
|
||||
startsWith($ProjectImporter::sourceContentFolder, makeFullPath("tools/")))
|
||||
{
|
||||
ProjectImportWindow.setStep(5);
|
||||
}
|
||||
|
|
@ -490,9 +490,11 @@ function preprocessImportingFiles()
|
|||
|
||||
%objectName = getSubStr(%line, %end+1, %nameEnd-%end-1);
|
||||
|
||||
%parentName = "";
|
||||
%inheritanceSplit = strpos(%objectName, ":");
|
||||
if(%inheritanceSplit != -1)
|
||||
{
|
||||
%parentName = getSubStr(%objectName, %inheritanceSplit + 1);
|
||||
%objectName = getSubStr(%objectName, 0, %inheritanceSplit);
|
||||
}
|
||||
|
||||
|
|
@ -502,6 +504,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.elementType = "object";
|
||||
%currentFileSectionObject.classType = %className;
|
||||
%currentFileSectionObject.objectName = %objectName;
|
||||
%currentFileSectionObject.parentName = %parentName;
|
||||
%currentFileSectionObject.fileName = %file;
|
||||
%currentFileSectionObject.skip = false;
|
||||
%currentFileSectionObject.fileDestination = %rootFileSectionObject.fileDestination;
|
||||
|
|
@ -510,6 +513,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.add(%line);
|
||||
|
||||
%parentFileSectionObject.add(%currentFileSectionObject);
|
||||
%currentFileSectionObject.parentElement = %parentFileSectionObject;
|
||||
|
||||
//Now for a sanity check, see if we kill the object on the same line as we make it
|
||||
//sometimes people try and be 'efficient' with their code linecount wise
|
||||
|
|
@ -540,9 +544,11 @@ function preprocessImportingFiles()
|
|||
|
||||
%objectName = getSubStr(%line, %end+1, %nameEnd-%end-1);
|
||||
|
||||
%parentName = "";
|
||||
%inheritanceSplit = strpos(%objectName, ":");
|
||||
if(%inheritanceSplit != -1)
|
||||
{
|
||||
%parentName = getSubStr(%objectName, %inheritanceSplit + 1);
|
||||
%objectName = getSubStr(%objectName, 0, %inheritanceSplit);
|
||||
}
|
||||
|
||||
|
|
@ -552,6 +558,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.elementType = "object";
|
||||
%currentFileSectionObject.classType = %className;
|
||||
%currentFileSectionObject.objectName = %objectName;
|
||||
%currentFileSectionObject.parentName = %parentName;
|
||||
%currentFileSectionObject.fileName = %file;
|
||||
%currentFileSectionObject.skip = false;
|
||||
%currentFileSectionObject.fileDestination = %rootFileSectionObject.fileDestination;
|
||||
|
|
@ -560,6 +567,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.add(%line);
|
||||
|
||||
%parentFileSectionObject.add(%currentFileSectionObject);
|
||||
%currentFileSectionObject.parentElement = %parentFileSectionObject;
|
||||
|
||||
//Now for a sanity check, see if we kill the object on the same line as we make it
|
||||
//sometimes people try and be 'efficient' with their code linecount wise
|
||||
|
|
@ -590,9 +598,11 @@ function preprocessImportingFiles()
|
|||
|
||||
%objectName = getSubStr(%line, %end+1, %nameEnd-%end-1);
|
||||
|
||||
%parentName = "";
|
||||
%inheritanceSplit = strpos(%objectName, ":");
|
||||
if(%inheritanceSplit != -1)
|
||||
{
|
||||
%parentName = getSubStr(%objectName, %inheritanceSplit + 1);
|
||||
%objectName = getSubStr(%objectName, 0, %inheritanceSplit);
|
||||
}
|
||||
|
||||
|
|
@ -602,6 +612,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.elementType = "object";
|
||||
%currentFileSectionObject.classType = %className;
|
||||
%currentFileSectionObject.objectName = %objectName;
|
||||
%currentFileSectionObject.parentName = %parentName;
|
||||
%currentFileSectionObject.fileName = %file;
|
||||
%currentFileSectionObject.skip = false;
|
||||
%currentFileSectionObject.fileDestination = %rootFileSectionObject.fileDestination;
|
||||
|
|
@ -610,6 +621,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.add(%line);
|
||||
|
||||
%parentFileSectionObject.add(%currentFileSectionObject);
|
||||
%currentFileSectionObject.parentElement = %parentFileSectionObject;
|
||||
|
||||
//Now for a sanity check, see if we kill the object on the same line as we make it
|
||||
//sometimes people try and be 'efficient' with their code linecount wise
|
||||
|
|
@ -650,6 +662,7 @@ function preprocessImportingFiles()
|
|||
%currentFileSectionObject.add(%line);
|
||||
|
||||
%parentFileSectionObject.add(%currentFileSectionObject);
|
||||
%currentFileSectionObject.parentElement = %parentFileSectionObject;
|
||||
|
||||
if(strIsMatchExpr("*{*", %line))
|
||||
{
|
||||
|
|
@ -838,6 +851,48 @@ function isImportingFile(%checkFile)
|
|||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Returns the file object of the file in question is part of our pre-scanned list of importing files
|
||||
//==============================================================================
|
||||
function findFileInImporting(%checkFile)
|
||||
{
|
||||
for(%i=0; %i < $ProjectImporter::FileList.count(); %i++)
|
||||
{
|
||||
%file = $ProjectImporter::FileList.getKey(%i);
|
||||
|
||||
if(%file $= %checkFile)
|
||||
return $ProjectImporter::FileList.getValue(%i);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Checks if the object in question is defined in any of our pre-scanned list of importing files
|
||||
//==============================================================================
|
||||
function findObjectInFiles(%objectName, %arrayObj)
|
||||
{
|
||||
if(%arrayObj $= "")
|
||||
%arrayObj = $ProjectImporter::FileList;
|
||||
|
||||
for(%i=0; %i < %arrayObj.count(); %i++)
|
||||
{
|
||||
%objectLine = %arrayObj.getKey(%i);
|
||||
if(isObject(%objectLine))
|
||||
{
|
||||
if(%objectLine.objectName $= %objectName)
|
||||
return %objectLine;
|
||||
|
||||
//If this object isn't it, try recursing any children
|
||||
%result = findObjectInFiles(%objectName, %objectLine);
|
||||
if(%result !$= "")
|
||||
return %result;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Takes a filename lacking an extension and then checks common file extensions
|
||||
// to see if we can find the actual file in question
|
||||
|
|
@ -1215,6 +1270,32 @@ function projectImporterLog(%line)
|
|||
$ProjectImporter::log.add(%line);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Traverses the object delcaration stack backwards to find the root file object
|
||||
//==============================================================================
|
||||
function getParentFileObjectFromObject(%object)
|
||||
{
|
||||
while(%object.parentElement !$= "")
|
||||
{
|
||||
%object = %object.parentElement;
|
||||
}
|
||||
|
||||
return %object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Traverses the object delcaration stack backwards to find the root file object
|
||||
//==============================================================================
|
||||
function getParentFileObjectFromObject(%object)
|
||||
{
|
||||
while(%object.parentElement !$= "")
|
||||
{
|
||||
%object = %object.parentElement;
|
||||
}
|
||||
|
||||
return %object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//Shape Importing
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -77,9 +77,6 @@ function TerrainMaterialDlg::showByObjectId( %this, %matObjectId, %onApplyCallba
|
|||
|
||||
function TerrainMaterialDlg::onWake( %this )
|
||||
{
|
||||
if( !isObject( ETerrainMaterialPersistMan ) )
|
||||
new PersistenceManager( ETerrainMaterialPersistMan );
|
||||
|
||||
if( !isObject( TerrainMaterialDlgNewGroup ) )
|
||||
new SimGroup( TerrainMaterialDlgNewGroup );
|
||||
if( !isObject( TerrainMaterialDlgDeleteGroup ) )
|
||||
|
|
@ -156,9 +153,6 @@ function TerrainMaterialDlg::dialogApply( %this )
|
|||
// Make sure we save any changes to the current selection.
|
||||
%this.saveDirtyMaterial( %this.activeMat );
|
||||
|
||||
// Save all changes.
|
||||
ETerrainMaterialPersistMan.saveDirty();
|
||||
|
||||
// Delete the snapshot.
|
||||
TerrainMaterialDlgSnapshot.delete();
|
||||
|
||||
|
|
@ -191,10 +185,6 @@ function TerrainMaterialDlg::closeDialog( %this )
|
|||
|
||||
%this.restoreMaterials();
|
||||
|
||||
// Clear the persistence manager state.
|
||||
|
||||
ETerrainMaterialPersistMan.clearAll();
|
||||
|
||||
// Delete all new object we have created.
|
||||
|
||||
TerrainMaterialDlgNewGroup.clear();
|
||||
|
|
@ -599,17 +589,9 @@ function TerrainMaterialDlg::saveDirtyMaterial( %this, %mat )
|
|||
%mat.isSRGB = %isSRGB;
|
||||
%mat.invertRoughness = %invertRoughness;
|
||||
|
||||
// Mark the material as dirty and needing saving.
|
||||
|
||||
%fileName = %mat.getFileName();
|
||||
if( %fileName $= "" )
|
||||
{
|
||||
error("TerrainMaterialDlg::saveDirtyMaterial() - terrain material doesn't have a fileName set to save to.");
|
||||
return;
|
||||
//%fileName = "data/terrains/materials." @ $TorqueScriptFileExtension;
|
||||
}
|
||||
|
||||
ETerrainMaterialPersistMan.setDirty( %mat, %fileName );
|
||||
//Save the material asset
|
||||
%assetDef = AssetDatabase.acquireAsset(%mat.internalName);
|
||||
%assetDef.saveAsset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue