summaryrefslogtreecommitdiffstats
path: root/tools/objectsnapper/code
diff options
context:
space:
mode:
authorSvxy <aidan61605@gmail.com>2023-05-31 23:31:32 +0200
committerSvxy <aidan61605@gmail.com>2023-05-31 23:31:32 +0200
commiteb4b3404aa00220d659e532151dab13d642c17a3 (patch)
tree7e1107c4995489a26c4007e41b53ea8d00ab2134 /tools/objectsnapper/code
downloadThe-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar.gz
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar.bz2
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar.lz
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar.xz
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.tar.zst
The-Simpsons-Hit-and-Run-eb4b3404aa00220d659e532151dab13d642c17a3.zip
Diffstat (limited to 'tools/objectsnapper/code')
-rw-r--r--tools/objectsnapper/code/commands/snapselected.cpp435
-rw-r--r--tools/objectsnapper/code/commands/snapselected.h59
-rw-r--r--tools/objectsnapper/code/main/mayaincludes.h49
-rw-r--r--tools/objectsnapper/code/main/pluginMain.cpp76
-rw-r--r--tools/objectsnapper/code/main/pluginMain.h40
-rw-r--r--tools/objectsnapper/code/main/stdafx.h19
-rw-r--r--tools/objectsnapper/code/precompiled/PCH.cpp1
-rw-r--r--tools/objectsnapper/code/precompiled/PCH.h50
-rw-r--r--tools/objectsnapper/code/scripts/os_cleanup.mel3
-rw-r--r--tools/objectsnapper/code/scripts/os_main.mel228
10 files changed, 960 insertions, 0 deletions
diff --git a/tools/objectsnapper/code/commands/snapselected.cpp b/tools/objectsnapper/code/commands/snapselected.cpp
new file mode 100644
index 0000000..e6ab048
--- /dev/null
+++ b/tools/objectsnapper/code/commands/snapselected.cpp
@@ -0,0 +1,435 @@
+//=============================================================================
+// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
+//
+// File:
+//
+// Description: Implement SnapSelectedCmd
+//
+// History: 18/03/2002 + Created -- Cary Brisebois
+//
+//=============================================================================
+
+//========================================
+// System Includes
+//========================================
+// Foundation Tech
+
+//========================================
+// Project Includes
+//========================================
+#include "snapselected.h"
+#include "utility/MUI.h"
+#include "utility/mext.h"
+
+
+//******************************************************************************
+//
+// Global Data, Local Data, Local Classes
+//
+//******************************************************************************
+
+const char* SnapSelectedCmd::stringId = "OS_SnapSelected";
+const double OSScale = 100.0;
+
+enum SnapType
+{
+ ALL,
+ SINGLE,
+ TREELINE
+};
+
+//******************************************************************************
+//
+// Public Member Functions
+//
+//******************************************************************************
+
+//==============================================================================
+// SnapSelectedCmd::SnapSelectedCmd
+//==============================================================================
+// Description: Constructor.
+//
+// Parameters: None.
+//
+// Return: N/A.
+//
+//==============================================================================
+SnapSelectedCmd::SnapSelectedCmd()
+{
+ mObjDagPaths.clear();
+ mNewPositions.clear();
+ mOldPositions.clear();
+}
+
+//==============================================================================
+// SnapSelectedCmd::~SnapSelectedCmd
+//==============================================================================
+// Description: Destructor.
+//
+// Parameters: None.
+//
+// Return: N/A.
+//
+//==============================================================================
+SnapSelectedCmd::~SnapSelectedCmd()
+{
+}
+
+//==============================================================================
+// SnapSelectedCmd::creator
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: void
+//
+//==============================================================================
+void* SnapSelectedCmd::creator()
+{
+ return new SnapSelectedCmd();
+}
+
+//==============================================================================
+// SnapSelectedCmd::doit
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( const MArgList& args )
+//
+// Return: MStatus
+//
+//==============================================================================
+MStatus SnapSelectedCmd::doIt( const MArgList& args )
+{
+ if ( !MUI::ConfirmDialog( "Are you sure you want to snap these objects?\nYou can not UNDO this command." ) == MUI::YES )
+ {
+ //quit.
+ return MStatus::kSuccess;
+ }
+
+ assert( args.length() == 2 );
+
+ double OFFSET = 0;
+ int snapType = ALL;
+
+ args.get( 0, OFFSET );
+ args.get( 1, snapType );
+
+ OFFSET *= OSScale;
+
+ MSelectionList list;
+ MGlobal::getActiveSelectionList( list );
+
+ MItSelectionList i( list );
+
+ MFnDagNode fnDagNode;
+ MDagPath dagPath;
+ MItDag itDag;
+ MObject obj;
+ MDagPath objDagPath;
+ MObject childObj;
+
+ //For all selected objects.
+ for ( ; !i.isDone(); i.next() )
+ {
+ i.getDagPath( dagPath );
+
+ itDag.reset( dagPath, MItDag::kBreadthFirst, MFn::kTransform );
+
+ for ( ; !itDag.isDone() && itDag.depth() < 2; itDag.next() )
+ {
+ obj = itDag.item();
+ fnDagNode.setObject( obj );
+
+ const char* objName = fnDagNode.name().asChar();
+ const char* objTypeName = fnDagNode.typeName().asChar();
+
+ int childCount = fnDagNode.childCount();
+
+ int whichChild;
+
+ for ( whichChild = 0; whichChild < childCount; ++whichChild )
+ {
+ childObj = fnDagNode.child( whichChild );
+ fnDagNode.setObject( childObj );
+
+ const char* childObjName = fnDagNode.name().asChar();
+ const char* childObjTypeName = fnDagNode.typeName().asChar();
+
+ //Find a mesh below me and move my pivot to the intersection.
+ itDag.getPath( objDagPath );
+ MFnTransform fnTrans( objDagPath );
+
+ //Get all the child meshes of this obj node to prevent snapping to
+ //something that is part of me.
+
+ MStringArray meshNames;
+
+ GetChildMeshNames( objDagPath, meshNames );
+
+
+ MVector pos = fnTrans.translation( MSpace::kWorld );
+ MPoint rotate = fnTrans.rotatePivot( MSpace::kWorld );
+ MVector rayDir( 0, -1.0, 0 );
+
+ MItDag meshIt( MItDag::kDepthFirst, MFn::kMesh );
+ MDagPath meshDagPath;
+ MPointArray intersectPoints;
+
+ bool found = false;
+
+ for ( ; !meshIt.isDone(); meshIt.next() )
+ {
+ meshIt.getPath( meshDagPath );
+ MFnMesh mesh( meshDagPath );
+
+ const char* meshName = mesh.name().asChar();
+
+ unsigned int i;
+ bool nameFound = false;
+ for ( i = 0; i < meshNames.length(); ++i )
+ {
+ if ( meshNames[i] == mesh.name() )
+ {
+ nameFound = true;
+ break;
+ }
+ }
+
+ if ( nameFound )
+ {
+ continue;
+ }
+
+ if ( snapType == TREELINE )
+ {
+
+ }
+ else
+ {
+ mesh.intersect( rotate, rayDir, intersectPoints, 0.001f, MSpace::kWorld );
+
+ if ( intersectPoints.length() > 0 )
+ {
+ MVector diff( intersectPoints[ 0 ] - rotate );
+ diff.y += OFFSET;
+
+ //Prepare the command for the redo it ( which does all the work )
+ mObjDagPaths.append( fnTrans.dagPath() );
+ mNewPositions.append( diff );
+
+ //Save the old position.
+ MVector vector = fnTrans.translation( MSpace::kObject );
+ mOldPositions.append( vector );
+
+// //Move the transform.
+// fnTrans.translateBy( diff, MSpace::kWorld );
+
+ found = true;
+
+ break;
+ }
+ }
+ }
+
+ if ( !found )
+ {
+ //Look up
+ MPoint rotate = fnTrans.rotatePivot( MSpace::kWorld );
+ MVector rayDir( 0, 1.0, 0 );
+
+ MItDag meshIt( MItDag::kDepthFirst, MFn::kMesh );
+ MDagPath meshDagPath;
+ MPointArray intersectPoints;
+
+ for ( ; !meshIt.isDone(); meshIt.next() )
+ {
+ meshIt.getPath( meshDagPath );
+ MFnMesh mesh( meshDagPath );
+
+ const char* meshName = mesh.name().asChar();
+
+ unsigned int i;
+ bool nameFound = false;
+ for ( i = 0; i < meshNames.length(); ++i )
+ {
+ if ( meshNames[i] == mesh.name() )
+ {
+ nameFound = true;
+ break;
+ }
+ }
+
+ if ( nameFound )
+ {
+ continue;
+ }
+
+ if ( snapType == TREELINE )
+ {
+
+ }
+ else
+ {
+ mesh.intersect( rotate, rayDir, intersectPoints, 0.001f, MSpace::kWorld );
+
+ if ( intersectPoints.length() > 0 )
+ {
+ MVector diff( intersectPoints[ 0 ] - rotate );
+ diff.y -= OFFSET;
+
+ //Prepare the command for the redo it ( which does all the work )
+ mObjDagPaths.append( fnTrans.dagPath() );
+ mNewPositions.append( diff );
+
+ //Save the old position.
+ MVector vector = fnTrans.translation( MSpace::kObject );
+ mOldPositions.append( vector );
+
+// //Move the transform.
+// fnTrans.translateBy( diff, MSpace::kWorld );
+
+ found = true;
+
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !found )
+ {
+ MString errorMsg( "The object: " );
+ errorMsg += fnTrans.name();
+ errorMsg += MString( " has no mesh below it.\nNo snapping done on it." );
+
+ MUI::InfoDialog( errorMsg.asChar() );
+ }
+ }
+
+ if ( snapType == SINGLE )
+ {
+ //No more iterations.
+ break;
+ }
+ }
+ }
+
+ redoIt();
+
+ return MStatus::kSuccess;
+}
+
+//=============================================================================
+// SnapSelectedCmd::undoIt
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: MStatus
+//
+//=============================================================================
+MStatus SnapSelectedCmd::undoIt()
+{
+ unsigned int i;
+ for ( i = 0; i < mObjDagPaths.length(); ++i )
+ {
+ if ( mObjDagPaths[i].isValid() )
+ {
+ //Move this guy to the new position.
+ MFnTransform fnTransform( mObjDagPaths[i] );
+
+ fnTransform.setTranslation( mOldPositions[i], MSpace::kObject );
+ }
+ else
+ {
+ MExt::DisplayError( "Error performing snap due to invalid object or change in heirarchy" );
+ }
+ }
+
+ return MStatus::kSuccess;
+}
+
+//=============================================================================
+// SnapSelectedCmd::redoIt
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: MStatus
+//
+//=============================================================================
+MStatus SnapSelectedCmd::redoIt()
+{
+ unsigned int i;
+ for ( i = 0; i < mObjDagPaths.length(); ++i )
+ {
+ if ( mObjDagPaths[i].isValid() )
+ {
+ //Move this guy to the new position.
+ MFnTransform fnTransform( mObjDagPaths[i] );
+
+ fnTransform.translateBy( mNewPositions[i], MSpace::kWorld );
+ }
+ else
+ {
+ MExt::DisplayError( "Error performing snap due to invalid object or change in heirarchy" );
+ }
+ }
+
+ return MStatus::kSuccess;
+}
+
+//=============================================================================
+// SnapSelectedCmd::isUndoable
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: bool
+//
+//=============================================================================
+bool SnapSelectedCmd::isUndoable() const
+{
+ return true;
+}
+
+//******************************************************************************
+//
+// Private Member Functions
+//
+//******************************************************************************
+
+//==============================================================================
+// SnapSelectedCmd::GetChildMeshNames
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ( MDagPath objDagPath, MStringArray& names )
+//
+// Return: void
+//
+//==============================================================================
+void SnapSelectedCmd::GetChildMeshNames( MDagPath objDagPath, MStringArray& names )
+{
+ names.clear();
+
+ MItDag itDag;
+ itDag.reset( objDagPath, MItDag::kDepthFirst, MFn::kMesh );
+
+ for ( ; !itDag.isDone(); itDag.next() )
+ {
+ MDagPath dagPath;
+ itDag.getPath( dagPath );
+ MFnMesh fnMesh( dagPath );
+
+ names.append( fnMesh.name() );
+
+ const char* meshName = fnMesh.name().asChar();
+ }
+
+}
diff --git a/tools/objectsnapper/code/commands/snapselected.h b/tools/objectsnapper/code/commands/snapselected.h
new file mode 100644
index 0000000..55e0f0d
--- /dev/null
+++ b/tools/objectsnapper/code/commands/snapselected.h
@@ -0,0 +1,59 @@
+//=============================================================================
+// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
+//
+// File: snapselectedcmd.h
+//
+// Description: Blahblahblah
+//
+// History: 18/03/2002 + Created -- Cary Brisebois
+//
+//=============================================================================
+
+#ifndef SNAPSELECTEDCMD_H
+#define SNAPSELECTEDCMD_H
+
+//========================================
+// Nested Includes
+//========================================
+#include "main/mayaincludes.h"
+#include "precompiled/PCH.h"
+
+//========================================
+// Forward References
+//========================================
+
+//=============================================================================
+//
+// Synopsis: Blahblahblah
+//
+//=============================================================================
+
+class SnapSelectedCmd : public MPxCommand
+{
+public:
+ SnapSelectedCmd();
+ virtual ~SnapSelectedCmd();
+
+ static void* creator();
+ virtual MStatus doIt( const MArgList& args );
+ virtual MStatus undoIt();
+ virtual MStatus redoIt();
+ virtual bool isUndoable() const;
+
+ static const char* stringId;
+
+private:
+
+ MDagPathArray mObjDagPaths;
+ MVectorArray mOldPositions;
+ MVectorArray mNewPositions;
+
+ void GetChildMeshNames( MDagPath objDagPath, MStringArray& names );
+
+ //Prevent wasteful constructor creation.
+SnapSelectedCmd( const SnapSelectedCmd& snapselectedcmd );
+SnapSelectedCmd& operator=( const SnapSelectedCmd& snapselectedcmd );
+};
+
+#endif //SNAPSELECTEDCMD_H
+
diff --git a/tools/objectsnapper/code/main/mayaincludes.h b/tools/objectsnapper/code/main/mayaincludes.h
new file mode 100644
index 0000000..5f91009
--- /dev/null
+++ b/tools/objectsnapper/code/main/mayaincludes.h
@@ -0,0 +1,49 @@
+#include <maya/M3dView.h>
+#include <maya/MArgList.h>
+#include <maya/MCursor.h>
+#include <maya/MDagPath.h>
+#include <maya/MDGMessage.h>
+#include <maya/MDGModifier.h>
+#include <maya/MDoubleArray.h>
+#include <maya/MEulerRotation.h>
+#include <maya/MFnData.h>
+#include <maya/MFnDagNode.h>
+#include <maya/MFnDependencyNode.h>
+#include <maya/MFnDoubleArrayData.h>
+#include <maya/MFnIkJoint.h>
+#include <maya/MFnIntArrayData.h>
+#include <maya/MFnMatrixData.h>
+#include <maya/MFnMesh.h>
+#include <maya/MFnMessageAttribute.h>
+#include <maya/MFnNumericAttribute.h>
+#include <maya/MFnStringArrayData.h>
+#include <maya/MFnTransform.h>
+#include <maya/MFnTypedAttribute.h>
+#include <maya/MGlobal.h>
+#include <maya/MIntArray.h>
+#include <maya/MItDag.h>
+#include <maya/MItMeshVertex.h>
+#include <maya/MItSelectionList.h>
+#include <maya/MMatrix.h>
+#include <maya/MNodeMessage.h>
+#include <maya/MObject.h>
+#include <maya/MObjectArray.h>
+#include <maya/MPlug.h>
+#include <maya/MPlugArray.h>
+#include <maya/MPoint.h>
+#include <maya/MPointArray.h>
+#include <maya/MPxCommand.h>
+#include <maya/MPxContext.h>
+#include <maya/MPxContextCommand.h>
+#include <maya/MPxLocatorNode.h>
+#include <maya/MQuaternion.h>
+#include <maya/MSelectionList.h>
+#include <maya/MStatus.h>
+#include <maya/MString.h>
+#include <maya/MStringArray.h>
+#include <maya/MTransformationMatrix.h>
+#include <maya/MTypeId.h>
+#include <maya/MUiMessage.h>
+#include <maya/MVector.h>
+
+#include <assert.h> \ No newline at end of file
diff --git a/tools/objectsnapper/code/main/pluginMain.cpp b/tools/objectsnapper/code/main/pluginMain.cpp
new file mode 100644
index 0000000..0e38b04
--- /dev/null
+++ b/tools/objectsnapper/code/main/pluginMain.cpp
@@ -0,0 +1,76 @@
+//
+// Copyright (C) 2002 Radical Entertainment
+//
+// File: pluginMain.cpp
+//
+// Author: Maya SDK Wizard
+//
+#include <maya/MFnPlugin.h>
+
+#include "utility/mayahandles.h"
+
+#include "pluginmain.h"
+#include "commands/snapselected.h"
+
+MStatus initializePlugin( MObject obj )
+//
+// Description:
+// this method is called when the plug-in is loaded into Maya. It
+// registers all of the services that this plug-in provides with
+// Maya.
+//
+// Arguments:
+// obj - a handle to the plug-in object (use MFnPlugin to access it)
+//
+{
+ MStatus status;
+
+ MayaHandles::SetHInstance( (void*)(MhInstPlugin) );
+
+ MFnPlugin plugin( obj, "Radical Entertainment", "4.0.1", "Any");
+
+ // Add plug-in feature registration here
+ //
+
+ //Register Nodes
+
+ //Register Contexts
+
+ //Register Commands
+ REGISTER_COMMAND( plugin, SnapSelectedCmd );
+
+
+ //Run any startup scripts.
+ MGlobal::sourceFile( "os_main.mel" );
+
+ return status;
+}
+
+MStatus uninitializePlugin( MObject obj )
+//
+// Description:
+// this method is called when the plug-in is unloaded from Maya. It
+// deregisters all of the services that it was providing.
+//
+// Arguments:
+// obj - a handle to the plug-in object (use MFnPlugin to access it)
+//
+{
+ MStatus status;
+ MFnPlugin plugin( obj );
+
+ // Add plug-in feature deregistration here
+ //
+
+ //Run any cleanup scripts.
+ MGlobal::sourceFile( "os_cleanup.mel" );
+
+ //Unregister Commands
+
+ //Unregister Contexts
+
+ //Unregister Nodes
+
+ return status;
+}
+
diff --git a/tools/objectsnapper/code/main/pluginMain.h b/tools/objectsnapper/code/main/pluginMain.h
new file mode 100644
index 0000000..502f6fb
--- /dev/null
+++ b/tools/objectsnapper/code/main/pluginMain.h
@@ -0,0 +1,40 @@
+#include "mayaincludes.h"
+
+//----------------------------------------
+// MACROS
+//----------------------------------------
+
+#define REGISTER_COMMAND( p, c ) if ( ! ( ( p ).registerCommand( c##::stringId, \
+ c##::creator ) \
+ ) \
+ ) return MS::kFailure
+
+#define REGISTER_CONTEXT( p, c ) if ( ! ( ( p ).registerContextCommand( c##::stringId, \
+ c##Cmd::creator ) \
+ ) \
+ ) return MS::kFailure
+
+
+#define REGISTER_LOCATOR( p, n ) if ( ! ( ( p ).registerNode( n##::stringId, \
+ n##::id, \
+ n##::creator, \
+ n##::initialize, \
+ MPxNode::kLocatorNode ) \
+ ) \
+ ) return MS::kFailure
+
+#define REGISTER_NODE( p, n ) if ( ! ( ( p ).registerNode( n##::stringId, \
+ n##::id, \
+ n##::creator, \
+ n##::initialize ) \
+ ) \
+ ) return MS::kFailure
+
+#define DEREGISTER_COMMAND( p, c ) ( p ).deregisterCommand( c##::stringId )
+
+#define DEREGISTER_CONTEXT( p, c ) ( p ).deregisterContextCommand( c##::stringId )
+
+//#define DEREGISTER_NODE( p, n ) n##::Unload();\
+// ( p ).deregisterNode( n##::id )
+
+#define DEREGISTER_NODE( p, n ) ( p ).deregisterNode( n##::id )
diff --git a/tools/objectsnapper/code/main/stdafx.h b/tools/objectsnapper/code/main/stdafx.h
new file mode 100644
index 0000000..3152a3f
--- /dev/null
+++ b/tools/objectsnapper/code/main/stdafx.h
@@ -0,0 +1,19 @@
+#ifndef STDAFX
+#define STDAFX
+
+//-----------------------------------------------------------------------------
+// Copyright (C) 2001 Radical Entertainment Ltd. All rights reserved.
+//
+// stdafx.h
+//
+// Description: Header wrapper for using MFC.
+//
+// Modification History:
+// + Created Oct 12, 2001 -- bkusy
+//-----------------------------------------------------------------------------
+#define VC_EXTRALEAN
+#include <afxwin.h>
+#include <afxdlgs.h>
+
+
+#endif \ No newline at end of file
diff --git a/tools/objectsnapper/code/precompiled/PCH.cpp b/tools/objectsnapper/code/precompiled/PCH.cpp
new file mode 100644
index 0000000..5f77b4a
--- /dev/null
+++ b/tools/objectsnapper/code/precompiled/PCH.cpp
@@ -0,0 +1 @@
+#include "PCH.h" \ No newline at end of file
diff --git a/tools/objectsnapper/code/precompiled/PCH.h b/tools/objectsnapper/code/precompiled/PCH.h
new file mode 100644
index 0000000..c14ca45
--- /dev/null
+++ b/tools/objectsnapper/code/precompiled/PCH.h
@@ -0,0 +1,50 @@
+#include <maya/M3dView.h>
+#include <maya/MArgList.h>
+#include <maya/MCursor.h>
+#include <maya/MDagPath.h>
+#include <maya/MDagPathArray.h>
+#include <maya/MDGMessage.h>
+#include <maya/MDGModifier.h>
+#include <maya/MDoubleArray.h>
+#include <maya/MEulerRotation.h>
+#include <maya/MFnData.h>
+#include <maya/MFnDagNode.h>
+#include <maya/MFnDependencyNode.h>
+#include <maya/MFnDoubleArrayData.h>
+#include <maya/MFnIkJoint.h>
+#include <maya/MFnIntArrayData.h>
+#include <maya/MFnMatrixData.h>
+#include <maya/MFnMesh.h>
+#include <maya/MFnMessageAttribute.h>
+#include <maya/MFnNumericAttribute.h>
+#include <maya/MFnStringArrayData.h>
+#include <maya/MFnTransform.h>
+#include <maya/MFnTypedAttribute.h>
+#include <maya/MGlobal.h>
+#include <maya/MIntArray.h>
+#include <maya/MItDag.h>
+#include <maya/MItMeshVertex.h>
+#include <maya/MItSelectionList.h>
+#include <maya/MMatrix.h>
+#include <maya/MNodeMessage.h>
+#include <maya/MObject.h>
+#include <maya/MObjectArray.h>
+#include <maya/MPlug.h>
+#include <maya/MPlugArray.h>
+#include <maya/MPoint.h>
+#include <maya/MPointArray.h>
+#include <maya/MPxCommand.h>
+#include <maya/MPxContext.h>
+#include <maya/MPxContextCommand.h>
+#include <maya/MPxLocatorNode.h>
+#include <maya/MQuaternion.h>
+#include <maya/MSelectionList.h>
+#include <maya/MStatus.h>
+#include <maya/MString.h>
+#include <maya/MStringArray.h>
+#include <maya/MTransformationMatrix.h>
+#include <maya/MTypeId.h>
+#include <maya/MUiMessage.h>
+#include <maya/MVector.h>
+
+#include <assert.h> \ No newline at end of file
diff --git a/tools/objectsnapper/code/scripts/os_cleanup.mel b/tools/objectsnapper/code/scripts/os_cleanup.mel
new file mode 100644
index 0000000..020de04
--- /dev/null
+++ b/tools/objectsnapper/code/scripts/os_cleanup.mel
@@ -0,0 +1,3 @@
+
+
+os_RemoveUI(); \ No newline at end of file
diff --git a/tools/objectsnapper/code/scripts/os_main.mel b/tools/objectsnapper/code/scripts/os_main.mel
new file mode 100644
index 0000000..7a8c567
--- /dev/null
+++ b/tools/objectsnapper/code/scripts/os_main.mel
@@ -0,0 +1,228 @@
+//-----------------------------------------------------------------------------
+// Copyright (C) 2001 Radical Entertainment Ltd. All rights reserved.
+//
+// TE_main.mel
+//
+// Description: Installs the Object Snapper (OS) interface.
+// As a convention all Object Snapper global procedures
+// and global variables are prefixed with "os_". All commands
+// exposed through OS plugins are prefixed with "OS_".
+//
+// MCB = Menu Call Back
+// BCB = Button Call Back
+//
+// Modification History:
+// + Created March 18 2002 -- Cary Brisebois
+//-----------------------------------------------------------------------------
+
+
+global float $gOS_Offset = 0.10;
+
+
+//-----------------------------------------------------------------------------
+// o s _ b r e a k p o i n t
+//
+// Synopsis:
+//
+// Parameters: NONE
+//
+// Returns: NOTHING
+//
+// Constraints: NONE
+//
+//-----------------------------------------------------------------------------
+global proc os_breakpoint( string $tag )
+{
+ confirmDialog -m ( "BreakPoint: " + $tag );
+}
+
+//-----------------------------------------------------------------------------
+// o s _ M C B _ A b o u t
+//
+// Synopsis: Display an About Object Snapper window.
+//
+// Parameters: NONE
+//
+// Returns: NOTHING
+//
+// Constraints: NONE
+//
+//-----------------------------------------------------------------------------
+global proc os_MCB_About()
+{
+ string $pluginVersion = "1.0";
+
+ string $message = ( "\nSimpsons Road Rage Object Snapper.\n\n" +
+ "Release " + $pluginVersion + "\n" +
+ "(c) 2001, Radical Entertainment, Ltd.\n\n" );
+
+
+ confirmDialog -title "About Object Snapper"
+ -message $message
+ -button "OK"
+ -defaultButton "OK";
+}
+
+//-----------------------------------------------------------------------------
+// o s _ d o M a i n M e n u I t e m s
+//
+// Synopsis: Creates the OS menu on the menu handle passed in.
+//
+// Parameters: NONE
+//
+// Returns: NOTHING
+//
+// Constraints: NONE
+//
+//-----------------------------------------------------------------------------
+global proc os_doMainMenuItems( string $menu )
+{
+ menu -edit -tearOff true -allowOptionBoxes true $menu;
+
+ menuItem -label "Snap Single Selected" -command ( "os_MCB_SnapSingleSelected()" );
+
+ menuItem -divider true;
+
+ menuItem -label "Snap All Selected" -command ( "os_MCB_SnapSelected()" );
+
+ menuItem -divider true;
+
+ menuItem -label "Snap Tree Line" -command ( "os_MCB_SnapTreeLine()" );
+
+ menuItem -divider true;
+
+ menuItem -label "About" -command "os_MCB_About()";
+
+ menuItem -optionBox true -command "os_MCB_OSOptions()";
+
+ setParent -m ..;
+}
+
+//-----------------------------------------------------------------------------
+// o s _ I n s t a l l U I
+//
+// Synopsis:
+//
+// Parameters: NONE
+//
+// Returns: NOTHING
+//
+// Constraints: NONE
+//
+//-----------------------------------------------------------------------------
+global proc os_InstallUI()
+{
+
+ global string $gMainWindow;
+
+ //
+ // Install OS menu as a root menu.
+ //
+ if ( `menu -exists os_MainMenu` ) deleteUI os_MainMenu;
+ menu -label "Object Snapper" -allowOptionBoxes true -parent $gMainWindow os_MainMenu;
+
+ os_doMainMenuItems "os_MainMenu";
+}
+
+//==============================================================================
+// global proc os_RemoveUI
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: global
+//
+//==============================================================================
+global proc os_RemoveUI()
+{
+ if ( `menu -exists os_MainMenu` ) deleteUI os_MainMenu;
+ if ( `window -exists os_OptionWindow` ) deleteUI os_OptionWindow;
+}
+
+//==============================================================================
+// global proc os_MCB_SnapSelected
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: global
+//
+//==============================================================================
+global proc os_MCB_SnapSelected()
+{
+ global float $gOS_Offset;
+
+ OS_SnapSelected( $gOS_Offset, 0 );
+}
+
+
+//==============================================================================
+// global proc os_MCB_SnapSingleSelected
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: global
+//
+//==============================================================================
+global proc os_MCB_SnapSingleSelected()
+{
+ global float $gOS_Offset;
+
+ OS_SnapSelected( $gOS_Offset, 1 );
+}
+
+//=============================================================================
+// global proc os_MCB_SnapTreeLine
+//=============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: global
+//
+//=============================================================================
+global proc os_MCB_SnapTreeLine()
+{
+ global float $gOS_Offset;
+
+ OS_SnapSelected( $gOS_Offset, 2 );
+}
+
+//==============================================================================
+// global proc os_MCB_OSOptions
+//==============================================================================
+// Description: Comment
+//
+// Parameters: ()
+//
+// Return: global
+//
+//==============================================================================
+global proc os_MCB_OSOptions()
+{
+ global float $gOS_Offset;
+
+ if ( `window -exists os_OptionWindow` ) deleteUI os_OptionWindow;
+
+ window -title "Object Snapper Options" os_OptionWindow;
+
+ columnLayout;
+
+ rowLayout -nc 2;
+
+ text -label "Offset (M):";
+
+ floatField -min -10.0 -max 10.0 -value $gOS_Offset -cc ("$gOS_Offset = #1");
+
+ setParent ..;
+
+ setParent ..;
+
+ showWindow;
+}
+
+evalDeferred "os_InstallUI"; \ No newline at end of file