mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +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();
|
mFileName = StringTable->EmptyString();
|
||||||
mConstructorFileName = 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);
|
ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
|
||||||
|
|
||||||
//Ensure our path is expando'd if it isn't already
|
//Ensure our path is expando'd if it isn't already
|
||||||
if (!Platform::isFullPath(mFileName))
|
if (!Platform::isFullPath(mFilePath))
|
||||||
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
|
mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
|
||||||
|
|
||||||
mConstructorFileName = expandAssetFilePath(mConstructorFileName);
|
mConstructorFilePath = expandAssetFilePath(mConstructorFilePath);
|
||||||
|
|
||||||
loadShape();
|
loadShape();
|
||||||
}
|
}
|
||||||
|
|
@ -258,7 +260,7 @@ bool ShapeAsset::loadShape()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mShape = ResourceManager::get().load(mFileName);
|
mShape = ResourceManager::get().load(mFilePath);
|
||||||
|
|
||||||
if (!mShape)
|
if (!mShape)
|
||||||
{
|
{
|
||||||
|
|
@ -439,7 +441,7 @@ void ShapeAsset::onAssetRefresh(void)
|
||||||
|
|
||||||
// Update.
|
// Update.
|
||||||
if(!Platform::isFullPath(mFileName))
|
if(!Platform::isFullPath(mFileName))
|
||||||
mFileName = getOwned() ? expandAssetFilePath(mFileName) : mFileName;
|
mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
|
||||||
|
|
||||||
loadShape();
|
loadShape();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ class ShapeAsset : public AssetBase
|
||||||
protected:
|
protected:
|
||||||
StringTableEntry mFileName;
|
StringTableEntry mFileName;
|
||||||
StringTableEntry mConstructorFileName;
|
StringTableEntry mConstructorFileName;
|
||||||
|
StringTableEntry mFilePath;
|
||||||
|
StringTableEntry mConstructorFilePath;
|
||||||
Resource<TSShape> mShape;
|
Resource<TSShape> mShape;
|
||||||
|
|
||||||
//Material assets we're dependent on and use
|
//Material assets we're dependent on and use
|
||||||
|
|
@ -96,9 +98,9 @@ public:
|
||||||
Resource<TSShape> getShapeResource() { return mShape; }
|
Resource<TSShape> getShapeResource() { return mShape; }
|
||||||
|
|
||||||
void SplitSequencePathAndName(String& srcPath, String& srcName);
|
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; }
|
Vector<AssetPtr<MaterialAsset>> getMaterialAssets() { return mMaterialAssets; }
|
||||||
|
|
||||||
|
|
@ -128,6 +130,9 @@ public:
|
||||||
void setShapeConstructorFile(const char* pScriptFile);
|
void setShapeConstructorFile(const char* pScriptFile);
|
||||||
inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; };
|
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 bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
||||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||||
static bool getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
static bool getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
||||||
|
|
|
||||||
|
|
@ -1833,6 +1833,9 @@ void AssetImporter::resolveAssetItemIssues(AssetImportObject* assetItem)
|
||||||
//
|
//
|
||||||
StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath)
|
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);
|
String assetType = getAssetTypeByFile(filePath);
|
||||||
|
|
||||||
if (assetType == String("Folder") || assetType == String("Zip"))
|
if (assetType == String("Folder") || assetType == String("Zip"))
|
||||||
|
|
@ -1902,10 +1905,12 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TORQUE_DEBUG
|
#if TORQUE_DEBUG
|
||||||
|
Con::printf("/***************/");
|
||||||
for (U32 i = 0; i < activityLog.size(); i++)
|
for (U32 i = 0; i < activityLog.size(); i++)
|
||||||
{
|
{
|
||||||
Con::printf(activityLog[i].c_str());
|
Con::printf(activityLog[i].c_str());
|
||||||
}
|
}
|
||||||
|
Con::printf("/***************/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (hasIssues)
|
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());
|
dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Import attempt of %s failed, so skipping asset.", childItem->assetName.c_str());
|
||||||
activityLog.push_back(importLogBuffer);
|
activityLog.push_back(importLogBuffer);
|
||||||
|
|
|
||||||
|
|
@ -3668,7 +3668,7 @@ DefineEngineMethod( WorldEditor, colladaExportSelection, void, ( const char* pat
|
||||||
object->colladaExportSelection( path );
|
object->colladaExportSelection( path );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditor::makeSelectionPrefab( const char *filename )
|
void WorldEditor::makeSelectionPrefab( const char *filename, bool dontReplaceOriginals )
|
||||||
{
|
{
|
||||||
if ( mSelected->size() == 0 )
|
if ( mSelected->size() == 0 )
|
||||||
{
|
{
|
||||||
|
|
@ -3761,25 +3761,28 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save out .prefab file.
|
// Save out .prefab file.
|
||||||
group->save( filename, false, "$ThisPrefab = " );
|
group->save( filename, false, "$ThisPrefab = " );
|
||||||
|
|
||||||
// Allocate Prefab object and add to level.
|
if (!dontReplaceOriginals)
|
||||||
Prefab *fab = new Prefab();
|
{
|
||||||
fab->setFile( filename );
|
// Allocate Prefab object and add to level.
|
||||||
fabMat.inverse();
|
Prefab* fab = new Prefab();
|
||||||
fab->setTransform( fabMat );
|
fab->setFile(filename);
|
||||||
fab->registerObject();
|
fabMat.inverse();
|
||||||
scene->addObject( fab );
|
fab->setTransform(fabMat);
|
||||||
|
fab->registerObject();
|
||||||
|
scene->addObject(fab);
|
||||||
|
|
||||||
// Select it, mark level as dirty.
|
// Select it, mark level as dirty.
|
||||||
clearSelection();
|
clearSelection();
|
||||||
selectObject( fab );
|
selectObject(fab);
|
||||||
setDirty();
|
setDirty();
|
||||||
|
|
||||||
// Delete original objects and temporary SimGroup.
|
// Delete original objects and temporary SimGroup.
|
||||||
group->deleteObject();
|
group->deleteObject();
|
||||||
for ( S32 i = 0; i < cleanup.size(); i++ )
|
for (S32 i = 0; i < cleanup.size(); i++)
|
||||||
cleanup[i]->deleteObject();
|
cleanup[i]->deleteObject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditor::explodeSelectedPrefab()
|
void WorldEditor::explodeSelectedPrefab()
|
||||||
|
|
@ -3827,19 +3830,19 @@ void WorldEditor::explodeSelectedPrefab()
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditor::makeSelectionAMesh(const char *filename)
|
bool WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
{
|
{
|
||||||
if (mSelected->size() == 0)
|
if (mSelected->size() == 0)
|
||||||
{
|
{
|
||||||
Con::errorf("WorldEditor::makeSelectionAMesh - Nothing selected.");
|
Con::errorf("WorldEditor::makeSelectionAMesh - Nothing selected.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene* scene = Scene::getRootScene();
|
Scene* scene = Scene::getRootScene();
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene.");
|
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector< SimObject* > stack;
|
Vector< SimObject* > stack;
|
||||||
|
|
@ -3887,7 +3890,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
if (found.empty())
|
if (found.empty())
|
||||||
{
|
{
|
||||||
Con::warnf("WorldEditor::makeSelectionPrefab - No valid objects selected.");
|
Con::warnf("WorldEditor::makeSelectionPrefab - No valid objects selected.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimGroup we collect prefab objects into.
|
// SimGroup we collect prefab objects into.
|
||||||
|
|
@ -3911,7 +3914,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( objectList.empty() )
|
if ( objectList.empty() )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
//
|
//
|
||||||
Point3F centroid;
|
Point3F centroid;
|
||||||
|
|
@ -3982,6 +3985,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
ColladaUtils::exportToCollada(filename, exportData);
|
ColladaUtils::exportToCollada(filename, exportData);
|
||||||
//
|
//
|
||||||
|
|
||||||
|
if (Platform::isFile(filename))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
// Allocate TSStatic object and add to level.
|
// Allocate TSStatic object and add to level.
|
||||||
TSStatic *ts = new TSStatic();
|
TSStatic *ts = new TSStatic();
|
||||||
ts->setShapeFileName(StringTable->insert(filename));
|
ts->setShapeFileName(StringTable->insert(filename));
|
||||||
|
|
@ -4000,11 +4008,11 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
||||||
objectList[i]->deleteObject();
|
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."
|
"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.")
|
"@param filename Prefab file to save the selected objects to.")
|
||||||
{
|
{
|
||||||
object->makeSelectionPrefab( filename );
|
object->makeSelectionPrefab( filename, dontDeleteOriginals);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),,
|
DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),,
|
||||||
|
|
@ -4013,11 +4021,11 @@ DefineEngineMethod( WorldEditor, explodeSelectedPrefab, void, (),,
|
||||||
object->explodeSelectedPrefab();
|
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."
|
"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.")
|
"@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 ),,
|
DefineEngineMethod( WorldEditor, mountRelative, void, ( SceneObject *objA, SceneObject *objB ),,
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,10 @@ class WorldEditor : public EditTSCtrl
|
||||||
|
|
||||||
void colladaExportSelection( const String &path );
|
void colladaExportSelection( const String &path );
|
||||||
|
|
||||||
void makeSelectionPrefab( const char *filename );
|
void makeSelectionPrefab( const char *filename, bool dontReplaceOriginals = false);
|
||||||
void explodeSelectedPrefab();
|
void explodeSelectedPrefab();
|
||||||
|
|
||||||
void makeSelectionAMesh(const char *filename);
|
bool makeSelectionAMesh(const char *filename);
|
||||||
|
|
||||||
//
|
//
|
||||||
static SceneObject* getClientObj(SceneObject *);
|
static SceneObject* getClientObj(SceneObject *);
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@
|
||||||
};
|
};
|
||||||
new GuiIconButtonCtrl() {
|
new GuiIconButtonCtrl() {
|
||||||
buttonMargin = "4 4";
|
buttonMargin = "4 4";
|
||||||
iconBitmap = "tools/gui/images/stencilIcons/return.png";
|
iconBitmap = "tools/gui/images/stencilIcons/gear.png";
|
||||||
iconLocation = "Left";
|
iconLocation = "Left";
|
||||||
sizeIconToButton = "1";
|
sizeIconToButton = "1";
|
||||||
makeIconSquare = "1";
|
makeIconSquare = "1";
|
||||||
|
|
@ -328,12 +328,12 @@
|
||||||
profile = "ToolsGuiDefaultProfile";
|
profile = "ToolsGuiDefaultProfile";
|
||||||
visible = "1";
|
visible = "1";
|
||||||
active = "1";
|
active = "1";
|
||||||
command = "AssetBrowser.refreshDatabases();";
|
command = "AssetBrowser.openAssetSettings();";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
tooltip = "Refresh Asset and Module databases.";
|
tooltip = "Edit the editor settings for Assets.";
|
||||||
hovertime = "1000";
|
hovertime = "1000";
|
||||||
isContainer = "0";
|
isContainer = "0";
|
||||||
internalName = "refreshDatabasesButton";
|
internalName = "editAssetSettingsButton";
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "0";
|
canSaveDynamicFields = "0";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1218,11 +1218,11 @@ function AssetBrowserFilterTree::onRightMouseDown(%this, %itemId)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
function AssetBrowser::refreshDatabases(%this)
|
function AssetBrowser::openAssetSettings(%this)
|
||||||
{
|
{
|
||||||
//ModuleDatabase.scanModules( "data", false );
|
ESettingsWindow.toggleEditorSettings();
|
||||||
//ModuleDatabase.unloadGroup( "Game" );
|
%assetEditIndex = ESettingsWindowList.findTextIndex("Asset Editing");
|
||||||
//ModuleDatabase.LoadGroup( "Game" );
|
ESettingsWindowList.setSelectedRow( %assetEditIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
function AssetBrowser::showVisibiltyOptions(%this)
|
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="dividerDarkColor">17 16 15 255</Setting>
|
||||||
<Setting name="fieldBGColor">59 58 57 255</Setting>
|
<Setting name="fieldBGColor">59 58 57 255</Setting>
|
||||||
<Setting name="tabsHLColor">50 49 48 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="tooltipBGColor">43 43 43 255</Setting>
|
||||||
<Setting name="tooltipDividerColor">72 70 68 255</Setting>
|
<Setting name="tooltipDividerColor">72 70 68 255</Setting>
|
||||||
<Setting name="fieldTextColor">178 175 172 255</Setting>
|
<Setting name="fieldTextColor">178 175 172 255</Setting>
|
||||||
|
|
|
||||||
|
|
@ -573,10 +573,10 @@ function EditorExplodePrefab()
|
||||||
EditorTree.buildVisibleTree( true );
|
EditorTree.buildVisibleTree( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeSelectedAMesh()
|
function makeSelectedAMesh(%assetId)
|
||||||
{
|
{
|
||||||
|
|
||||||
%dlg = new SaveFileDialog()
|
/*%dlg = new SaveFileDialog()
|
||||||
{
|
{
|
||||||
Filters = "Collada file (*.dae)|*.dae|";
|
Filters = "Collada file (*.dae)|*.dae|";
|
||||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||||
|
|
@ -598,9 +598,45 @@ function makeSelectedAMesh()
|
||||||
%dlg.delete();
|
%dlg.delete();
|
||||||
|
|
||||||
if ( !%ret )
|
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 );
|
EditorTree.buildVisibleTree( true );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue