mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
Initial implementation of the Scene object for handling scenes/levels in a more consistent and deliberate way.
This commit is contained in:
parent
e0627973fb
commit
1c2f90a190
37 changed files with 509 additions and 140 deletions
|
|
@ -189,7 +189,7 @@ function ConvexEditorPlugin::onSaveMission( %this, %missionFile )
|
|||
{
|
||||
if( ConvexEditorGui.isDirty )
|
||||
{
|
||||
MissionGroup.save( %missionFile );
|
||||
getScene(0).save( %missionFile );
|
||||
ConvexEditorGui.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1584,7 +1584,7 @@ function ColladaImportDlg::onOK(%this)
|
|||
function ColladaImportDlg::loadLights(%this)
|
||||
{
|
||||
// Get the ID of the last object added
|
||||
%obj = MissionGroup.getObject(MissionGroup.getCount()-1);
|
||||
%obj = getScene(0).getObject(getScene(0).getCount()-1);
|
||||
|
||||
// Create a new SimGroup to hold the model and lights
|
||||
%group = new SimGroup();
|
||||
|
|
@ -1596,7 +1596,7 @@ function ColladaImportDlg::loadLights(%this)
|
|||
{
|
||||
%group.add(%obj);
|
||||
%group.bringToFront(%obj);
|
||||
MissionGroup.add(%group);
|
||||
getScene(0).add(%group);
|
||||
if (EditorTree.isVisible())
|
||||
{
|
||||
EditorTree.removeItem(EditorTree.findItemByObjectId(%obj));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//--- OBJECT WRITE BEGIN ---
|
||||
new SimGroup(MissionGroup) {
|
||||
new Scene(EditorTemplateLevel) {
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
cdTrack = "2";
|
||||
|
|
|
|||
|
|
@ -1051,7 +1051,7 @@ function MaterialEditorGui::updateActiveMaterialName(%this, %name)
|
|||
// Some objects (ConvexShape, DecalRoad etc) reference Materials by name => need
|
||||
// to find and update all these references so they don't break when we rename the
|
||||
// Material.
|
||||
MaterialEditorGui.updateMaterialReferences( MissionGroup, %action.oldName, %action.newName );
|
||||
MaterialEditorGui.updateMaterialReferences( getScene(0), %action.oldName, %action.newName );
|
||||
}
|
||||
|
||||
function MaterialEditorGui::updateMaterialReferences( %this, %obj, %oldName, %newName )
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ function ActionUpdateActiveMaterialAnimationFlags::undo(%this)
|
|||
function ActionUpdateActiveMaterialName::redo(%this)
|
||||
{
|
||||
%this.material.setName(%this.newName);
|
||||
MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.oldName, %this.newName );
|
||||
MaterialEditorGui.updateMaterialReferences( getScene(0), %this.oldName, %this.newName );
|
||||
|
||||
if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material )
|
||||
{
|
||||
|
|
@ -199,7 +199,7 @@ function ActionUpdateActiveMaterialName::redo(%this)
|
|||
function ActionUpdateActiveMaterialName::undo(%this)
|
||||
{
|
||||
%this.material.setName(%this.oldName);
|
||||
MaterialEditorGui.updateMaterialReferences( MissionGroup, %this.newName, %this.oldName );
|
||||
MaterialEditorGui.updateMaterialReferences( getScene(0), %this.newName, %this.oldName );
|
||||
|
||||
if( MaterialEditorPreviewWindow.isVisible() && MaterialEditorGui.currentMaterial == %this.material )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ function MeshRoadEditorPlugin::onSaveMission( %this, %missionFile )
|
|||
{
|
||||
if( MeshRoadEditorGui.isDirty )
|
||||
{
|
||||
MissionGroup.save( %missionFile );
|
||||
getScene(0).save( %missionFile );
|
||||
MeshRoadEditorGui.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ function MissionAreaEditorPlugin::createNewMissionArea(%this)
|
|||
%newMissionArea = new MissionArea();
|
||||
%newMissionArea.area = "-256 -256 512 512";
|
||||
|
||||
MissionGroup.add(%newMissionArea);
|
||||
getScene(0).add(%newMissionArea);
|
||||
|
||||
EditorGui.setEditor(MissionAreaEditorPlugin);
|
||||
|
||||
|
|
|
|||
|
|
@ -354,13 +354,13 @@ function CreateNewNavMeshDlg::create(%this)
|
|||
|
||||
if(MeshMissionBounds.isStateOn())
|
||||
{
|
||||
if(!isObject(MissionGroup))
|
||||
if(!isObject(getScene(0)))
|
||||
{
|
||||
MessageBoxOk("Error", "You must have a MissionGroup to use the mission bounds function.");
|
||||
MessageBoxOk("Error", "You must have a Scene to use the mission bounds function.");
|
||||
return;
|
||||
}
|
||||
// Get maximum extents of all objects.
|
||||
%box = MissionBoundsExtents(MissionGroup);
|
||||
%box = MissionBoundsExtents(getScene(0));
|
||||
%pos = GetBoxCenter(%box);
|
||||
%scale = (GetWord(%box, 3) - GetWord(%box, 0)) / 2 + 5
|
||||
SPC (GetWord(%box, 4) - GetWord(%box, 1)) / 2 + 5
|
||||
|
|
@ -380,7 +380,7 @@ function CreateNewNavMeshDlg::create(%this)
|
|||
scale = %this-->MeshScale.getText();
|
||||
};
|
||||
}
|
||||
MissionGroup.add(%mesh);
|
||||
getScene(0).add(%mesh);
|
||||
NavEditorGui.selectObject(%mesh);
|
||||
|
||||
Canvas.popDialog(CreateNewNavMeshDlg);
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ function NavEditorPlugin::onSaveMission(%this, %missionFile)
|
|||
{
|
||||
if(NavEditorGui.isDirty)
|
||||
{
|
||||
MissionGroup.save(%missionFile);
|
||||
getScene(0).save(%missionFile);
|
||||
NavEditorGui.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,9 @@ function RiverEditorPlugin::onSaveMission( %this, %missionFile )
|
|||
{
|
||||
if( RiverEditorGui.isDirty )
|
||||
{
|
||||
MissionGroup.save( %missionFile );
|
||||
//Get our root scene, which would be the level
|
||||
getScene(0).save( %missionFile );
|
||||
|
||||
RiverEditorGui.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ function RoadEditorPlugin::onSaveMission( %this, %missionFile )
|
|||
{
|
||||
if( RoadEditorGui.isDirty )
|
||||
{
|
||||
MissionGroup.save( %missionFile );
|
||||
getScene(0).save( %missionFile );
|
||||
RoadEditorGui.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ function ShapeEditorPlugin::open(%this, %filename)
|
|||
ShapeEdNodes-->worldTransform.setStateOn(1);
|
||||
|
||||
// Initialise and show the shape editor
|
||||
ShapeEdShapeTreeView.open(MissionGroup);
|
||||
ShapeEdShapeTreeView.open(getScene(0));
|
||||
ShapeEdShapeTreeView.buildVisibleTree(true);
|
||||
|
||||
ShapeEdPreviewGui.setVisible(true);
|
||||
|
|
|
|||
|
|
@ -184,11 +184,11 @@ function TimeAdjustSliderCtrl::onAction(%this)
|
|||
|
||||
if ( !isObject( %this.tod ) )
|
||||
{
|
||||
if ( isObject( MissionGroup ) )
|
||||
if ( isObject( getScene(0) ) )
|
||||
{
|
||||
for ( %i = 0; %i < MissionGroup.getCount(); %i++ )
|
||||
for ( %i = 0; %i < getScene(0).getCount(); %i++ )
|
||||
{
|
||||
%obj = MissionGroup.getObject( %i );
|
||||
%obj = getScene(0).getObject( %i );
|
||||
|
||||
if ( %obj.getClassName() $= "TimeOfDay" )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -947,10 +947,10 @@ function ObjectBuilderGui::buildPlayerDropPoint(%this)
|
|||
%this.addField("spawnClass", "TypeString", "Spawn Class", "Player");
|
||||
%this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "PlayerData DefaultPlayerData");
|
||||
|
||||
if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() )
|
||||
if( EWCreatorWindow.objectGroup.getID() == getScene(0).getID() )
|
||||
{
|
||||
if( !isObject("PlayerDropPoints") )
|
||||
MissionGroup.add( new SimGroup("PlayerDropPoints") );
|
||||
getScene(0).add( new SimGroup("PlayerDropPoints") );
|
||||
%this.objectGroup = "PlayerDropPoints";
|
||||
}
|
||||
|
||||
|
|
@ -967,10 +967,10 @@ function ObjectBuilderGui::buildObserverDropPoint(%this)
|
|||
%this.addField("spawnClass", "TypeString", "Spawn Class", "Camera");
|
||||
%this.addField("spawnDatablock", "TypeDataBlock", "Spawn Data", "CameraData Observer");
|
||||
|
||||
if( EWCreatorWindow.objectGroup.getID() == MissionGroup.getID() )
|
||||
if( EWCreatorWindow.objectGroup.getID() == getScene(0).getID() )
|
||||
{
|
||||
if( !isObject("ObserverDropPoints") )
|
||||
MissionGroup.add( new SimGroup("ObserverDropPoints") );
|
||||
getScene(0).add( new SimGroup("ObserverDropPoints") );
|
||||
%this.objectGroup = "ObserverDropPoints";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ function EditorGui::addCameraBookmark( %this, %name )
|
|||
if( !isObject(CameraBookmarks) )
|
||||
{
|
||||
%grp = new SimGroup(CameraBookmarks);
|
||||
MissionGroup.add(%grp);
|
||||
getScene(0).add(%grp);
|
||||
}
|
||||
CameraBookmarks.add( %obj );
|
||||
|
||||
|
|
@ -835,12 +835,17 @@ function EditorGui::syncCameraGui( %this )
|
|||
|
||||
function WorldEditorPlugin::onActivated( %this )
|
||||
{
|
||||
if(!isObject(Scenes))
|
||||
$scenesRootGroup = new SimGroup(Scenes);
|
||||
|
||||
$scenesRootGroup.add(getScene(0));
|
||||
|
||||
EditorGui.bringToFront( EWorldEditor );
|
||||
EWorldEditor.setVisible(true);
|
||||
EditorGui.menuBar.insert( EditorGui.worldMenu, EditorGui.menuBar.dynamicItemInsertPos );
|
||||
EWorldEditor.makeFirstResponder(true);
|
||||
EditorTree.open(MissionGroup,true);
|
||||
EWCreatorWindow.setNewObjectGroup(MissionGroup);
|
||||
EditorTree.open($scenesRootGroup,true);
|
||||
EWCreatorWindow.setNewObjectGroup(getScene(0));
|
||||
|
||||
EWorldEditor.syncGui();
|
||||
|
||||
|
|
@ -1464,7 +1469,7 @@ function EditorTree::onDeleteObject( %this, %object )
|
|||
return true;
|
||||
|
||||
if( %object == EWCreatorWindow.objectGroup )
|
||||
EWCreatorWindow.setNewObjectGroup( MissionGroup );
|
||||
EWCreatorWindow.setNewObjectGroup( getScene(0) );
|
||||
|
||||
// Append it to our list.
|
||||
%this.undoDeleteList = %this.undoDeleteList TAB %object;
|
||||
|
|
@ -1596,6 +1601,13 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
|
|||
{
|
||||
%popup.item[ 0 ] = "Add Camera Bookmark" TAB "" TAB "EditorGui.addCameraBookmarkByGui();";
|
||||
}
|
||||
else if( %obj.isMemberOfClass( "Scene" ))
|
||||
{
|
||||
%popup.item[ 0 ] = "Set as Active Scene" TAB "" TAB "EditorTree.showItemRenameCtrl( EditorTree.findItemByObjectId(" @ %popup.object @ ") );";
|
||||
%popup.item[ 1 ] = "Delete" TAB "" TAB "EWorldEditor.deleteMissionObject(" @ %popup.object @ ");";
|
||||
%popup.item[ 2 ] = "Inspect" TAB "" TAB "inspectObject(" @ %popup.object @ ");";
|
||||
%popup.item[ 3 ] = "-";
|
||||
}
|
||||
else
|
||||
{
|
||||
%popup.object = %obj;
|
||||
|
|
@ -1673,8 +1685,8 @@ function EditorTree::onRightMouseUp( %this, %itemId, %mouse, %obj )
|
|||
|
||||
if( %haveObjectEntries )
|
||||
{
|
||||
%popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj.getName() !$= "MissionGroup" );
|
||||
%popup.enableItem( 1, %obj.getName() !$= "MissionGroup" );
|
||||
%popup.enableItem( 0, %obj.isNameChangeAllowed() && %obj !$= getScene(0) );
|
||||
%popup.enableItem( 1, %obj !$= getScene(0) );
|
||||
|
||||
if( %haveLockAndHideEntries )
|
||||
{
|
||||
|
|
@ -2025,21 +2037,21 @@ function EWorldEditor::syncToolPalette( %this )
|
|||
function EWorldEditor::addSimGroup( %this, %groupCurrentSelection )
|
||||
{
|
||||
%activeSelection = %this.getActiveSelection();
|
||||
if ( %activeSelection.getObjectIndex( MissionGroup ) != -1 )
|
||||
if ( %activeSelection.getObjectIndex( getScene(0) ) != -1 )
|
||||
{
|
||||
MessageBoxOK( "Error", "Cannot add MissionGroup to a new SimGroup" );
|
||||
MessageBoxOK( "Error", "Cannot add Scene to a new SimGroup" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Find our parent.
|
||||
|
||||
%parent = MissionGroup;
|
||||
%parent = getScene(0);
|
||||
if( !%groupCurrentSelection && isObject( %activeSelection ) && %activeSelection.getCount() > 0 )
|
||||
{
|
||||
%firstSelectedObject = %activeSelection.getObject( 0 );
|
||||
if( %firstSelectedObject.isMemberOfClass( "SimGroup" ) )
|
||||
%parent = %firstSelectedObject;
|
||||
else if( %firstSelectedObject.getId() != MissionGroup.getId() )
|
||||
else if( %firstSelectedObject.getId() != getScene(0).getId() )
|
||||
%parent = %firstSelectedObject.parentGroup;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function ESelectObjectsWindow::toggleVisibility( %this )
|
|||
/// to start searching for objects.
|
||||
function ESelectObjectsWindow::getRootGroup( %this )
|
||||
{
|
||||
return MissionGroup;
|
||||
return getScene(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ function EWCreatorWindow::createStatic( %this, %file )
|
|||
return;
|
||||
|
||||
if( !isObject(%this.objectGroup) )
|
||||
%this.setNewObjectGroup( MissionGroup );
|
||||
%this.setNewObjectGroup( getScene(0) );
|
||||
|
||||
%objId = new TSStatic()
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ function EWCreatorWindow::createPrefab( %this, %file )
|
|||
return;
|
||||
|
||||
if( !isObject(%this.objectGroup) )
|
||||
%this.setNewObjectGroup( MissionGroup );
|
||||
%this.setNewObjectGroup( getScene(0) );
|
||||
|
||||
%objId = new Prefab()
|
||||
{
|
||||
|
|
@ -215,7 +215,7 @@ function EWCreatorWindow::createObject( %this, %cmd )
|
|||
return;
|
||||
|
||||
if( !isObject(%this.objectGroup) )
|
||||
%this.setNewObjectGroup( MissionGroup );
|
||||
%this.setNewObjectGroup( getScene(0) );
|
||||
|
||||
pushInstantGroup();
|
||||
%objId = eval(%cmd);
|
||||
|
|
|
|||
|
|
@ -124,6 +124,12 @@ function WorldEditor::onSelectionCentroidChanged( %this )
|
|||
Inspector.refresh();
|
||||
}
|
||||
|
||||
function WorldEditor::setSceneAsDirty(%this)
|
||||
{
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function WorldEditor::init(%this)
|
||||
|
|
@ -198,7 +204,7 @@ function WorldEditor::export(%this)
|
|||
|
||||
function WorldEditor::doExport(%this, %file)
|
||||
{
|
||||
missionGroup.save("~/editor/" @ %file, true);
|
||||
getScene(0).save("~/editor/" @ %file, true);
|
||||
}
|
||||
|
||||
function WorldEditor::import(%this)
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ function EditorSaveMission()
|
|||
// now write the terrain and mission files out:
|
||||
|
||||
if(EWorldEditor.isDirty || ETerrainEditor.isMissionDirty)
|
||||
MissionGroup.save($Server::MissionFile);
|
||||
getScene(0).save($Server::MissionFile);
|
||||
if(ETerrainEditor.isDirty)
|
||||
{
|
||||
// Find all of the terrain files
|
||||
|
|
@ -483,6 +483,21 @@ function EditorOpenMission(%filename)
|
|||
}
|
||||
}
|
||||
|
||||
function EditorOpenSceneAppend(%levelAsset)
|
||||
{
|
||||
//Load the asset's level file
|
||||
exec(%levelAsset.levelFile);
|
||||
|
||||
//We'll assume the scene name and assetname are the same for now
|
||||
%sceneName = %levelAsset.AssetName;
|
||||
%scene = nameToID(%sceneName);
|
||||
if(isObject(%scene))
|
||||
{
|
||||
//Append it to our scene heirarchy
|
||||
$scenesRootGroup.add(%scene);
|
||||
}
|
||||
}
|
||||
|
||||
function EditorExportToCollada()
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue