mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 21:40:31 +00:00
Updates the shape editor to support editing a shape via assetID, as well as adding support for shape animation assets being selected when adding a new animation sequence to a shape.
This commit is contained in:
parent
06e02c5582
commit
5f5b90794e
3 changed files with 63 additions and 15 deletions
|
|
@ -145,6 +145,13 @@ function ShapeEditorPlugin::onWorldEditorStartup(%this)
|
|||
}
|
||||
}
|
||||
|
||||
function ShapeEditorPlugin::openShapeAsset(%this, %assetId)
|
||||
{
|
||||
%this.selectedAssetId = %assetId;
|
||||
%this.selectedAssetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
%this.open(%this.selectedAssetDef.fileName);
|
||||
}
|
||||
|
||||
function ShapeEditorPlugin::open(%this, %filename)
|
||||
{
|
||||
if ( !%this.isActivated )
|
||||
|
|
|
|||
|
|
@ -611,6 +611,19 @@ function ShapeEdPropWindow::update_onShapeSelectionChanged( %this )
|
|||
ShapeEdSequenceList.addItem( %name );
|
||||
}
|
||||
ShapeEdThreadWindow.onAddThread(); // add thread 0
|
||||
|
||||
//Now, fetch any animation assets if we're utilizing a shape asset
|
||||
if(ShapeEditorPlugin.selectedAssetId !$= "")
|
||||
{
|
||||
%animationAssetCount = ShapeEditorPlugin.selectedAssetDef.getAnimationCount();
|
||||
|
||||
for(%animIdx = 0; %animIdx < %animationAssetCount; %animIdx++)
|
||||
{
|
||||
%animAsset = ShapeEditorPlugin.selectedAssetDef.getAnimation(%animIdx);
|
||||
|
||||
//ShapeEdSequenceList.addItem( %animAsset.assetName );
|
||||
}
|
||||
}
|
||||
|
||||
// --- DETAILS TAB ---
|
||||
// Add detail levels and meshes to tree
|
||||
|
|
@ -789,7 +802,8 @@ function ShapeEdSeqNodeTabBook::onTabSelected( %this, %name, %index )
|
|||
{
|
||||
case "Seq":
|
||||
ShapeEdPropWindow-->newBtn.ToolTip = "Add new sequence";
|
||||
ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();";
|
||||
//ShapeEdPropWindow-->newBtn.Command = "ShapeEdSequences.onAddSequence();";
|
||||
ShapeEdPropWindow-->newBtn.Command = "AssetBrowser.showDialog(\"ShapeAnimationAsset\", \"onAddAnimationAssetShapeEditor\", \"\", \"\", \"\");";
|
||||
ShapeEdPropWindow-->newBtn.setActive( true );
|
||||
ShapeEdPropWindow-->deleteBtn.ToolTip = "Delete selected sequence (cannot be undone)";
|
||||
ShapeEdPropWindow-->deleteBtn.Command = "ShapeEdSequences.onDeleteSequence();";
|
||||
|
|
|
|||
|
|
@ -299,6 +299,12 @@ function ActionEditNodeTransform::undo( %this )
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
// Add sequence
|
||||
function onAddAnimationAssetShapeEditor(%selectedAnimation)
|
||||
{
|
||||
echo("SELECTED MUH ASSET");
|
||||
ShapeEditor.doAddSequence(%selectedAnimation, 0, 0, 0);
|
||||
}
|
||||
|
||||
function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end )
|
||||
{
|
||||
%action = %this.createAction( ActionAddSequence, "Add sequence" );
|
||||
|
|
@ -313,23 +319,44 @@ function ShapeEditor::doAddSequence( %this, %seqName, %from, %start, %end )
|
|||
|
||||
function ActionAddSequence::doit( %this )
|
||||
{
|
||||
// If adding this sequence from an existing sequence, make a backup copy of
|
||||
// the existing sequence first, so we can edit the start/end frames later
|
||||
// without having to worry if the original source sequence has changed.
|
||||
if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 )
|
||||
if(ShapeEditorPlugin.selectedAssetId $= "")
|
||||
{
|
||||
%this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" );
|
||||
ShapeEditor.shape.addSequence( %this.origFrom, %this.from );
|
||||
// If adding this sequence from an existing sequence, make a backup copy of
|
||||
// the existing sequence first, so we can edit the start/end frames later
|
||||
// without having to worry if the original source sequence has changed.
|
||||
if ( ShapeEditor.shape.getSequenceIndex( %this.from ) >= 0 )
|
||||
{
|
||||
%this.from = ShapeEditor.getUniqueName( "sequence", "__backup__" @ %this.origFrom @ "_" );
|
||||
ShapeEditor.shape.addSequence( %this.origFrom, %this.from );
|
||||
}
|
||||
|
||||
// Add the sequence
|
||||
$collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" );
|
||||
%success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end );
|
||||
$collada::forceLoadDAE = false;
|
||||
|
||||
if ( %success )
|
||||
{
|
||||
ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the sequence
|
||||
$collada::forceLoadDAE = EditorSettings.value( "forceLoadDAE" );
|
||||
%success = ShapeEditor.shape.addSequence( %this.from, %this.seqName, %this.start, %this.end );
|
||||
$collada::forceLoadDAE = false;
|
||||
|
||||
if ( %success )
|
||||
else
|
||||
{
|
||||
ShapeEdPropWindow.update_onSequenceAdded( %this.seqName, -1 );
|
||||
%assetDef = AssetDatabase.acquireAsset(%this.seqName);
|
||||
%moduleName = getWord(getToken(%this.seqName, ":", 0),0);
|
||||
|
||||
%idx = ShapeEdSequenceList.rowCount();
|
||||
|
||||
%matSet = "ShapeEditorPlugin.selectedAssetDef.animationSequence"@%idx@"=\"@Asset="@%moduleName@":"@%this.seqName.assetName@"\";";
|
||||
eval(%matSet);
|
||||
|
||||
%assetPath = AssetDatabase.getAssetFilePath(ShapeEditorPlugin.selectedAssetId);
|
||||
|
||||
%assetImportSuccessful = TAMLWrite(ShapeEditorPlugin.selectedAssetDef, %assetPath);
|
||||
|
||||
AssetDatabase.refreshAsset(ShapeEditorPlugin.selectedAssetId);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue