mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 07:20:40 +00:00
Merge pull request #274 from Areloch/MiscAssetImportAndWorkflowFixes
Various fixes for both asset importing and some workflowy bits relating to assets stuffs
This commit is contained in:
commit
4278d8ad5a
10 changed files with 106 additions and 50 deletions
|
|
@ -117,6 +117,8 @@ ShapeAsset::ShapeAsset()
|
|||
{
|
||||
mFileName = StringTable->EmptyString();
|
||||
mConstructorFileName = StringTable->EmptyString();
|
||||
mFilePath = StringTable->EmptyString();
|
||||
mConstructorFilePath = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -163,10 +165,10 @@ void ShapeAsset::initializeAsset()
|
|||
ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
|
||||
|
||||
//Ensure our path is expando'd if it isn't already
|
||||
if (!Platform::isFullPath(mFileName))
|
||||
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
|
||||
if (!Platform::isFullPath(mFilePath))
|
||||
mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
|
||||
|
||||
mConstructorFileName = expandAssetFilePath(mConstructorFileName);
|
||||
mConstructorFilePath = expandAssetFilePath(mConstructorFilePath);
|
||||
|
||||
loadShape();
|
||||
}
|
||||
|
|
@ -258,7 +260,7 @@ bool ShapeAsset::loadShape()
|
|||
}
|
||||
}
|
||||
|
||||
mShape = ResourceManager::get().load(mFileName);
|
||||
mShape = ResourceManager::get().load(mFilePath);
|
||||
|
||||
if (!mShape)
|
||||
{
|
||||
|
|
@ -439,7 +441,7 @@ void ShapeAsset::onAssetRefresh(void)
|
|||
|
||||
// Update.
|
||||
if(!Platform::isFullPath(mFileName))
|
||||
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
|
||||
mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
|
||||
|
||||
loadShape();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ class ShapeAsset : public AssetBase
|
|||
protected:
|
||||
StringTableEntry mFileName;
|
||||
StringTableEntry mConstructorFileName;
|
||||
StringTableEntry mFilePath;
|
||||
StringTableEntry mConstructorFilePath;
|
||||
Resource<TSShape> mShape;
|
||||
|
||||
//Material assets we're dependent on and use
|
||||
|
|
@ -96,9 +98,9 @@ public:
|
|||
Resource<TSShape> getShapeResource() { return mShape; }
|
||||
|
||||
void SplitSequencePathAndName(String& srcPath, String& srcName);
|
||||
StringTableEntry getShapeFilename() { return mFileName; }
|
||||
StringTableEntry getShapeFilename() { return mFilePath; }
|
||||
|
||||
U32 getShapeFilenameHash() { return _StringTable::hashString(mFileName); }
|
||||
U32 getShapeFilenameHash() { return _StringTable::hashString(mFilePath); }
|
||||
|
||||
Vector<AssetPtr<MaterialAsset>> getMaterialAssets() { return mMaterialAssets; }
|
||||
|
||||
|
|
@ -128,6 +130,9 @@ public:
|
|||
void setShapeConstructorFile(const char* pScriptFile);
|
||||
inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; };
|
||||
|
||||
inline StringTableEntry getShapeFilePath(void) const { return mFilePath; };
|
||||
inline StringTableEntry getShapeConstructorFilePath(void) const { return mConstructorFilePath; };
|
||||
|
||||
static bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||
static bool getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
|
|
|
|||
|
|
@ -1833,6 +1833,9 @@ void AssetImporter::resolveAssetItemIssues(AssetImportObject* assetItem)
|
|||
//
|
||||
StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath)
|
||||
{
|
||||
//Just in case we're reusing the same importer object from another import session, nuke any existing files
|
||||
resetImportSession(true);
|
||||
|
||||
String assetType = getAssetTypeByFile(filePath);
|
||||
|
||||
if (assetType == String("Folder") || assetType == String("Zip"))
|
||||
|
|
@ -1902,10 +1905,12 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath)
|
|||
}
|
||||
|
||||
#if TORQUE_DEBUG
|
||||
Con::printf("/***************/");
|
||||
for (U32 i = 0; i < activityLog.size(); i++)
|
||||
{
|
||||
Con::printf(activityLog[i].c_str());
|
||||
}
|
||||
Con::printf("/***************/");
|
||||
#endif
|
||||
|
||||
if (hasIssues)
|
||||
|
|
@ -2045,7 +2050,7 @@ void AssetImporter::importAssets(AssetImportObject* assetItem)
|
|||
}
|
||||
}
|
||||
|
||||
if (assetPath.isEmpty() && importingAssets[i]->assetType != String("MaterialAsset"))
|
||||
if (assetPath.isEmpty() && childItem->assetType != String("MaterialAsset"))
|
||||
{
|
||||
dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Import attempt of %s failed, so skipping asset.", childItem->assetName.c_str());
|
||||
activityLog.push_back(importLogBuffer);
|
||||
|
|
|
|||
|
|
@ -3668,7 +3668,7 @@ DefineEngineMethod( WorldEditor, colladaExportSelection, void, ( const char* pat
|
|||
object->colladaExportSelection( path );
|
||||
}
|
||||
|
||||
void WorldEditor::makeSelectionPrefab( const char *filename )
|
||||
void WorldEditor::makeSelectionPrefab( const char *filename, bool dontReplaceOriginals )
|
||||
{
|
||||
if ( mSelected->size() == 0 )
|
||||
{
|
||||
|
|
@ -3761,25 +3761,28 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
|||
}
|
||||
|
||||
// Save out .prefab file.
|
||||
group->save( filename, false, "$ThisPrefab = " );
|
||||
group->save( filename, false, "$ThisPrefab = " );
|
||||
|
||||
// Allocate Prefab object and add to level.
|
||||
Prefab *fab = new Prefab();
|
||||
fab->setFile( filename );
|
||||
fabMat.inverse();
|
||||
fab->setTransform( fabMat );
|
||||
fab->registerObject();
|
||||
scene->addObject( fab );
|
||||
if (!dontReplaceOriginals)
|
||||
{
|
||||
// Allocate Prefab object and add to level.
|
||||
Prefab* fab = new Prefab();
|
||||
fab->setFile(filename);
|
||||
fabMat.inverse();
|
||||
fab->setTransform(fabMat);
|
||||
fab->registerObject();
|
||||
scene->addObject(fab);
|
||||
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
selectObject( fab );
|
||||
setDirty();
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
selectObject(fab);
|
||||
setDirty();
|
||||
|
||||
// Delete original objects and temporary SimGroup.
|
||||
group->deleteObject();
|
||||
for ( S32 i = 0; i < cleanup.size(); i++ )
|
||||
cleanup[i]->deleteObject();
|
||||
// Delete original objects and temporary SimGroup.
|
||||
group->deleteObject();
|
||||
for (S32 i = 0; i < cleanup.size(); i++)
|
||||
cleanup[i]->deleteObject();
|
||||
}
|
||||
}
|
||||
|
||||
void WorldEditor::explodeSelectedPrefab()
|
||||
|
|
@ -3827,19 +3830,19 @@ void WorldEditor::explodeSelectedPrefab()
|
|||
setDirty();
|
||||
}
|
||||
|
||||
void WorldEditor::makeSelectionAMesh(const char *filename)
|
||||
bool WorldEditor::makeSelectionAMesh(const char *filename)
|
||||
{
|
||||
if (mSelected->size() == 0)
|
||||
{
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Nothing selected.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (!scene)
|
||||
{
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector< SimObject* > stack;
|
||||
|
|
@ -3887,7 +3890,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
if (found.empty())
|
||||
{
|
||||
Con::warnf("WorldEditor::makeSelectionPrefab - No valid objects selected.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// SimGroup we collect prefab objects into.
|
||||
|
|
@ -3911,7 +3914,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
}
|
||||
|
||||
if ( objectList.empty() )
|
||||
return;
|
||||
return false;
|
||||
|
||||
//
|
||||
Point3F centroid;
|
||||
|
|
@ -3982,6 +3985,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
ColladaUtils::exportToCollada(filename, exportData);
|
||||
//
|
||||
|
||||
if (Platform::isFile(filename))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
// Allocate TSStatic object and add to level.
|
||||
TSStatic *ts = new TSStatic();
|
||||
ts->setShapeFileName(StringTable->insert(filename));
|
||||
|
|
@ -4000,11 +4008,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
objectList[i]->deleteObject();
|
||||
}
|
||||
|
||||
DefineEngineMethod( WorldEditor, makeSelectionPrefab, void, ( const char* filename ),,
|
||||
DefineEngineMethod( WorldEditor, makeSelectionPrefab, void, ( const char* filename, bool dontDeleteOriginals ), (false),
|
||||
"Save selected objects to a .prefab file and replace them in the level with a Prefab object."
|
||||
"@param filename Prefab file to save the selected objects to.")
|
||||
{
|
||||
object->makeSelectionPrefab( filename );
|
||||
object->makeSelectionPrefab( filename, dontDeleteOriginals);
|
||||
}
|
||||
|
||||
DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),,
|
||||
|
|
@ -4013,11 +4021,11 @@ DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),,
|
|||
object->explodeSelectedPrefab();
|
||||
}
|
||||
|
||||
DefineEngineMethod(WorldEditor, makeSelectionAMesh, void, (const char* filename), ,
|
||||
DefineEngineMethod(WorldEditor, makeSelectionAMesh, bool, (const char* filename), ,
|
||||
"Save selected objects to a .dae collada file and replace them in the level with a TSStatic object."
|
||||
"@param filename collada file to save the selected objects to.")
|
||||
{
|
||||
object->makeSelectionAMesh(filename);
|
||||
return object->makeSelectionAMesh(filename);
|
||||
}
|
||||
|
||||
DefineEngineMethod( WorldEditor, mountRelative, void, ( SceneObject *objA, SceneObject *objB ),,
|
||||
|
|
|
|||
|
|
@ -114,10 +114,10 @@ class WorldEditor : public EditTSCtrl
|
|||
|
||||
void colladaExportSelection( const String &path );
|
||||
|
||||
void makeSelectionPrefab( const char *filename );
|
||||
void makeSelectionPrefab( const char *filename, bool dontReplaceOriginals = false);
|
||||
void explodeSelectedPrefab();
|
||||
|
||||
void makeSelectionAMesh(const char *filename);
|
||||
bool makeSelectionAMesh(const char *filename);
|
||||
|
||||
//
|
||||
static SceneObject* getClientObj(SceneObject *);
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@
|
|||
};
|
||||
new GuiIconButtonCtrl() {
|
||||
buttonMargin = "4 4";
|
||||
iconBitmap = "tools/gui/images/stencilIcons/return.png";
|
||||
iconBitmap = "tools/gui/images/stencilIcons/gear.png";
|
||||
iconLocation = "Left";
|
||||
sizeIconToButton = "1";
|
||||
makeIconSquare = "1";
|
||||
|
|
@ -328,12 +328,12 @@
|
|||
profile = "ToolsGuiDefaultProfile";
|
||||
visible = "1";
|
||||
active = "1";
|
||||
command = "AssetBrowser.refreshDatabases();";
|
||||
command = "AssetBrowser.openAssetSettings();";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
tooltip = "Refresh Asset and Module databases.";
|
||||
tooltip = "Edit the editor settings for Assets.";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "refreshDatabasesButton";
|
||||
internalName = "editAssetSettingsButton";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1218,11 +1218,11 @@ function AssetBrowserFilterTree::onRightMouseDown(%this, %itemId)
|
|||
//
|
||||
//
|
||||
//
|
||||
function AssetBrowser::refreshDatabases(%this)
|
||||
function AssetBrowser::openAssetSettings(%this)
|
||||
{
|
||||
//ModuleDatabase.scanModules( "data", false );
|
||||
//ModuleDatabase.unloadGroup( "Game" );
|
||||
//ModuleDatabase.LoadGroup( "Game" );
|
||||
ESettingsWindow.toggleEditorSettings();
|
||||
%assetEditIndex = ESettingsWindowList.findTextIndex("Asset Editing");
|
||||
ESettingsWindowList.setSelectedRow( %assetEditIndex );
|
||||
}
|
||||
|
||||
function AssetBrowser::showVisibiltyOptions(%this)
|
||||
|
|
|
|||
BIN
Templates/BaseGame/game/tools/gui/images/stencilIcons/gear.png
Normal file
BIN
Templates/BaseGame/game/tools/gui/images/stencilIcons/gear.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
|
|
@ -246,7 +246,7 @@
|
|||
<Setting name="dividerDarkColor">17 16 15 255</Setting>
|
||||
<Setting name="fieldBGColor">59 58 57 255</Setting>
|
||||
<Setting name="tabsHLColor">50 49 48 255</Setting>
|
||||
<Setting name="fieldTextNAColor">77 77 77 255</Setting>
|
||||
<Setting name="fieldTextNAColor">120 120 120 255</Setting>
|
||||
<Setting name="tooltipBGColor">43 43 43 255</Setting>
|
||||
<Setting name="tooltipDividerColor">72 70 68 255</Setting>
|
||||
<Setting name="fieldTextColor">178 175 172 255</Setting>
|
||||
|
|
|
|||
|
|
@ -573,10 +573,10 @@ function EditorExplodePrefab()
|
|||
EditorTree.buildVisibleTree( true );
|
||||
}
|
||||
|
||||
function makeSelectedAMesh()
|
||||
function makeSelectedAMesh(%assetId)
|
||||
{
|
||||
|
||||
%dlg = new SaveFileDialog()
|
||||
|
||||
/*%dlg = new SaveFileDialog()
|
||||
{
|
||||
Filters = "Collada file (*.dae)|*.dae|";
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
|
|
@ -598,9 +598,45 @@ function makeSelectedAMesh()
|
|||
%dlg.delete();
|
||||
|
||||
if ( !%ret )
|
||||
return;
|
||||
return;*/
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
EWorldEditor.makeSelectionAMesh( %saveFile );
|
||||
%assetPath = AssetDatabase.getAssetPath(%assetId);
|
||||
%filePath = %assetPath @ "/" @ %assetDef.AssetName @ ".dae";
|
||||
|
||||
%fileName = fileName(%filePath);
|
||||
|
||||
%assetDef.fileName = %fileName;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
%success = EWorldEditor.makeSelectionAMesh( %filePath );
|
||||
|
||||
AssetDatabase.refreshAsset(%assetId);
|
||||
|
||||
if(%success)
|
||||
{
|
||||
//ok, cool it worked, so clear out the old
|
||||
//First, get our center of the currently selected objects
|
||||
%selectionCenter = EWorldEditor.getSelectionCentroid();
|
||||
|
||||
//Next, for safety purposes(and convenience!) we'll make them a prefab aping off the filepath/name provided
|
||||
//TODO: Make this an editor option
|
||||
%prefabPath = %assetPath @ "/" @ %assetDef.AssetName @ ".prefab";
|
||||
EWorldEditor.makeSelectionPrefab(%prefabPath, true);
|
||||
|
||||
//Next, nuke 'em
|
||||
EditorMenuEditDelete();
|
||||
|
||||
//now make a new static
|
||||
%newStatic = new TSStatic()
|
||||
{
|
||||
shapeAsset = %assetId;
|
||||
position = %selectionCenter;
|
||||
};
|
||||
|
||||
getRootScene().add(%newStatic);
|
||||
}
|
||||
|
||||
EditorTree.buildVisibleTree( true );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue