summaryrefslogtreecommitdiffstats
path: root/tools/trackeditor/code/commands
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/trackeditor/code/commands/export.cpp193
-rw-r--r--tools/trackeditor/code/commands/export.h26
-rw-r--r--tools/trackeditor/code/commands/intersectioncommands.cpp449
-rw-r--r--tools/trackeditor/code/commands/intersectioncommands.h60
-rw-r--r--tools/trackeditor/code/commands/trackeditorcommands.cpp222
-rw-r--r--tools/trackeditor/code/commands/trackeditorcommands.h42
-rw-r--r--tools/trackeditor/code/commands/treelinecommand.cpp323
-rw-r--r--tools/trackeditor/code/commands/treelinecommand.h136
8 files changed, 1451 insertions, 0 deletions
diff --git a/tools/trackeditor/code/commands/export.cpp b/tools/trackeditor/code/commands/export.cpp
new file mode 100644
index 0000000..77b7328
--- /dev/null
+++ b/tools/trackeditor/code/commands/export.cpp
@@ -0,0 +1,193 @@
+#include "precompiled/PCH.h"
+
+#include "export.h"
+#include "main/constants.h"
+#include "nodes/walllocator.h"
+#include "nodes/fenceline.h"
+#include "nodes/intersection.h"
+#include "nodes/road.h"
+#include "nodes/pedpath.h"
+#include "utility/mui.h"
+#include "utility/mext.h"
+
+#include <toollib.hpp>
+
+const char* ExportCommand::stringId = "TE_Export";
+bool ExportCommand::sRegisteredChunks = false;
+
+
+ExportCommand::ExportCommand() {};
+ExportCommand::~ExportCommand() {};
+
+//==============================================================================
+// ExportCommand::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* ExportCommand::creator()
+{
+ return new ExportCommand();
+}
+
+//==============================================================================
+// ExportCommand::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus ExportCommand::doIt( const MArgList& args )
+{
+ if ( !sRegisteredChunks )
+ {
+ tlDataChunk::RegisterDefaultChunks();
+ sRegisteredChunks = true;
+ }
+
+ //Go through all the chunks looking for the types we want and exporting them.
+ //Alternatively, we could go thtough all the chunks and attempt to access the
+ //IExportable interface and then export if the interface exists...
+
+ //Args are all, or selected.
+
+ const unsigned char FILE_NAME_SIZE = 255;
+ char filePath[FILE_NAME_SIZE];
+ filePath[0] = '\0';
+
+ if ( MUI::FileDialog( filePath,
+ FILE_NAME_SIZE,
+ "Track Editor Export",
+ "Pure3D(*.p3d)|*.p3d|All Files(*.*)|*.*||",
+ "p3d",
+ MUI::SAVE ) )
+ {
+ //TODO: add selected.
+ MItDag dagIt( MItDag::kBreadthFirst, MFn::kLocator );
+
+ tlDataChunk* outChunk = new tlDataChunk;
+
+ //Put in a history chunk.
+ tlHistory history;
+
+// char hist[256];
+// sprintf(hist, "Track Editor version: 2.0, toollib version: %s", tlversion);
+//
+// history.AddLine( hist );
+
+// outChunk->AppendSubChunk( history.Chunk(), 0 );
+
+ bool deleteLast = false;
+ MFnDependencyNode fnNode;
+ MObject lastObj;
+ MTypeId id;
+
+ while ( !dagIt.isDone() )
+ {
+ fnNode.setObject( dagIt.item() );
+ id = fnNode.typeId();
+
+ if ( id == FenceLineNode::id )
+ {
+ //Export a wall locator;
+ tlDataChunk* newChunk = FenceLineNode::Export( dagIt.item(), history );
+
+ if ( newChunk )
+ {
+ //Append this to the output file.
+ outChunk->AppendSubChunk( newChunk );
+ }
+ else
+ {
+ //Time to go away.
+ deleteLast = true;
+ }
+ }
+ else if ( id == IntersectionLocatorNode::id )
+ {
+ tlDataChunk* newChunk = IntersectionLocatorNode::Export( dagIt.item(), history );
+
+ if ( newChunk )
+ {
+ //Append this to the output file.
+ outChunk->AppendSubChunk( newChunk );
+ }
+ else
+ {
+ //Time to go away.
+ deleteLast = true;
+ }
+ }
+ else if ( id == RoadNode::id )
+ {
+ tlDataChunk* newChunk = RoadNode::Export( dagIt.item(), history, outChunk );
+
+ if ( newChunk )
+ {
+ //Append this to the output file.
+ outChunk->AppendSubChunk( newChunk );
+ }
+ else
+ {
+ //Time to go away.
+ deleteLast = true;
+ }
+ }
+ else if ( id == PedPathNode::id )
+ {
+ tlDataChunk* newChunk = PedPathNode::Export( dagIt.item(), history );
+
+ if ( newChunk )
+ {
+ //Append this to the output file.
+ outChunk->AppendSubChunk( newChunk );
+ }
+ else
+ {
+ //Time to go away.
+ deleteLast = true;
+ }
+ }
+
+ if ( deleteLast )
+ {
+ lastObj = dagIt.item();
+ }
+
+ dagIt.next();
+
+ if ( deleteLast )
+ {
+ MExt::DisplayWarning( "Deleting useless node: %s", fnNode.name().asChar() );
+ MExt::DeleteNode( lastObj, true );
+ deleteLast = false;
+ }
+ }
+
+ tlFile output(new tlFileByteStream(filePath, omWRITE), tlFile::CHUNK32);
+
+ if(!output.IsOpen())
+ {
+
+ MGlobal::displayError("Unable to write file!");
+
+ delete outChunk;
+ return MS::kFailure;
+ }
+
+ //Sort it out..
+ outChunk->SortSubChunks();
+ outChunk->Write(&output);
+
+ delete outChunk;
+ }
+
+ return MS::kSuccess;
+}
diff --git a/tools/trackeditor/code/commands/export.h b/tools/trackeditor/code/commands/export.h
new file mode 100644
index 0000000..f3c031c
--- /dev/null
+++ b/tools/trackeditor/code/commands/export.h
@@ -0,0 +1,26 @@
+#include "precompiled/PCH.h"
+
+#ifndef EXPORT_COMMAND_H
+#define EXPORT_COMMAND_H
+
+class ExportCommand : MPxCommand
+{
+public:
+ enum ExportArg
+ {
+ SELECTED,
+ ALL
+ };
+
+ ExportCommand();
+ ~ExportCommand();
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+
+private:
+ static bool sRegisteredChunks;
+};
+#endif \ No newline at end of file
diff --git a/tools/trackeditor/code/commands/intersectioncommands.cpp b/tools/trackeditor/code/commands/intersectioncommands.cpp
new file mode 100644
index 0000000..4733762
--- /dev/null
+++ b/tools/trackeditor/code/commands/intersectioncommands.cpp
@@ -0,0 +1,449 @@
+#include "precompiled/PCH.h"
+
+#include "intersectioncommands.h"
+#include "utility/mext.h"
+#include "nodes/road.h"
+#include "main/trackeditor.h"
+#include "nodes/intersection.h"
+
+
+const char* CreateRoadCmd::stringId = "TE_CreateRoad";
+const char* AddIntersectionToRoadCmd::stringId = "TE_AddIntersectionToRoad";
+
+
+//==============================================================================
+// CreateRoadCmd::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* CreateRoadCmd::creator()
+{
+ return new CreateRoadCmd();
+}
+
+//==============================================================================
+// CreateRoadCmd::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus CreateRoadCmd::doIt( const MArgList& args )
+{
+ //Take all the selected road segments and create a road from them.
+ //If there is a segment that has not been roadified, highlight that one and return an error message.
+
+ MSelectionList selectList;
+ MGlobal::getActiveSelectionList( selectList );
+ MItSelectionList itSelect( selectList, MFn::kMesh );
+
+ if ( selectList.length() <= 0 || itSelect.isDone() )
+ {
+ MExt::DisplayWarning( "Nothing to do, please select road segments!" );
+ return MStatus::kSuccess;
+ }
+
+ MObjectArray segArray;
+ MObject obj;
+ MFnMesh fnMesh;
+ MPlug whichRoadPlug;
+ MStatus status;
+
+ while ( !itSelect.isDone() )
+ {
+ //Gather all the road segments and add them to the new road.
+ itSelect.getDependNode( obj );
+
+ fnMesh.setObject( obj );
+
+ whichRoadPlug = fnMesh.findPlug( MString( "teWhichRoad" ), &status );
+
+ if ( status == MStatus::kSuccess )
+ {
+ //This is one of them.
+ segArray.append( obj );
+ }
+
+ itSelect.next();
+ }
+
+ if ( segArray.length() <= 0 )
+ {
+ //There were no appropriate segs in the selection.
+ MExt::DisplayWarning( "Nothing to do, please select road segments!" );
+ return MStatus::kSuccess;
+ }
+
+ MObject newRoad;
+ MObject newRoadT;
+
+ MExt::CreateNode( newRoad, newRoadT, MString( RoadNode::stringId ) );
+
+ assert( !newRoad.isNull() );
+
+ unsigned int i;
+ for ( i = 0; i < segArray.length(); ++i )
+ {
+ //Test to see if this road seg is already connected.
+ if ( MExt::IsConnected( segArray[ i ], "teWhichRoad" ) )
+ {
+ MExt::DisconnectAll( segArray[ i ], "teWhichRoad" );
+ }
+
+ MExt::Connect( segArray[ i ], "teWhichRoad", newRoad, RoadNode::ROAD_SEG_NAME_LONG );
+ }
+
+ TrackEditor::AddChild( newRoad );
+
+ return MStatus::kSuccess;
+}
+
+
+//==============================================================================
+// AddIntersectionToRoadCmd::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* AddIntersectionToRoadCmd::creator()
+{
+ return new AddIntersectionToRoadCmd();
+}
+
+//==============================================================================
+// AddIntersectionToRoadCmd::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus AddIntersectionToRoadCmd::doIt( const MArgList& args )
+{
+ MStatus status;
+
+ //Arg 0 is the name of the intersection (the road is selected)
+ //Arg 1 is whether it is a start or end point on the road.
+
+ assert( args.length() == 2 );
+
+ MObjectArray roadArray;
+
+ if ( GetRoadsFromSelectionList( roadArray ) )
+ {
+ MString intersectionName;
+ args.get( 0, intersectionName );
+
+ if ( intersectionName == MString( "" ) )
+ {
+ MExt::DisplayWarning( "Must have an intersection selected in the editor." );
+ return MStatus::kSuccess;
+ }
+
+ bool isEnd;
+ args.get( 1, isEnd );
+
+ MDagPath dagPath;
+ if ( !MExt::FindDagNodeByName( &dagPath, intersectionName ) )
+ {
+ MExt::DisplayWarning( "The Intersection: %s does not exist!", intersectionName.asChar() );
+ return MStatus::kSuccess;
+ }
+
+ MFnDagNode fnIntersectionDagNode( dagPath );
+
+ unsigned int i;
+ for ( i = 0; i < roadArray.length(); ++i )
+ {
+ if ( isEnd )
+ {
+ MExt::DisconnectAll( roadArray[i], RoadNode::INTERSECTION_END_LONG );
+ MExt::Connect( roadArray[i], RoadNode::INTERSECTION_END_LONG, fnIntersectionDagNode.object(), IntersectionLocatorNode::ROAD_LONG );
+ }
+ else
+ {
+ MExt::DisconnectAll( roadArray[i], RoadNode::INTERSECTION_START_LONG );
+ MExt::Connect( roadArray[i], RoadNode::INTERSECTION_START_LONG, fnIntersectionDagNode.object(), IntersectionLocatorNode::ROAD_LONG );
+ }
+ }
+ }
+
+ return MStatus::kSuccess;
+}
+
+
+const char* ShowRoadCmd::stringId = "TE_ShowRoad";
+
+//==============================================================================
+// ShowRoadCmd::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* ShowRoadCmd::creator()
+{
+ return new ShowRoadCmd();
+}
+
+//==============================================================================
+// ShowRoadCmd::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus ShowRoadCmd::doIt( const MArgList& args )
+{
+
+ MObject road;
+
+ if ( GetRoadFromSelectionList( road ) )
+ {
+ MString cmd;
+
+ MFnDependencyNode fnNode( road );
+ MPlug roadPlug = fnNode.findPlug( MString( RoadNode::ROAD_SEG_NAME_LONG ) );
+ assert( roadPlug.isArray() );
+
+ MGlobal::clearSelectionList();
+
+ MPlugArray source, dest;
+ MExt::ResolveConnections( &source, &dest, roadPlug, AS_DEST );
+
+ assert( source.length() );
+
+ unsigned int i;
+ for ( i = 0; i < source.length(); ++i )
+ {
+ fnNode.setObject( source[i].node() );
+ cmd = MString( "select -add " ) + fnNode.name();
+
+ MGlobal::executeCommand( cmd );
+ }
+
+ fnNode.setObject( road );
+ cmd = MString("select -add ") + fnNode.name();
+ MGlobal::executeCommand( cmd );
+ }
+
+ return MStatus::kSuccess;
+}
+
+
+const char* DestroyRoadCmd::stringId = "TE_DestroyRoad";
+
+//==============================================================================
+// DestroyRoadCmd::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* DestroyRoadCmd::creator()
+{
+ return new DestroyRoadCmd();
+}
+
+//==============================================================================
+// DestroyRoadCmd::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus DestroyRoadCmd::doIt( const MArgList& args )
+{
+
+ MObject road;
+
+ if ( GetRoadFromSelectionList( road ) )
+ {
+ MExt::DeleteNode( road, true );
+ }
+
+ return MStatus::kSuccess;
+}
+
+
+
+//==============================================================================
+// GetRoadFromSelectionList
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( MObject& road )
+//
+// Return: bool
+//
+//==============================================================================
+bool GetRoadFromSelectionList( MObject& road )
+{
+ MStatus status;
+
+ MSelectionList selectList;
+ MGlobal::getActiveSelectionList( selectList );
+
+ if ( selectList.length() <= 0 )
+ {
+ MExt::DisplayWarning( "A road segment must be selected!" );
+ return false;
+ }
+ else
+ {
+ MObject segment;
+ selectList.getDependNode( 0, segment );
+ MFnDagNode fnNode( segment );
+
+ if ( fnNode.typeName() == MString( RoadNode::stringId ) )
+ {
+ //this is a road segment
+ road = fnNode.object();
+ }
+ else
+ {
+ //Test to make sure the selected item is a road segment.
+ MFn::Type type = fnNode.type();
+
+ if ( fnNode.typeName() == MString( "transform" ) )
+ {
+ //We want the child of this, not the transform.
+ fnNode.setObject( fnNode.child( 0 ) );
+ }
+
+ MPlug whichRoadPlug = fnNode.findPlug( MString( "teWhichRoad" ), &status );
+
+ if ( status )
+ {
+ //Get the intersection connected to this road and select all the road segs
+ //attached to it.
+ if ( whichRoadPlug.isConnected() )
+ {
+ //Get the road Locator;
+ MPlugArray plugs;
+ whichRoadPlug.connectedTo( plugs, false, true );
+
+ assert( plugs.length() > 0 );
+
+ //Get to road attached to the segment.
+ road = plugs[ 0 ].node();
+ }
+ else
+ {
+ MExt::DisplayWarning( "This road segment is not part of a road!" );
+ return false;
+ }
+ }
+ else
+ {
+ MExt::DisplayWarning( "A road segment must be selected!" );
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+//==============================================================================
+// GetRoadsFromSelectionList
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( MObject& road )
+//
+// Return: bool
+//
+//==============================================================================
+bool GetRoadsFromSelectionList( MObjectArray& roadArray )
+{
+ MStatus status;
+
+ MSelectionList selectList;
+ MGlobal::getActiveSelectionList( selectList );
+
+ if ( selectList.length() <= 0 )
+ {
+ MExt::DisplayWarning( "At least one road segment must be selected!" );
+ return false;
+ }
+ else
+ {
+ unsigned int i;
+ for ( i = 0; i < selectList.length(); ++i )
+ {
+ MObject node;
+ selectList.getDependNode( i, node );
+ MFnDagNode fnNode( node );
+
+ if ( fnNode.typeName() == MString( RoadNode::stringId ) )
+ {
+ //this is a road node
+ roadArray.append( fnNode.object() );
+ }
+ else
+ {
+ //Test to make sure the selected item is a road segment.
+ MFn::Type type = fnNode.type();
+
+ if ( fnNode.typeName() == MString( "transform" ) )
+ {
+ //We want the child of this, not the transform.
+ fnNode.setObject( fnNode.child( 0 ) );
+ }
+
+ MPlug whichRoadPlug = fnNode.findPlug( MString( "teWhichRoad" ), &status );
+
+ if ( status )
+ {
+ //Get the intersection connected to this road and select all the road segs
+ //attached to it.
+ if ( whichRoadPlug.isConnected() )
+ {
+ //Get the road Locator;
+ MPlugArray plugs;
+ whichRoadPlug.connectedTo( plugs, false, true );
+
+ assert( plugs.length() > 0 );
+
+ //Get to road attached to the segment.
+ roadArray.append( plugs[ 0 ].node() );
+ }
+ else
+ {
+ MExt::DisplayWarning( "This road segment: %s is not part of a road!", fnNode.name().asChar() );
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/tools/trackeditor/code/commands/intersectioncommands.h b/tools/trackeditor/code/commands/intersectioncommands.h
new file mode 100644
index 0000000..f2a261b
--- /dev/null
+++ b/tools/trackeditor/code/commands/intersectioncommands.h
@@ -0,0 +1,60 @@
+#include "precompiled/PCH.h"
+
+#ifndef INTERSECTION_COMMANDS
+#define INTERSECTION_COMMANDS
+
+class CreateRoadCmd : public MPxCommand
+{
+public:
+ CreateRoadCmd() {};
+ ~CreateRoadCmd() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+class AddIntersectionToRoadCmd : public MPxCommand
+{
+public:
+ AddIntersectionToRoadCmd() {};
+ ~AddIntersectionToRoadCmd() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+class ShowRoadCmd : public MPxCommand
+{
+public:
+ ShowRoadCmd() {};
+ ~ShowRoadCmd() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+class DestroyRoadCmd : public MPxCommand
+{
+public:
+ DestroyRoadCmd() {};
+ ~DestroyRoadCmd() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+
+
+//Global tool like thing.
+bool GetRoadFromSelectionList( MObject& road );
+bool GetRoadsFromSelectionList( MObjectArray& road );
+
+#endif \ No newline at end of file
diff --git a/tools/trackeditor/code/commands/trackeditorcommands.cpp b/tools/trackeditor/code/commands/trackeditorcommands.cpp
new file mode 100644
index 0000000..29aeb76
--- /dev/null
+++ b/tools/trackeditor/code/commands/trackeditorcommands.cpp
@@ -0,0 +1,222 @@
+#include "precompiled/PCH.h"
+
+#include "trackeditorcommands.h"
+#include "main/trackeditor.h"
+#include "utility/mext.h"
+#include "main/constants.h"
+
+//TEStateChange
+const char* TEStateChangeCommand::stringId = "TE_StateChange";
+
+//==============================================================================
+// TEStateChangeCommand::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* TEStateChangeCommand::creator()
+{
+ return new TEStateChangeCommand();
+}
+
+//==============================================================================
+// TEStateChangeCommand::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus TEStateChangeCommand::doIt( const MArgList& args )
+{
+ assert( args.length() == 1 );
+
+ int arg;
+ args.get( 0, arg );
+
+ TrackEditor::SetEditMode( (TrackEditor::EditMode) arg );
+
+ return MStatus::kSuccess;
+}
+
+//TEGetSelectedVertexPosition
+
+const char* TEGetSelectedVertexPosition::stringId = "TE_GetSelectedVertexPosition";
+
+//==============================================================================
+// TEGetSelectedVertexPosition::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* TEGetSelectedVertexPosition::creator()
+{
+ return new TEGetSelectedVertexPosition();
+}
+
+//==============================================================================
+// TEGetSelectedVertexPosition::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus TEGetSelectedVertexPosition::doIt( const MArgList& args )
+{
+ MStatus status;
+ MDoubleArray returnVal( 3, 0 );
+
+ assert( args.length() == 1 ); //Only one arg.
+
+ MString argString;
+ args.get( 0, argString );
+
+ MSelectionList activeList;
+ MGlobal::getActiveSelectionList(activeList);
+
+ MItSelectionList iter( activeList, MFn::kMeshVertComponent, &status);
+
+ //We're only going to deal with the first selected item. Don't select more
+ //Than one please.
+
+ if ( !iter.isDone() )
+ {
+ MDagPath item;
+ MObject component;
+ iter.getDagPath( item, component );
+ // do something with it
+
+ MStatus isMeshIT;
+ MItMeshVertex mITVert( item , component, &isMeshIT );
+
+ if(isMeshIT == MS::kSuccess)
+ {
+ MPoint vertPos;
+ double x, y, z;
+
+ if ( argString == MString( "local" ) )
+ {
+ vertPos = mITVert.position( MSpace::kObject, &status );
+ x = vertPos[0];
+ y = vertPos[1];
+ z = vertPos[2];
+ }
+ else //"world"
+ {
+ vertPos = mITVert.position( MSpace::kWorld, &status );
+ x = vertPos[0];
+ y = vertPos[1];
+ z = vertPos[2];
+ }
+
+ returnVal[0] = x / TEConstants::Scale;
+ returnVal[1] = y / TEConstants::Scale;
+ returnVal[2] = z / TEConstants::Scale;
+
+ }
+
+ iter.next(); //This is to test if there are more verts than needed.
+ }
+ else
+ {
+ MExt::DisplayWarning("No vertices selected!");
+ }
+
+ if ( !iter.isDone() )
+ {
+ MExt::DisplayWarning("Too many vertices selected!");
+ }
+
+
+ MPxCommand::setResult( returnVal );
+
+ return MStatus::kSuccess;
+}
+
+
+//TEGetSelectedVertexIndex
+
+const char* TEGetSelectedVertexIndex::stringId = "TE_GetSelectedVertexIndex";
+
+//==============================================================================
+// TEGetSelectedVertexIndex::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* TEGetSelectedVertexIndex::creator()
+{
+ return new TEGetSelectedVertexIndex();
+}
+
+//==============================================================================
+// TEGetSelectedVertexIndex::doIt
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus TEGetSelectedVertexIndex::doIt( const MArgList& args )
+{
+ int returnVal = -1;
+
+ MStatus status;
+ MSelectionList activeList;
+ MGlobal::getActiveSelectionList(activeList);
+
+ MItSelectionList iter( activeList, MFn::kMeshVertComponent, &status);
+
+ //We're only going to deal with the first selected item. Don't select more
+ //Than one please.
+
+ if ( !iter.isDone() )
+ {
+ MDagPath item;
+ MObject component;
+ iter.getDagPath( item, component );
+ // do something with it
+
+ MStatus isMeshIT;
+ MItMeshVertex mITVert( item , component, &isMeshIT );
+
+ if(isMeshIT == MS::kSuccess)
+ {
+ returnVal = mITVert.index();
+ }
+
+ iter.next(); //This is to test if there are more verts than needed.
+ }
+ else
+ {
+ MExt::DisplayWarning("No vertices selected!");
+ }
+
+ if ( !iter.isDone() )
+ {
+ MExt::DisplayWarning("Too many vertices selected!");
+ }
+
+ MPxCommand::setResult( returnVal );
+
+ return MStatus::kSuccess;
+}
diff --git a/tools/trackeditor/code/commands/trackeditorcommands.h b/tools/trackeditor/code/commands/trackeditorcommands.h
new file mode 100644
index 0000000..990ffd7
--- /dev/null
+++ b/tools/trackeditor/code/commands/trackeditorcommands.h
@@ -0,0 +1,42 @@
+#include "precompiled/PCH.h"
+
+#ifndef TE_COMMANDS_H
+#define TE_COMMANDS_H
+
+class TEStateChangeCommand : public MPxCommand
+{
+public:
+ TEStateChangeCommand() {};
+ ~TEStateChangeCommand() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+class TEGetSelectedVertexPosition : public MPxCommand
+{
+public:
+ TEGetSelectedVertexPosition() {};
+ ~TEGetSelectedVertexPosition() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+class TEGetSelectedVertexIndex : public MPxCommand
+{
+public:
+ TEGetSelectedVertexIndex() {};
+ ~TEGetSelectedVertexIndex() {};
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+};
+
+#endif \ No newline at end of file
diff --git a/tools/trackeditor/code/commands/treelinecommand.cpp b/tools/trackeditor/code/commands/treelinecommand.cpp
new file mode 100644
index 0000000..25f22de
--- /dev/null
+++ b/tools/trackeditor/code/commands/treelinecommand.cpp
@@ -0,0 +1,323 @@
+//=============================================================================
+// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
+//
+// File: SnapSelectedTreelines.cpp
+//
+// Description: Implement SnapSelectedTreelines
+//
+// History: 27/05/2002 + Created -- Cary Brisebois
+//
+//=============================================================================
+
+//========================================
+// System Includes
+//========================================
+
+
+//========================================
+// Project Includes
+//========================================
+#include "commands/TreeLineCommand.h"
+#include "main/trackeditor.h"
+#include "nodes/treelineshapenode.h"
+
+//******************************************************************************
+//
+// Global Data, Local Data, Local Classes
+//
+//******************************************************************************
+const char* SnapSelectedTreelines::stringId = "TE_SnapSelectedTreelines";
+const char* ConvertTreelineToGeometry::stringId = "TE_ConvertTreelineToGeometry";
+const char* SetDeleteTreeline::stringId = "TE_SetDeleteTreeline";
+
+//******************************************************************************
+//
+// Public Member Functions
+//
+//******************************************************************************
+
+//==============================================================================
+// SnapSelectedTreelines::SnapSelectedTreelines
+//==============================================================================
+// Description: Constructor.
+//
+// Parameters: None.
+//
+// Return: N/A.
+//
+//==============================================================================
+SnapSelectedTreelines::SnapSelectedTreelines()
+{
+}
+
+//==============================================================================
+// SnapSelectedTreelines::~SnapSelectedTreelines
+//==============================================================================
+// Description: Destructor.
+//
+// Parameters: None.
+//
+// Return: N/A.
+//
+//==============================================================================
+SnapSelectedTreelines::~SnapSelectedTreelines()
+{
+}
+
+//=============================================================================
+// SnapSelectedTreelines::doIt
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//=============================================================================
+MStatus SnapSelectedTreelines::doIt( const MArgList& args )
+{
+ //For each treeline in the selection list, call
+
+ MSelectionList selectionList;
+ MGlobal::getActiveSelectionList( selectionList );
+
+ MItSelectionList itSel( selectionList );
+
+ while ( !itSel.isDone() )
+ {
+ MObject obj;
+ itSel.getDependNode( obj );
+
+ Recurse( obj );
+
+ itSel.next();
+ }
+
+ return MStatus::kSuccess;
+}
+
+//=============================================================================
+// SnapSelectedTreelines::Recurse
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ( MObject& obj )
+//
+// Return: void
+//
+//=============================================================================
+void SnapSelectedTreelines::Recurse( MObject& obj )
+{
+ MStatus status;
+
+ MFnTransform FnTransform( obj, &status );
+
+ if ( status )
+ {
+ //This is a transform...
+
+ MFnDagNode fnDagNode( obj );
+
+ unsigned int i;
+ for ( i = 0; i < fnDagNode.childCount(); ++i )
+ {
+ Recurse( fnDagNode.child( i ) );
+ }
+ }
+ else
+ {
+ MFnDependencyNode fnDepNode( obj );
+
+ if ( fnDepNode.typeId() == TETreeLine::TreelineShapeNode::id )
+ {
+ TETreeLine::TreelineShapeNode::SnapTreeline( obj );
+ }
+
+ }
+}
+
+//*****************************************************************************
+//
+// ConvertTreelineToGeometry
+//
+//*****************************************************************************
+
+//=============================================================================
+// ConvertTreelineToGeometry::ConvertTreelineToGeometry
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: ConvertTreelineToGeometry
+//
+//=============================================================================
+ConvertTreelineToGeometry::ConvertTreelineToGeometry()
+{
+}
+
+//=============================================================================
+// ConvertTreelineToGeometry::~ConvertTreelineToGeometry
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: ConvertTreelineToGeometry
+//
+//=============================================================================
+ConvertTreelineToGeometry::~ConvertTreelineToGeometry()
+{
+}
+
+//=============================================================================
+// ConvertTreelineToGeometry::doIt
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//=============================================================================
+MStatus ConvertTreelineToGeometry::doIt( const MArgList& args )
+{
+ //For each treeline in the world, call
+
+ MSelectionList selectionList;
+ selectionList.clear();
+
+ MItDag itDag( MItDag::kDepthFirst );
+
+ while ( !itDag.isDone() )
+ {
+ MDagPath dagPath;
+ itDag.getPath( dagPath );
+
+ selectionList.add( dagPath );
+
+ itDag.next();
+ }
+
+ if ( selectionList.length() > 0 )
+ {
+
+ MItSelectionList itSel( selectionList );
+
+ while ( !itSel.isDone() )
+ {
+ MObject obj;
+ itSel.getDependNode( obj );
+
+ Recurse( obj );
+
+ itSel.next();
+ }
+ }
+
+ return MStatus::kSuccess;
+}
+
+//=============================================================================
+// ConvertTreelineToGeometry::Recurse
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ( MObject& obj )
+//
+// Return: void
+//
+//=============================================================================
+void ConvertTreelineToGeometry::Recurse( MObject& obj )
+{
+ MStatus status;
+
+/*
+ MFnTransform FnTransform( obj, &status );
+
+ if ( status )
+ {
+ //This is a transform...
+
+ MFnDagNode fnDagNode( obj );
+
+ unsigned int i;
+ for ( i = 0; i < fnDagNode.childCount(); ++i )
+ {
+ Recurse( fnDagNode.child( i ) );
+ }
+ }
+ else
+ {
+*/
+ MFnDependencyNode fnDepNode( obj );
+
+ if ( fnDepNode.typeId() == TETreeLine::TreelineShapeNode::id )
+ {
+ TETreeLine::TreelineShapeNode::ConvertToGeometry( obj );
+ }
+
+// }
+}
+
+//*****************************************************************************
+//
+// SetDeleteTreeline
+//
+//*****************************************************************************
+
+//=============================================================================
+// SetDeleteTreeline::SetDeleteTreeline
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: SetDeleteTreeline
+//
+//=============================================================================
+SetDeleteTreeline::SetDeleteTreeline()
+{
+}
+
+//=============================================================================
+// SetDeleteTreeline::~SetDeleteTreeline
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: SetDeleteTreeline
+//
+//=============================================================================
+SetDeleteTreeline::~SetDeleteTreeline()
+{
+}
+
+//=============================================================================
+// SetDeleteTreeline::doIt
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//=============================================================================
+MStatus SetDeleteTreeline::doIt( const MArgList& args )
+{
+ assert( args.length() == 1 );
+
+ bool del;
+ args.get( 0, del );
+
+ TrackEditor::SetDeleteTreelines( del );
+
+ return MStatus::kSuccess;
+}
+
+//******************************************************************************
+//
+// Private Member Functions
+//
+//******************************************************************************
diff --git a/tools/trackeditor/code/commands/treelinecommand.h b/tools/trackeditor/code/commands/treelinecommand.h
new file mode 100644
index 0000000..1e556b6
--- /dev/null
+++ b/tools/trackeditor/code/commands/treelinecommand.h
@@ -0,0 +1,136 @@
+//=============================================================================
+// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
+//
+// File: tetreelinecommand.h
+//
+// Description: Blahblahblah
+//
+// History: 27/05/2002 + Created -- Cary Brisebois
+//
+//=============================================================================
+
+#ifndef TETREELINECOMMAND_H
+#define TETREELINECOMMAND_H
+
+//========================================
+// Nested Includes
+//========================================
+#include "precompiled/PCH.h"
+
+//========================================
+// Forward References
+//========================================
+
+//=============================================================================
+//
+// Synopsis: Blahblahblah
+//
+//=============================================================================
+
+class SnapSelectedTreelines : public MPxCommand
+{
+public:
+ SnapSelectedTreelines();
+ virtual ~SnapSelectedTreelines();
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+
+private:
+
+ void Recurse( MObject& obj );
+
+ //Prevent wasteful constructor creation.
+ SnapSelectedTreelines( const SnapSelectedTreelines& tetreelinecommand );
+ SnapSelectedTreelines& operator=( const SnapSelectedTreelines& tetreelinecommand );
+};
+
+class ConvertTreelineToGeometry : public MPxCommand
+{
+public:
+ ConvertTreelineToGeometry();
+ ~ConvertTreelineToGeometry();
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+
+private:
+ void Recurse( MObject& obj );
+
+ //Prevent wasteful constructor creation.
+ ConvertTreelineToGeometry( const ConvertTreelineToGeometry& tetreelinecommand );
+ ConvertTreelineToGeometry& operator=( const ConvertTreelineToGeometry& tetreelinecommand );
+};
+
+class SetDeleteTreeline : public MPxCommand
+{
+public:
+ SetDeleteTreeline();
+ ~SetDeleteTreeline();
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+
+ static const char* stringId;
+
+private:
+
+ //Prevent wasteful constructor creation.
+ SetDeleteTreeline( const SetDeleteTreeline& tetreelinecommand );
+ SetDeleteTreeline& operator=( const SetDeleteTreeline& tetreelinecommand );
+};
+//******************************************************************************
+//
+// Inline Public Functions
+//
+//******************************************************************************
+
+//=============================================================================
+// SnapSelectedTreelines::creator
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//=============================================================================
+inline void* SnapSelectedTreelines::creator()
+{
+ return new SnapSelectedTreelines();
+}
+
+//=============================================================================
+// ConvertTreelineToGeometry::creator
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//=============================================================================
+inline void* ConvertTreelineToGeometry::creator()
+{
+ return new ConvertTreelineToGeometry();
+}
+
+//=============================================================================
+// SetDeleteTreeline::creator
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//=============================================================================
+inline void* SetDeleteTreeline::creator()
+{
+ return new SetDeleteTreeline();
+}
+#endif //TETREELINECOMMAND_H