aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/maya
diff options
context:
space:
mode:
authorJørgen P. Tjernø <[email protected]>2013-12-02 19:31:46 -0800
committerJørgen P. Tjernø <[email protected]>2013-12-02 19:46:31 -0800
commitf56bb35301836e56582a575a75864392a0177875 (patch)
treede61ddd39de3e7df52759711950b4c288592f0dc /mp/src/public/maya
parentMark some more files as text. (diff)
downloadsource-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz
source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/public/maya')
-rw-r--r--mp/src/public/maya/IMayaVGui.h134
-rw-r--r--mp/src/public/maya/VsMayaDmx.h58
-rw-r--r--mp/src/public/maya/VsMayaMPxFactory.h2238
-rw-r--r--mp/src/public/maya/VsVGuiWindow.h390
-rw-r--r--mp/src/public/maya/valveMaya.h1344
5 files changed, 2082 insertions, 2082 deletions
diff --git a/mp/src/public/maya/IMayaVGui.h b/mp/src/public/maya/IMayaVGui.h
index 7c0d77f6..eda8f255 100644
--- a/mp/src/public/maya/IMayaVGui.h
+++ b/mp/src/public/maya/IMayaVGui.h
@@ -1,67 +1,67 @@
-//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
-//
-// Purpose: Interface for dealing with vgui focus issues across all plugins
-//
-// $NoKeywords: $
-//===========================================================================//
-
-#ifndef IMAYAVGUI_H
-#define IMAYAVGUI_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "tier0/platform.h"
-#include "appframework/iappsystem.h"
-#include "vgui_controls/Frame.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-namespace vgui
-{
- class EditablePanel;
-}
-
-class CVsVGuiWindowBase;
-
-
-//-----------------------------------------------------------------------------
-// Factory for creating vgui windows
-//-----------------------------------------------------------------------------
-abstract_class IMayaVguiWindowFactory
-{
-public:
- virtual void CreateVguiWindow( const char *pPanelName ) = 0;
- virtual void DestroyVguiWindow( const char *pPanelName ) = 0;
- virtual vgui::Frame *GetVGuiPanel( const char *pPanelName = NULL ) = 0;
- virtual CVsVGuiWindowBase *GetVGuiWindow( const char *pPanelName = NULL ) = 0;
-};
-
-
-//-----------------------------------------------------------------------------
-// Interface for dealing with vgui focus issues across all plugins
-//-----------------------------------------------------------------------------
-#define MAYA_VGUI_INTERFACE_VERSION "VMayaVGui001"
-abstract_class IMayaVGui : public IAppSystem
-{
-public:
- virtual void InstallVguiWindowFactory( const char *pWindowTypeName, IMayaVguiWindowFactory *pFactory ) = 0;
- virtual void RemoveVguiWindowFactory( const char *pWindowTypeName, IMayaVguiWindowFactory *pFactory ) = 0;
- virtual void SetFocus( void *hWnd, int hVGuiContext ) = 0;
- virtual bool HasFocus( void *hWnd ) = 0;
-
- // In this mode, maya's in a strange re-entrant mode waiting for a modal dialog
- // We still get WM_PAINT messages, but we're in the middle of a callstack
- // deep in the bowels of VGUI
- virtual void SetModalMode( bool bEnable ) = 0;
- virtual bool IsInModalMode( ) const = 0;
-};
-
-extern IMayaVGui* g_pMayaVGui;
-
-
-#endif // IMAYAVGUI_H
+//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
+//
+// Purpose: Interface for dealing with vgui focus issues across all plugins
+//
+// $NoKeywords: $
+//===========================================================================//
+
+#ifndef IMAYAVGUI_H
+#define IMAYAVGUI_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+#include "tier0/platform.h"
+#include "appframework/iappsystem.h"
+#include "vgui_controls/Frame.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+namespace vgui
+{
+ class EditablePanel;
+}
+
+class CVsVGuiWindowBase;
+
+
+//-----------------------------------------------------------------------------
+// Factory for creating vgui windows
+//-----------------------------------------------------------------------------
+abstract_class IMayaVguiWindowFactory
+{
+public:
+ virtual void CreateVguiWindow( const char *pPanelName ) = 0;
+ virtual void DestroyVguiWindow( const char *pPanelName ) = 0;
+ virtual vgui::Frame *GetVGuiPanel( const char *pPanelName = NULL ) = 0;
+ virtual CVsVGuiWindowBase *GetVGuiWindow( const char *pPanelName = NULL ) = 0;
+};
+
+
+//-----------------------------------------------------------------------------
+// Interface for dealing with vgui focus issues across all plugins
+//-----------------------------------------------------------------------------
+#define MAYA_VGUI_INTERFACE_VERSION "VMayaVGui001"
+abstract_class IMayaVGui : public IAppSystem
+{
+public:
+ virtual void InstallVguiWindowFactory( const char *pWindowTypeName, IMayaVguiWindowFactory *pFactory ) = 0;
+ virtual void RemoveVguiWindowFactory( const char *pWindowTypeName, IMayaVguiWindowFactory *pFactory ) = 0;
+ virtual void SetFocus( void *hWnd, int hVGuiContext ) = 0;
+ virtual bool HasFocus( void *hWnd ) = 0;
+
+ // In this mode, maya's in a strange re-entrant mode waiting for a modal dialog
+ // We still get WM_PAINT messages, but we're in the middle of a callstack
+ // deep in the bowels of VGUI
+ virtual void SetModalMode( bool bEnable ) = 0;
+ virtual bool IsInModalMode( ) const = 0;
+};
+
+extern IMayaVGui* g_pMayaVGui;
+
+
+#endif // IMAYAVGUI_H
diff --git a/mp/src/public/maya/VsMayaDmx.h b/mp/src/public/maya/VsMayaDmx.h
index cd4f3890..9037df22 100644
--- a/mp/src/public/maya/VsMayaDmx.h
+++ b/mp/src/public/maya/VsMayaDmx.h
@@ -1,30 +1,30 @@
-//====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef VSMAYADMX_H
-#define VSMAYADMX_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-// Maya includes
-
-#include <maya/MDagPath.h>
-
-// Valve includes
-
-#include "movieobjects/dmemesh.h"
-
-class VsMayaDmx
-{
- static CDmeMesh *MayaMeshToDmeMesh(
- const MDagPath &i_mDagPath,
- DmFileId_t fileId );
-
-};
-
+//====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef VSMAYADMX_H
+#define VSMAYADMX_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+// Maya includes
+
+#include <maya/MDagPath.h>
+
+// Valve includes
+
+#include "movieobjects/dmemesh.h"
+
+class VsMayaDmx
+{
+ static CDmeMesh *MayaMeshToDmeMesh(
+ const MDagPath &i_mDagPath,
+ DmFileId_t fileId );
+
+};
+
#endif // VSMAYADMX_H \ No newline at end of file
diff --git a/mp/src/public/maya/VsMayaMPxFactory.h b/mp/src/public/maya/VsMayaMPxFactory.h
index 95accfa5..dc0ca0a1 100644
--- a/mp/src/public/maya/VsMayaMPxFactory.h
+++ b/mp/src/public/maya/VsMayaMPxFactory.h
@@ -1,1120 +1,1120 @@
-//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
-//
-// Purpose: Utility classes for creating, registering & deregistering
-// Maya MPx* derived classes
-//
-//=============================================================================
-
-#ifndef VSMAYAMPXFACTORY_H
-#define VSMAYAMPXFACTORY_H
-#if defined( _WIN32 )
-#pragma once
-#endif
-
-#include <maya/MPxCommand.h>
-#include <maya/MPxDeformerNode.h>
-#include <maya/MPxDragAndDropBehavior.h>
-#include <maya/MPxFileTranslator.h>
-#include <maya/MPxLocatorNode.h>
-#include <maya/MPxNode.h>
-#include <maya/MPxSurfaceShape.h>
-#include <maya/MPxSurfaceShapeUI.h>
-#include <maya/MPxToolCommand.h>
-#include <maya/MPxTransform.h>
-#include <maya/MPxTransformationMatrix.h>
-#include <maya/MSyntax.h>
-
-#if MAYA_API_VERSION >= 200800
-#include <maya/MPxImageFile.h>
-#endif //MAYA_API_VERSION >= 200800
-
-//-----------------------------------------------------------------------------
-//
-// Forward declarations
-//
-//-----------------------------------------------------------------------------
-class MFnPlugin;
-namespace ValveMaya
-{
- class CMSyntaxHelp;
-}
-
-
-//=============================================================================
-//
-// Base class for Maya MPx factories
-//
-//=============================================================================
-class CVsMayaMPxFactoryBase
-{
-public:
- // Registers all MPx derived things that have been allocated
- static MStatus RegisterEverything( MFnPlugin &pluginFn );
-
- // Deregisters all MPx derived things that have been allocated
- static MStatus DeregisterEverything( MFnPlugin &pluginFn );
-
- // Displays a list of stuff in the plugin
- static void DisplaySummary( const MString &pluginName );
-
- // Types of things the MPxFactory can create
- enum Type
- {
- // NOTE: Ensure this list of enums stays in sync with GetTypeName() array
- kCommand,
- kFileTranslator,
- kDependencyNode,
- kShaderNode,
- kTransform,
- kLocatorNode,
- kImageFile,
- // Insert new ones above here
- kUnknown
- };
-
- void Enable( bool bEnabled ) { m_bEnabled = bEnabled; }
-
- bool IsEnabled() const { return m_bEnabled; }
-
-protected:
- // Constructor
- CVsMayaMPxFactoryBase();
-
-private:
- // The next factory
- CVsMayaMPxFactoryBase* m_pNextFactory;
-
- // The starting factory
- static CVsMayaMPxFactoryBase *s_pFirstFactory;
-
- // Register the thing associated with this factory
- virtual MStatus Register( MFnPlugin &pluginFn ) const = 0;
-
- // Deregister the thing associated with this factory
- virtual MStatus Deregister( MFnPlugin &pluginFn ) const = 0;
-
- // Everything has a name
- virtual const MString &GetName() const = 0;
-
- // Everything has a description
- virtual const MString &GetDesc() const = 0;
-
- // Everything has a type
- virtual Type GetType() const = 0;
-
- // Everything has a type (map types to names)
- MString GetTypeName() const;
-
- // Whether this factory is enabled or not
- bool m_bEnabled;
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Templatized helpers for creating MPx derived classes
-//
-//-----------------------------------------------------------------------------
-template< class T >
-class CVsMayaMPxFactory : public CVsMayaMPxFactoryBase
-{
-private:
- // Register the thing associated with this factory
- virtual MStatus Register( MFnPlugin &pluginFn ) const
- {
- return T::Register( pluginFn );
- }
-
- // Deregister the thing associated with this factory
- virtual MStatus Deregister( MFnPlugin &pluginFn ) const
- {
- return T::Deregister( pluginFn );
- }
-
- virtual const MString &GetName() const
- {
- return T::s_name;
- }
-
- virtual const MString &GetDesc() const
- {
- return T::s_desc;
- }
-
- virtual Type GetType() const
- {
- return T::GetType();
- }
-};
-
-
-//============================================================================
-//
-// Base class for Valve Maya commands ( CVsMayaMPxCommand )
-//
-//============================================================================
-class CVsMayaMPxCommand : public MPxCommand
-{
-public:
- virtual const MString &GetName() const { return m_nullStr; }
- virtual const MString &GetDesc() const { return m_nullStr; }
-
-protected:
- // Derived classes must specify this to override syntax
- virtual void SpecifySyntax( MSyntax &mSyntax, ValveMaya::CMSyntaxHelp &help );
- ValveMaya::CMSyntaxHelp *GetSyntaxHelp() { return m_pSyntaxHelp; }
-
-private:
- ValveMaya::CMSyntaxHelp *m_pSyntaxHelp;
-
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- MCreatorFunction creatorFunction,
- MCreateSyntaxFunction createSyntaxFunction = NULL );
-
- static MStatus Deregister( MFnPlugin &pluginFn, const MString &name );
-
- template < class T > friend class CVsMayaMPxCommandDecorator;
-
- MString m_nullStr;
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya commands ( CVsMayaMPxCommandDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxCommandDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
- static const MString &Desc() { return s_desc; };
-
- virtual const MString &GetName() const { return Name(); };
- virtual const MString &GetDesc() const { return Desc(); };
-
- static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kCommand; }
-
-private:
- friend class CVsMayaMPxFactoryBase;
- template < class U > friend class CVsMayaMPxFactory;
-
- // These should be const but it's not because the CVsMayaMPxFactoryCommand class
- // only knows its name and therefore it's description at runtime
-
- static MString s_name;
- static MString s_desc;
- static ValveMaya::CMSyntaxHelp s_mSyntaxHelp; // Keeps track of command line flags
-
- static void *Create()
- {
- CVsMayaMPxCommandDecorator *pDecorator = new CVsMayaMPxCommandDecorator< T >;
- pDecorator->m_pSyntaxHelp = &s_mSyntaxHelp;
- return pDecorator;
- }
-
- static MSyntax CreateSyntax()
- {
- // Maya will simply never call this unless the 'hasSyntax()' virtual returns true
- // doesn't matter if a syntaxCreator is registered or not, and an empty
- // MSyntax is fine too. Also note the return is by value and not reference.
- // Also... even when Maya does call this, it is only ever called once, the
- // first time Maya needs to know what the syntax is (when the command is
- // invoked or when help cmd is done
-
- MSyntax mSyntax;
- T().SpecifySyntax( mSyntax, s_mSyntaxHelp );
- return mSyntax;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, Create, T().hasSyntax() ? CreateSyntax : NULL );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_name );
- }
-};
-
-
-//============================================================================
-//
-// Base class for Valve Maya commands ( CVsMayaMPxToolCommand )
-//
-//============================================================================
-class CVsMayaMPxToolCommand : public MPxToolCommand
-{
-public:
- virtual const MString &GetName() const { return m_nullStr; }
- virtual const MString &GetDesc() const { return m_nullStr; }
-
-protected:
- // Derived classes must specify this to override syntax
- virtual void SpecifySyntax( MSyntax &mSyntax, ValveMaya::CMSyntaxHelp &help );
- ValveMaya::CMSyntaxHelp *GetSyntaxHelp() { return m_pSyntaxHelp; }
-
-private:
- ValveMaya::CMSyntaxHelp *m_pSyntaxHelp;
-
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- MCreatorFunction creatorFunction,
- MCreateSyntaxFunction createSyntaxFunction = NULL );
-
- static MStatus Deregister( MFnPlugin &pluginFn, const MString &name );
-
- template < class T > friend class CVsMayaMPxToolCommandDecorator;
-
- MString m_nullStr;
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya commands ( CVsMayaMPxToolCommandDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxToolCommandDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
- static const MString &Desc() { return s_desc; };
-
- virtual const MString &GetName() const { return Name(); };
- virtual const MString &GetDesc() const { return Desc(); };
-
- static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kCommand; }
-
-private:
- friend class CVsMayaMPxFactoryBase;
- template < class U > friend class CVsMayaMPxFactory;
-
- // These should be const but it's not because the CVsMayaMPxFactoryCommand class
- // only knows its name and therefore it's description at runtime
-
- static MString s_name;
- static MString s_desc;
- static ValveMaya::CMSyntaxHelp s_mSyntaxHelp; // Keeps track of command line flags
-
- static void *Create()
- {
- CVsMayaMPxToolCommandDecorator *pDecorator = new CVsMayaMPxToolCommandDecorator< T >;
- pDecorator->m_pSyntaxHelp = &s_mSyntaxHelp;
- return pDecorator;
- }
-
- static MSyntax CreateSyntax()
- {
- // Maya will simply never call this unless the 'hasSyntax()' virtual returns true
- // doesn't matter if a syntaxCreator is registered or not, and an empty
- // MSyntax is fine too. Also note the return is by value and not reference.
- // Also... even when Maya does call this, it is only ever called once, the
- // first time Maya needs to know what the syntax is (when the command is
- // invoked or when help cmd is done
-
- MSyntax mSyntax;
- T().SpecifySyntax( mSyntax, s_mSyntaxHelp );
- return mSyntax;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, Create, T().hasSyntax() ? CreateSyntax : NULL );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_name );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya file translators ( CVsMayaMPxFileTranslator )
-//
-//=============================================================================
-class CVsMayaMPxFileTranslator : public MPxFileTranslator
-{
-public:
- virtual const MString &GetName() const = 0;
- virtual const MString &GetGUIName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MString &guiName,
- MCreatorFunction creatorFunction );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MString &name );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya file translators ( CVsMayaMPxFileTranslatorDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxFileTranslatorDecorator : public T
-{
-public:
- virtual const MString &GetName() const { return s_name; };
-
- virtual const MString &GetGUIName() const { return s_guiName; };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kFileTranslator; }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MString s_guiName;
-
- static void *Create()
- {
- return new CVsMayaMPxFileTranslatorDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_guiName, Create );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_guiName );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Dependency Nodes ( CVsMayaMPxNode )
-//
-//============================================================================
-class CVsMayaMPxNode : public MPxNode
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction,
- const MString &classification );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MTypeId &mTypeId );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya nodes ( CVsMayaMPxNodeDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxNodeDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return s_classification.length() ? CVsMayaMPxFactoryBase::kShaderNode : CVsMayaMPxFactoryBase::kDependencyNode;
- }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MTypeId s_mTypeId;
-
- static const MInitializeFunction s_mInitializeFunction;
-
- static const MString s_classification;
-
- static void *Create()
- {
- return new CVsMayaMPxNodeDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_classification );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_mTypeId );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Transform Nodes ( CVsMayaMPxTransform )
-//
-//============================================================================
-class CVsMayaMPxTransform : public MPxTransform
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
-
-#if MAYA_API_VERSION >= 200900
-
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction,
- MCreateXformMatrixFunction xformCreatorFunction = MPxTransformationMatrix::creator,
- const MTypeId &xformMTypeId = MPxTransformationMatrix::baseTransformationMatrixId,
- const MString *classification = NULL );
-
-#else // #if MAYA_API_VERSION >= 200900
-
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction,
- MCreatorFunction xformCreatorFunction = MPxTransformationMatrix::creator,
- const MTypeId &xformMTypeId = MPxTransformationMatrix::baseTransformationMatrixId,
- const MString *classification = NULL );
-
-#endif // #if MAYA_API_VERSION >= 200900
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MTypeId &mTypeId );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya commands ( CVsMayaMPxCommandDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxTransformDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kTransform; }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MTypeId s_mTypeId;
-
- static const MInitializeFunction s_mInitializeFunction;
-
-#if MAYA_API_VERSION >= 200900
-
- static const MCreateXformMatrixFunction s_xformMCreatorFunction;
-
-#else // #if MAYA_API_VERSION >= 200900
-
- static const MCreatorFunction s_xformMCreatorFunction;
-
-#endif // #if MAYA_API_VERSION >= 200900
-
- static const MTypeId s_xformMTypeId;
-
- static void *Create()
- {
- return new CVsMayaMPxTransformDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_xformMCreatorFunction, s_xformMTypeId );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_mTypeId );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Locator Nodes ( CVsMayaMPxLocatorNode )
-//
-//============================================================================
-class CVsMayaMPxLocatorNode : public MPxLocatorNode
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MTypeId &mTypeId );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya nodes ( CVsMayaMPxLocatorNodeDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxLocatorNodeDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return CVsMayaMPxFactoryBase::kLocatorNode;
- }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MTypeId s_mTypeId;
-
- static const MInitializeFunction s_mInitializeFunction;
-
- static void *Create()
- {
- return new CVsMayaMPxLocatorNodeDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_mTypeId );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Drag And Drop Behaviors ( CVsMayaMPxDragAndDropBehavior )
-//
-//============================================================================
-class CVsMayaMPxDragAndDropBehavior : public MPxDragAndDropBehavior
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- MCreatorFunction creatorFunction );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MString &name );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya drag and drop behaviors ( CVsMayaMPxDragAndDropBehavior )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxDragAndDropBehaviorDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return CVsMayaMPxFactoryBase::kLocatorNode;
- }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MInitializeFunction s_mInitializeFunction;
-
- static void *Create()
- {
- return new CVsMayaMPxDragAndDropBehaviorDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, Create );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_name );
- }
-};
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Shape Nodes ( CVsMayaMPxShapeNode )
-//
-//============================================================================
-class CVsMayaMPxShapeNode : public MPxSurfaceShape
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction,
- MCreatorFunction uiCreatorFunction );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MTypeId &mTypeId );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya shape nodes ( CVsMayaMPxShapeNodeDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T, class U >
-class CVsMayaMPxShapeNodeDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return CVsMayaMPxFactoryBase::kLocatorNode;
- }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MTypeId s_mTypeId;
-
- static const MInitializeFunction s_mInitializeFunction;
-
- static const MCreatorFunction s_uiCreatorFunction;
-
- static void *Create()
- {
- return new CVsMayaMPxShapeNodeDecorator< T, U >;
- }
-
- static void *CreateUI()
- {
- return new U;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, CreateUI );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_mTypeId );
- }
-};
-
-#if MAYA_API_VERSION >= 200800
-//=============================================================================
-//
-// Base class for Valve Maya Image File Types ( CVsMayaMPxImageFile )
-//
-//============================================================================
-class CVsMayaMPxImageFile : public MPxImageFile
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- MCreatorFunction creatorFunction,
- const MStringArray &extensions );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MString &name );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya Image Files ( CVsMayaMPxImageFileDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxImageFileDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return CVsMayaMPxFactoryBase::kImageFile;
- }
-
-private:
- template < class T > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MStringArray s_extensions;
-
- static const MCreatorFunction s_creatorFunction;
-
- static void *Create()
- {
- return new CVsMayaMPxImageFileDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, Create, s_extensions );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_name );
- }
-};
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate an image file
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXIMAGEFILE( _class, _name, _extensions, _desc ) \
- const MString CVsMayaMPxImageFileDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxImageFileDecorator< _class >::s_desc( _desc ); \
- const MStringArray CVsMayaMPxImageFileDecorator< _class >::s_extensions( _extensions ); \
- static CVsMayaMPxFactory< CVsMayaMPxImageFileDecorator< _class > > s_##_name##_Factory
-
-
-#endif // MAYA_API_VERSION >= 200800
-
-
-//=============================================================================
-//
-// Base class for Valve Maya Dependency Nodes ( CVsMayaMPxNode )
-//
-//============================================================================
-class CVsMayaMPxDeformerNode : public MPxDeformerNode
-{
-public:
- virtual const MString &GetName() const = 0;
-
-protected:
- static MStatus Register(
- MFnPlugin &pluginFn,
- const MString &name,
- const MTypeId &mTypeId,
- MCreatorFunction creatorFunction,
- MInitializeFunction initFunction,
- const MString &classification );
-
- static MStatus Deregister(
- MFnPlugin &pluginFn,
- const MTypeId &mTypeId );
-};
-
-
-//-----------------------------------------------------------------------------
-//
-// Decorator class for Valve Maya nodes ( CVsMayaMPxDeformerNodeDecorator )
-//
-//-----------------------------------------------------------------------------
-template < class T >
-class CVsMayaMPxDeformerNodeDecorator : public T
-{
-public:
- static const MString &Name() { return s_name; };
-
- virtual const MString &GetName() const { return Name(); };
-
- virtual const MString &GetDesc() const { return s_desc; };
-
- static CVsMayaMPxFactoryBase::Type GetType()
- {
- return s_classification.length() ? CVsMayaMPxFactoryBase::kShaderNode : CVsMayaMPxFactoryBase::kDependencyNode;
- }
-
-private:
- template < class U > friend class CVsMayaMPxFactory;
-
- static const MString s_name;
-
- static const MString s_desc;
-
- static const MTypeId s_mTypeId;
-
- static const MInitializeFunction s_mInitializeFunction;
-
- static const MString s_classification;
-
- static void *Create()
- {
- return new CVsMayaMPxDeformerNodeDecorator< T >;
- }
-
- static MStatus Register( MFnPlugin &pluginFn )
- {
- return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_classification );
- }
-
- static MStatus Deregister( MFnPlugin &pluginFn )
- {
- return T::Deregister( pluginFn, s_mTypeId );
- }
-};
-
-
-//=============================================================================
-//
-// Helper Macros
-//
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a command
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXCOMMAND( _class, _name, _desc ) \
- MString CVsMayaMPxCommandDecorator< _class >::s_name( #_name ); \
- MString CVsMayaMPxCommandDecorator< _class >::s_desc( _desc ); \
- ValveMaya::CMSyntaxHelp CVsMayaMPxCommandDecorator< _class >::s_mSyntaxHelp; \
- static CVsMayaMPxFactory< CVsMayaMPxCommandDecorator< _class > > s_##_name##_Factory
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a command
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXTOOLCOMMAND( _class, _name, _desc ) \
- MString CVsMayaMPxToolCommandDecorator< _class >::s_name( #_name ); \
- MString CVsMayaMPxToolCommandDecorator< _class >::s_desc( _desc ); \
- ValveMaya::CMSyntaxHelp CVsMayaMPxToolCommandDecorator< _class >::s_mSyntaxHelp; \
- static CVsMayaMPxFactory< CVsMayaMPxToolCommandDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a translator
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXFILETRANSLATOR( _class, _name, _guiName, _desc ) \
- const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_desc( _desc ); \
- const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_guiName( _guiName ); \
- static CVsMayaMPxFactory< CVsMayaMPxFileTranslatorDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a regular dependency node
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
- const MString CVsMayaMPxNodeDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxNodeDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxNodeDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MString CVsMayaMPxNodeDecorator< _class >::s_classification( "" ); \
- static CVsMayaMPxFactory< CVsMayaMPxNodeDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a shader dependency node
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXSHADERNODE( _class, _name, _typeId, _initializeFunction, _classification, _desc ) \
- const MString CVsMayaMPxNodeDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxNodeDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxNodeDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MString CVsMayaMPxNodeDecorator< _class >::s_classification( _classification ); \
- static CVsMayaMPxFactory< CVsMayaMPxNodeDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a transform node
-//-----------------------------------------------------------------------------
-#if MAYA_API_VERSION >= 200900
-
-#define INSTALL_MAYA_MPXTRANSFORM( _class, _name, _typeId, _initializeFunction, _desc ) \
- const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MCreateXformMatrixFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( MPxTransformationMatrix::creator ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( MPxTransformationMatrix::baseTransformationMatrixId ); \
- static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
-
-#else // #if MAYA_API_VERSION >= 200900
-
-#define INSTALL_MAYA_MPXTRANSFORM( _class, _name, _typeId, _initializeFunction, _desc ) \
- const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MCreatorFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( MPxTransformationMatrix::creator ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( MPxTransformationMatrix::baseTransformationMatrixId ); \
- static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
-
-#endif // #if MAYA_API_VERSION >= 200900
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a transform node with a custom transformation matrix
-// TODO: Make CVsMayaMPxTransformationMatrix and create the MCreatorFunction for the user
-//-----------------------------------------------------------------------------
-#if MAYA_API_VERSION >= 200900
-
-#define INSTALL_MAYA_MPXTRANSFORM_WITHMATRIX( _class, _name, _typeId, _initializeFunction, _xformCreatorFunction, _xformTypeId, _desc ) \
- const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MCreateXformMatrixFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( _xformCreatorFunction ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( _xformTypeId ); \
- static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
-
-#else // #if MAYA_API_VERSION >= 200900
-
-#define INSTALL_MAYA_MPXTRANSFORM_WITHMATRIX( _class, _name, _typeId, _initializeFunction, _xformCreatorFunction, _xformTypeId, _desc ) \
- const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MCreatorFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( _xformCreatorFunction ); \
- const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( _xformTypeId ); \
- static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
-
-#endif // #if MAYA_API_VERSION >= 200900
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a locator node
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXLOCATORNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
- const MString CVsMayaMPxLocatorNodeDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxLocatorNodeDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxLocatorNodeDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxLocatorNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- static CVsMayaMPxFactory< CVsMayaMPxLocatorNodeDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a drag and drop behavior
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXDRAGANDDROPBEHAVIOR( _class, _name, _desc ) \
- const MString CVsMayaMPxDragAndDropBehaviorDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxDragAndDropBehaviorDecorator< _class >::s_desc( _desc ); \
- static CVsMayaMPxFactory< CVsMayaMPxDragAndDropBehaviorDecorator< _class > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a shape node
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXSHAPENODE( _class, _name, _typeId, _initializeFunction, _uiClass, _desc ) \
- const MString CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_name( #_name ); \
- const MString CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_mInitializeFunction( _initializeFunction ); \
- static CVsMayaMPxFactory< CVsMayaMPxShapeNodeDecorator< _class, _uiClass > > s_##_name##_Factory
-
-
-//-----------------------------------------------------------------------------
-// Helper macro to instantiate a deformer dependency node
-//-----------------------------------------------------------------------------
-#define INSTALL_MAYA_MPXDEFORMERNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
- const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_name( #_name ); \
- const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_desc( _desc ); \
- const MTypeId CVsMayaMPxDeformerNodeDecorator< _class >::s_mTypeId( _typeId ); \
- const MInitializeFunction CVsMayaMPxDeformerNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
- const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_classification( "" ); \
- static CVsMayaMPxFactory< CVsMayaMPxDeformerNodeDecorator< _class > > s_##_name##_Factory
-
-
+//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
+//
+// Purpose: Utility classes for creating, registering & deregistering
+// Maya MPx* derived classes
+//
+//=============================================================================
+
+#ifndef VSMAYAMPXFACTORY_H
+#define VSMAYAMPXFACTORY_H
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+#include <maya/MPxCommand.h>
+#include <maya/MPxDeformerNode.h>
+#include <maya/MPxDragAndDropBehavior.h>
+#include <maya/MPxFileTranslator.h>
+#include <maya/MPxLocatorNode.h>
+#include <maya/MPxNode.h>
+#include <maya/MPxSurfaceShape.h>
+#include <maya/MPxSurfaceShapeUI.h>
+#include <maya/MPxToolCommand.h>
+#include <maya/MPxTransform.h>
+#include <maya/MPxTransformationMatrix.h>
+#include <maya/MSyntax.h>
+
+#if MAYA_API_VERSION >= 200800
+#include <maya/MPxImageFile.h>
+#endif //MAYA_API_VERSION >= 200800
+
+//-----------------------------------------------------------------------------
+//
+// Forward declarations
+//
+//-----------------------------------------------------------------------------
+class MFnPlugin;
+namespace ValveMaya
+{
+ class CMSyntaxHelp;
+}
+
+
+//=============================================================================
+//
+// Base class for Maya MPx factories
+//
+//=============================================================================
+class CVsMayaMPxFactoryBase
+{
+public:
+ // Registers all MPx derived things that have been allocated
+ static MStatus RegisterEverything( MFnPlugin &pluginFn );
+
+ // Deregisters all MPx derived things that have been allocated
+ static MStatus DeregisterEverything( MFnPlugin &pluginFn );
+
+ // Displays a list of stuff in the plugin
+ static void DisplaySummary( const MString &pluginName );
+
+ // Types of things the MPxFactory can create
+ enum Type
+ {
+ // NOTE: Ensure this list of enums stays in sync with GetTypeName() array
+ kCommand,
+ kFileTranslator,
+ kDependencyNode,
+ kShaderNode,
+ kTransform,
+ kLocatorNode,
+ kImageFile,
+ // Insert new ones above here
+ kUnknown
+ };
+
+ void Enable( bool bEnabled ) { m_bEnabled = bEnabled; }
+
+ bool IsEnabled() const { return m_bEnabled; }
+
+protected:
+ // Constructor
+ CVsMayaMPxFactoryBase();
+
+private:
+ // The next factory
+ CVsMayaMPxFactoryBase* m_pNextFactory;
+
+ // The starting factory
+ static CVsMayaMPxFactoryBase *s_pFirstFactory;
+
+ // Register the thing associated with this factory
+ virtual MStatus Register( MFnPlugin &pluginFn ) const = 0;
+
+ // Deregister the thing associated with this factory
+ virtual MStatus Deregister( MFnPlugin &pluginFn ) const = 0;
+
+ // Everything has a name
+ virtual const MString &GetName() const = 0;
+
+ // Everything has a description
+ virtual const MString &GetDesc() const = 0;
+
+ // Everything has a type
+ virtual Type GetType() const = 0;
+
+ // Everything has a type (map types to names)
+ MString GetTypeName() const;
+
+ // Whether this factory is enabled or not
+ bool m_bEnabled;
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Templatized helpers for creating MPx derived classes
+//
+//-----------------------------------------------------------------------------
+template< class T >
+class CVsMayaMPxFactory : public CVsMayaMPxFactoryBase
+{
+private:
+ // Register the thing associated with this factory
+ virtual MStatus Register( MFnPlugin &pluginFn ) const
+ {
+ return T::Register( pluginFn );
+ }
+
+ // Deregister the thing associated with this factory
+ virtual MStatus Deregister( MFnPlugin &pluginFn ) const
+ {
+ return T::Deregister( pluginFn );
+ }
+
+ virtual const MString &GetName() const
+ {
+ return T::s_name;
+ }
+
+ virtual const MString &GetDesc() const
+ {
+ return T::s_desc;
+ }
+
+ virtual Type GetType() const
+ {
+ return T::GetType();
+ }
+};
+
+
+//============================================================================
+//
+// Base class for Valve Maya commands ( CVsMayaMPxCommand )
+//
+//============================================================================
+class CVsMayaMPxCommand : public MPxCommand
+{
+public:
+ virtual const MString &GetName() const { return m_nullStr; }
+ virtual const MString &GetDesc() const { return m_nullStr; }
+
+protected:
+ // Derived classes must specify this to override syntax
+ virtual void SpecifySyntax( MSyntax &mSyntax, ValveMaya::CMSyntaxHelp &help );
+ ValveMaya::CMSyntaxHelp *GetSyntaxHelp() { return m_pSyntaxHelp; }
+
+private:
+ ValveMaya::CMSyntaxHelp *m_pSyntaxHelp;
+
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ MCreatorFunction creatorFunction,
+ MCreateSyntaxFunction createSyntaxFunction = NULL );
+
+ static MStatus Deregister( MFnPlugin &pluginFn, const MString &name );
+
+ template < class T > friend class CVsMayaMPxCommandDecorator;
+
+ MString m_nullStr;
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya commands ( CVsMayaMPxCommandDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxCommandDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+ static const MString &Desc() { return s_desc; };
+
+ virtual const MString &GetName() const { return Name(); };
+ virtual const MString &GetDesc() const { return Desc(); };
+
+ static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kCommand; }
+
+private:
+ friend class CVsMayaMPxFactoryBase;
+ template < class U > friend class CVsMayaMPxFactory;
+
+ // These should be const but it's not because the CVsMayaMPxFactoryCommand class
+ // only knows its name and therefore it's description at runtime
+
+ static MString s_name;
+ static MString s_desc;
+ static ValveMaya::CMSyntaxHelp s_mSyntaxHelp; // Keeps track of command line flags
+
+ static void *Create()
+ {
+ CVsMayaMPxCommandDecorator *pDecorator = new CVsMayaMPxCommandDecorator< T >;
+ pDecorator->m_pSyntaxHelp = &s_mSyntaxHelp;
+ return pDecorator;
+ }
+
+ static MSyntax CreateSyntax()
+ {
+ // Maya will simply never call this unless the 'hasSyntax()' virtual returns true
+ // doesn't matter if a syntaxCreator is registered or not, and an empty
+ // MSyntax is fine too. Also note the return is by value and not reference.
+ // Also... even when Maya does call this, it is only ever called once, the
+ // first time Maya needs to know what the syntax is (when the command is
+ // invoked or when help cmd is done
+
+ MSyntax mSyntax;
+ T().SpecifySyntax( mSyntax, s_mSyntaxHelp );
+ return mSyntax;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, Create, T().hasSyntax() ? CreateSyntax : NULL );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_name );
+ }
+};
+
+
+//============================================================================
+//
+// Base class for Valve Maya commands ( CVsMayaMPxToolCommand )
+//
+//============================================================================
+class CVsMayaMPxToolCommand : public MPxToolCommand
+{
+public:
+ virtual const MString &GetName() const { return m_nullStr; }
+ virtual const MString &GetDesc() const { return m_nullStr; }
+
+protected:
+ // Derived classes must specify this to override syntax
+ virtual void SpecifySyntax( MSyntax &mSyntax, ValveMaya::CMSyntaxHelp &help );
+ ValveMaya::CMSyntaxHelp *GetSyntaxHelp() { return m_pSyntaxHelp; }
+
+private:
+ ValveMaya::CMSyntaxHelp *m_pSyntaxHelp;
+
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ MCreatorFunction creatorFunction,
+ MCreateSyntaxFunction createSyntaxFunction = NULL );
+
+ static MStatus Deregister( MFnPlugin &pluginFn, const MString &name );
+
+ template < class T > friend class CVsMayaMPxToolCommandDecorator;
+
+ MString m_nullStr;
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya commands ( CVsMayaMPxToolCommandDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxToolCommandDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+ static const MString &Desc() { return s_desc; };
+
+ virtual const MString &GetName() const { return Name(); };
+ virtual const MString &GetDesc() const { return Desc(); };
+
+ static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kCommand; }
+
+private:
+ friend class CVsMayaMPxFactoryBase;
+ template < class U > friend class CVsMayaMPxFactory;
+
+ // These should be const but it's not because the CVsMayaMPxFactoryCommand class
+ // only knows its name and therefore it's description at runtime
+
+ static MString s_name;
+ static MString s_desc;
+ static ValveMaya::CMSyntaxHelp s_mSyntaxHelp; // Keeps track of command line flags
+
+ static void *Create()
+ {
+ CVsMayaMPxToolCommandDecorator *pDecorator = new CVsMayaMPxToolCommandDecorator< T >;
+ pDecorator->m_pSyntaxHelp = &s_mSyntaxHelp;
+ return pDecorator;
+ }
+
+ static MSyntax CreateSyntax()
+ {
+ // Maya will simply never call this unless the 'hasSyntax()' virtual returns true
+ // doesn't matter if a syntaxCreator is registered or not, and an empty
+ // MSyntax is fine too. Also note the return is by value and not reference.
+ // Also... even when Maya does call this, it is only ever called once, the
+ // first time Maya needs to know what the syntax is (when the command is
+ // invoked or when help cmd is done
+
+ MSyntax mSyntax;
+ T().SpecifySyntax( mSyntax, s_mSyntaxHelp );
+ return mSyntax;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, Create, T().hasSyntax() ? CreateSyntax : NULL );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_name );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya file translators ( CVsMayaMPxFileTranslator )
+//
+//=============================================================================
+class CVsMayaMPxFileTranslator : public MPxFileTranslator
+{
+public:
+ virtual const MString &GetName() const = 0;
+ virtual const MString &GetGUIName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MString &guiName,
+ MCreatorFunction creatorFunction );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MString &name );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya file translators ( CVsMayaMPxFileTranslatorDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxFileTranslatorDecorator : public T
+{
+public:
+ virtual const MString &GetName() const { return s_name; };
+
+ virtual const MString &GetGUIName() const { return s_guiName; };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kFileTranslator; }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MString s_guiName;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxFileTranslatorDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_guiName, Create );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_guiName );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Dependency Nodes ( CVsMayaMPxNode )
+//
+//============================================================================
+class CVsMayaMPxNode : public MPxNode
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction,
+ const MString &classification );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MTypeId &mTypeId );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya nodes ( CVsMayaMPxNodeDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxNodeDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return s_classification.length() ? CVsMayaMPxFactoryBase::kShaderNode : CVsMayaMPxFactoryBase::kDependencyNode;
+ }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MTypeId s_mTypeId;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+ static const MString s_classification;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxNodeDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_classification );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_mTypeId );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Transform Nodes ( CVsMayaMPxTransform )
+//
+//============================================================================
+class CVsMayaMPxTransform : public MPxTransform
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+
+#if MAYA_API_VERSION >= 200900
+
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction,
+ MCreateXformMatrixFunction xformCreatorFunction = MPxTransformationMatrix::creator,
+ const MTypeId &xformMTypeId = MPxTransformationMatrix::baseTransformationMatrixId,
+ const MString *classification = NULL );
+
+#else // #if MAYA_API_VERSION >= 200900
+
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction,
+ MCreatorFunction xformCreatorFunction = MPxTransformationMatrix::creator,
+ const MTypeId &xformMTypeId = MPxTransformationMatrix::baseTransformationMatrixId,
+ const MString *classification = NULL );
+
+#endif // #if MAYA_API_VERSION >= 200900
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MTypeId &mTypeId );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya commands ( CVsMayaMPxCommandDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxTransformDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType() { return CVsMayaMPxFactoryBase::kTransform; }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MTypeId s_mTypeId;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+#if MAYA_API_VERSION >= 200900
+
+ static const MCreateXformMatrixFunction s_xformMCreatorFunction;
+
+#else // #if MAYA_API_VERSION >= 200900
+
+ static const MCreatorFunction s_xformMCreatorFunction;
+
+#endif // #if MAYA_API_VERSION >= 200900
+
+ static const MTypeId s_xformMTypeId;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxTransformDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_xformMCreatorFunction, s_xformMTypeId );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_mTypeId );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Locator Nodes ( CVsMayaMPxLocatorNode )
+//
+//============================================================================
+class CVsMayaMPxLocatorNode : public MPxLocatorNode
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MTypeId &mTypeId );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya nodes ( CVsMayaMPxLocatorNodeDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxLocatorNodeDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return CVsMayaMPxFactoryBase::kLocatorNode;
+ }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MTypeId s_mTypeId;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxLocatorNodeDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_mTypeId );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Drag And Drop Behaviors ( CVsMayaMPxDragAndDropBehavior )
+//
+//============================================================================
+class CVsMayaMPxDragAndDropBehavior : public MPxDragAndDropBehavior
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ MCreatorFunction creatorFunction );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MString &name );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya drag and drop behaviors ( CVsMayaMPxDragAndDropBehavior )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxDragAndDropBehaviorDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return CVsMayaMPxFactoryBase::kLocatorNode;
+ }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxDragAndDropBehaviorDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, Create );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_name );
+ }
+};
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Shape Nodes ( CVsMayaMPxShapeNode )
+//
+//============================================================================
+class CVsMayaMPxShapeNode : public MPxSurfaceShape
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction,
+ MCreatorFunction uiCreatorFunction );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MTypeId &mTypeId );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya shape nodes ( CVsMayaMPxShapeNodeDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T, class U >
+class CVsMayaMPxShapeNodeDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return CVsMayaMPxFactoryBase::kLocatorNode;
+ }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MTypeId s_mTypeId;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+ static const MCreatorFunction s_uiCreatorFunction;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxShapeNodeDecorator< T, U >;
+ }
+
+ static void *CreateUI()
+ {
+ return new U;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, CreateUI );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_mTypeId );
+ }
+};
+
+#if MAYA_API_VERSION >= 200800
+//=============================================================================
+//
+// Base class for Valve Maya Image File Types ( CVsMayaMPxImageFile )
+//
+//============================================================================
+class CVsMayaMPxImageFile : public MPxImageFile
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ MCreatorFunction creatorFunction,
+ const MStringArray &extensions );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MString &name );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya Image Files ( CVsMayaMPxImageFileDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxImageFileDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return CVsMayaMPxFactoryBase::kImageFile;
+ }
+
+private:
+ template < class T > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MStringArray s_extensions;
+
+ static const MCreatorFunction s_creatorFunction;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxImageFileDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, Create, s_extensions );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_name );
+ }
+};
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate an image file
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXIMAGEFILE( _class, _name, _extensions, _desc ) \
+ const MString CVsMayaMPxImageFileDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxImageFileDecorator< _class >::s_desc( _desc ); \
+ const MStringArray CVsMayaMPxImageFileDecorator< _class >::s_extensions( _extensions ); \
+ static CVsMayaMPxFactory< CVsMayaMPxImageFileDecorator< _class > > s_##_name##_Factory
+
+
+#endif // MAYA_API_VERSION >= 200800
+
+
+//=============================================================================
+//
+// Base class for Valve Maya Dependency Nodes ( CVsMayaMPxNode )
+//
+//============================================================================
+class CVsMayaMPxDeformerNode : public MPxDeformerNode
+{
+public:
+ virtual const MString &GetName() const = 0;
+
+protected:
+ static MStatus Register(
+ MFnPlugin &pluginFn,
+ const MString &name,
+ const MTypeId &mTypeId,
+ MCreatorFunction creatorFunction,
+ MInitializeFunction initFunction,
+ const MString &classification );
+
+ static MStatus Deregister(
+ MFnPlugin &pluginFn,
+ const MTypeId &mTypeId );
+};
+
+
+//-----------------------------------------------------------------------------
+//
+// Decorator class for Valve Maya nodes ( CVsMayaMPxDeformerNodeDecorator )
+//
+//-----------------------------------------------------------------------------
+template < class T >
+class CVsMayaMPxDeformerNodeDecorator : public T
+{
+public:
+ static const MString &Name() { return s_name; };
+
+ virtual const MString &GetName() const { return Name(); };
+
+ virtual const MString &GetDesc() const { return s_desc; };
+
+ static CVsMayaMPxFactoryBase::Type GetType()
+ {
+ return s_classification.length() ? CVsMayaMPxFactoryBase::kShaderNode : CVsMayaMPxFactoryBase::kDependencyNode;
+ }
+
+private:
+ template < class U > friend class CVsMayaMPxFactory;
+
+ static const MString s_name;
+
+ static const MString s_desc;
+
+ static const MTypeId s_mTypeId;
+
+ static const MInitializeFunction s_mInitializeFunction;
+
+ static const MString s_classification;
+
+ static void *Create()
+ {
+ return new CVsMayaMPxDeformerNodeDecorator< T >;
+ }
+
+ static MStatus Register( MFnPlugin &pluginFn )
+ {
+ return T::Register( pluginFn, s_name, s_mTypeId, Create, s_mInitializeFunction, s_classification );
+ }
+
+ static MStatus Deregister( MFnPlugin &pluginFn )
+ {
+ return T::Deregister( pluginFn, s_mTypeId );
+ }
+};
+
+
+//=============================================================================
+//
+// Helper Macros
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a command
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXCOMMAND( _class, _name, _desc ) \
+ MString CVsMayaMPxCommandDecorator< _class >::s_name( #_name ); \
+ MString CVsMayaMPxCommandDecorator< _class >::s_desc( _desc ); \
+ ValveMaya::CMSyntaxHelp CVsMayaMPxCommandDecorator< _class >::s_mSyntaxHelp; \
+ static CVsMayaMPxFactory< CVsMayaMPxCommandDecorator< _class > > s_##_name##_Factory
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a command
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXTOOLCOMMAND( _class, _name, _desc ) \
+ MString CVsMayaMPxToolCommandDecorator< _class >::s_name( #_name ); \
+ MString CVsMayaMPxToolCommandDecorator< _class >::s_desc( _desc ); \
+ ValveMaya::CMSyntaxHelp CVsMayaMPxToolCommandDecorator< _class >::s_mSyntaxHelp; \
+ static CVsMayaMPxFactory< CVsMayaMPxToolCommandDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a translator
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXFILETRANSLATOR( _class, _name, _guiName, _desc ) \
+ const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_desc( _desc ); \
+ const MString CVsMayaMPxFileTranslatorDecorator< _class >::s_guiName( _guiName ); \
+ static CVsMayaMPxFactory< CVsMayaMPxFileTranslatorDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a regular dependency node
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxNodeDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_classification( "" ); \
+ static CVsMayaMPxFactory< CVsMayaMPxNodeDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a shader dependency node
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXSHADERNODE( _class, _name, _typeId, _initializeFunction, _classification, _desc ) \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxNodeDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MString CVsMayaMPxNodeDecorator< _class >::s_classification( _classification ); \
+ static CVsMayaMPxFactory< CVsMayaMPxNodeDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a transform node
+//-----------------------------------------------------------------------------
+#if MAYA_API_VERSION >= 200900
+
+#define INSTALL_MAYA_MPXTRANSFORM( _class, _name, _typeId, _initializeFunction, _desc ) \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MCreateXformMatrixFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( MPxTransformationMatrix::creator ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( MPxTransformationMatrix::baseTransformationMatrixId ); \
+ static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
+
+#else // #if MAYA_API_VERSION >= 200900
+
+#define INSTALL_MAYA_MPXTRANSFORM( _class, _name, _typeId, _initializeFunction, _desc ) \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MCreatorFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( MPxTransformationMatrix::creator ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( MPxTransformationMatrix::baseTransformationMatrixId ); \
+ static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
+
+#endif // #if MAYA_API_VERSION >= 200900
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a transform node with a custom transformation matrix
+// TODO: Make CVsMayaMPxTransformationMatrix and create the MCreatorFunction for the user
+//-----------------------------------------------------------------------------
+#if MAYA_API_VERSION >= 200900
+
+#define INSTALL_MAYA_MPXTRANSFORM_WITHMATRIX( _class, _name, _typeId, _initializeFunction, _xformCreatorFunction, _xformTypeId, _desc ) \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MCreateXformMatrixFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( _xformCreatorFunction ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( _xformTypeId ); \
+ static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
+
+#else // #if MAYA_API_VERSION >= 200900
+
+#define INSTALL_MAYA_MPXTRANSFORM_WITHMATRIX( _class, _name, _typeId, _initializeFunction, _xformCreatorFunction, _xformTypeId, _desc ) \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxTransformDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxTransformDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MCreatorFunction CVsMayaMPxTransformDecorator< _class >::s_xformMCreatorFunction( _xformCreatorFunction ); \
+ const MTypeId CVsMayaMPxTransformDecorator< _class >::s_xformMTypeId( _xformTypeId ); \
+ static CVsMayaMPxFactory< CVsMayaMPxTransformDecorator< _class > > s_##_name##_Factory
+
+#endif // #if MAYA_API_VERSION >= 200900
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a locator node
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXLOCATORNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
+ const MString CVsMayaMPxLocatorNodeDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxLocatorNodeDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxLocatorNodeDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxLocatorNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ static CVsMayaMPxFactory< CVsMayaMPxLocatorNodeDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a drag and drop behavior
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXDRAGANDDROPBEHAVIOR( _class, _name, _desc ) \
+ const MString CVsMayaMPxDragAndDropBehaviorDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxDragAndDropBehaviorDecorator< _class >::s_desc( _desc ); \
+ static CVsMayaMPxFactory< CVsMayaMPxDragAndDropBehaviorDecorator< _class > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a shape node
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXSHAPENODE( _class, _name, _typeId, _initializeFunction, _uiClass, _desc ) \
+ const MString CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_name( #_name ); \
+ const MString CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxShapeNodeDecorator< _class, _uiClass >::s_mInitializeFunction( _initializeFunction ); \
+ static CVsMayaMPxFactory< CVsMayaMPxShapeNodeDecorator< _class, _uiClass > > s_##_name##_Factory
+
+
+//-----------------------------------------------------------------------------
+// Helper macro to instantiate a deformer dependency node
+//-----------------------------------------------------------------------------
+#define INSTALL_MAYA_MPXDEFORMERNODE( _class, _name, _typeId, _initializeFunction, _desc ) \
+ const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_name( #_name ); \
+ const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_desc( _desc ); \
+ const MTypeId CVsMayaMPxDeformerNodeDecorator< _class >::s_mTypeId( _typeId ); \
+ const MInitializeFunction CVsMayaMPxDeformerNodeDecorator< _class >::s_mInitializeFunction( _initializeFunction ); \
+ const MString CVsMayaMPxDeformerNodeDecorator< _class >::s_classification( "" ); \
+ static CVsMayaMPxFactory< CVsMayaMPxDeformerNodeDecorator< _class > > s_##_name##_Factory
+
+
#endif // VSMAYAMPXFACTORY_H \ No newline at end of file
diff --git a/mp/src/public/maya/VsVGuiWindow.h b/mp/src/public/maya/VsVGuiWindow.h
index 4abd4ca2..e33446dd 100644
--- a/mp/src/public/maya/VsVGuiWindow.h
+++ b/mp/src/public/maya/VsVGuiWindow.h
@@ -1,195 +1,195 @@
-//===== Copyright � 1996-2006, Valve Corporation, All rights reserved. ======//
-//
-// Base class for windows that draw vgui in Maya
-//
-//===========================================================================//
-
-#ifndef VSVGUIWINDOW_H
-#define VSVGUIWINDOW_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-
-#include "imayavgui.h"
-#include "vgui_controls/Frame.h"
-#include "tier1/utlmap.h"
-#include "valveMaya.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class IMayaVGui;
-
-
-//-----------------------------------------------------------------------------
-// The singleton is defined here twice just so we don't have to include valvemaya.h also
-//-----------------------------------------------------------------------------
-extern IMayaVGui *g_pMayaVGui;
-
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-namespace vgui
-{
- class EditablePanel;
-}
-
-
-class CVsVGuiWindowBase
-{
-public:
- virtual void SetPeriod( float flPeriod ) = 0;
- virtual void StartTick() = 0;
- virtual void StartTick( float flPeriod ) = 0;
- virtual void StopTick() = 0;
- virtual void Tick( float flElapsedTime ) = 0;
- virtual void NonTimerTick() = 0;
-};
-
-
-//-----------------------------------------------------------------------------
-// Creates, destroys a maya vgui window
-//-----------------------------------------------------------------------------
-CVsVGuiWindowBase *CreateMayaVGuiWindow( vgui::EditablePanel *pRootPanel, const char *pPanelName );
-void DestroyMayaVGuiWindow( const char *pPanelName );
-
-
-//-----------------------------------------------------------------------------
-// Factory used to install vgui windows easily
-//-----------------------------------------------------------------------------
-class CVsVguiWindowFactoryBase : public IMayaVguiWindowFactory
-{
-public:
- CVsVguiWindowFactoryBase( const char *pWindowTypeName, const char *pDccStartupCommand );
-
- // Returns the DCC command
- const char *GetDccStartupCommand() const;
-
- // Registers/deregisters all vgui windows
- static void RegisterAllVguiWindows( );
- static void UnregisterAllVguiWindows( );
-
-protected:
- const char *m_pWindowTypeName;
- const char *m_pDccStartupCommand;
-
-private:
- CVsVguiWindowFactoryBase *m_pNext;
- static CVsVguiWindowFactoryBase *s_pFirstCommandFactory;
-};
-
-template< class T >
-class CVsVguiWindowFactory : public CVsVguiWindowFactoryBase
-{
- typedef CVsVguiWindowFactoryBase BaseClass;
-
- static bool StringLessFunc( const CUtlString &a, const CUtlString &b )
- {
- return StringLessThan( a.Get(), b.Get() );
- }
-
-
-public:
- CVsVguiWindowFactory( const char *pWindowTypeName, const char *pDccCommand )
- : BaseClass( pWindowTypeName, pDccCommand )
- , m_panelMap( StringLessFunc )
- {
- }
-
- struct PanelMapElem_s
- {
- CVsVGuiWindowBase *m_pVGuiWindow;
- T *m_pPanel;
- };
-
- typedef CUtlMap< CUtlString, PanelMapElem_s > PanelMap_t;
-
- virtual void CreateVguiWindow( const char *pPanelName )
- {
- T *pVGuiPanel = new T( NULL, pPanelName );
- vgui::Frame *pFrame = dynamic_cast< vgui::Frame * >( pVGuiPanel );
-
- if ( pFrame )
- {
- pFrame->SetSizeable( false );
- pFrame->SetCloseButtonVisible( false );
- pFrame->SetMoveable( false );
-
- CVsVGuiWindowBase *pVGuiWindow = CreateMayaVGuiWindow( pVGuiPanel, pPanelName );
-
- const CUtlString panelName( pPanelName );
-
- PanelMap_t::IndexType_t nIndex = m_panelMap.Find( panelName );
- if ( m_panelMap.IsValidIndex( nIndex ) )
- {
- merr << "[vsVguiWindow]: Panel \"" << pPanelName << "\" of Type: \"" << m_pWindowTypeName << "\" Already Exists!!!" << std::endl;
- }
- else
- {
- PanelMap_t::ElemType_t &element = m_panelMap.Element( m_panelMap.Insert( panelName ) );
- element.m_pVGuiWindow = pVGuiWindow;
- element.m_pPanel = pVGuiPanel;
- }
- }
- }
-
- virtual void DestroyVguiWindow( const char *pPanelName )
- {
- PanelMap_t::IndexType_t nIndex = m_panelMap.Find( pPanelName );
- if ( !m_panelMap.IsValidIndex( nIndex ) )
- return;
-
- PanelMap_t::ElemType_t &element = m_panelMap.Element( nIndex );
- delete element.m_pPanel;
-
- m_panelMap.Remove( CUtlString( pPanelName ) );
- DestroyMayaVGuiWindow( pPanelName );
- }
-
- virtual vgui::Frame *GetVGuiPanel( const char *pPanelName = NULL )
- {
- if ( pPanelName )
- {
- PanelMap_t::IndexType_t nPanelIndex = m_panelMap.Find( CUtlString( pPanelName ) );
- if ( m_panelMap.IsValidIndex( nPanelIndex ) )
- return dynamic_cast< vgui::Frame * >( m_panelMap.Element( nPanelIndex ).m_pPanel );
- }
- else if ( m_panelMap.Count() > 0 )
- {
- return dynamic_cast< vgui::Frame * >( m_panelMap.Element( m_panelMap.FirstInorder() ).m_pPanel );
- }
-
- return NULL;
- }
-
- virtual CVsVGuiWindowBase *GetVGuiWindow( const char *pPanelName = NULL )
- {
- if ( pPanelName )
- {
- PanelMap_t::IndexType_t nPanelIndex = m_panelMap.Find( CUtlString( pPanelName ) );
- if ( m_panelMap.IsValidIndex( nPanelIndex ) )
- return m_panelMap.Element( nPanelIndex ).m_pVGuiWindow;
- }
- else if ( m_panelMap.Count() > 0 )
- {
- return m_panelMap.Element( m_panelMap.FirstInorder() ).m_pVGuiWindow;
- }
-
- return NULL;
- }
-
-private:
-
- PanelMap_t m_panelMap;
-};
-
-
-#define INSTALL_MAYA_VGUI_WINDOW( _className, _windowTypeName, _dccCommand ) \
- static CVsVguiWindowFactory< _className > s_VsVguiWindowFactory##_className##( _windowTypeName, _dccCommand )
-
-
-#endif // VSVGUIWINDOW_H
+//===== Copyright � 1996-2006, Valve Corporation, All rights reserved. ======//
+//
+// Base class for windows that draw vgui in Maya
+//
+//===========================================================================//
+
+#ifndef VSVGUIWINDOW_H
+#define VSVGUIWINDOW_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+#include "imayavgui.h"
+#include "vgui_controls/Frame.h"
+#include "tier1/utlmap.h"
+#include "valveMaya.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class IMayaVGui;
+
+
+//-----------------------------------------------------------------------------
+// The singleton is defined here twice just so we don't have to include valvemaya.h also
+//-----------------------------------------------------------------------------
+extern IMayaVGui *g_pMayaVGui;
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+namespace vgui
+{
+ class EditablePanel;
+}
+
+
+class CVsVGuiWindowBase
+{
+public:
+ virtual void SetPeriod( float flPeriod ) = 0;
+ virtual void StartTick() = 0;
+ virtual void StartTick( float flPeriod ) = 0;
+ virtual void StopTick() = 0;
+ virtual void Tick( float flElapsedTime ) = 0;
+ virtual void NonTimerTick() = 0;
+};
+
+
+//-----------------------------------------------------------------------------
+// Creates, destroys a maya vgui window
+//-----------------------------------------------------------------------------
+CVsVGuiWindowBase *CreateMayaVGuiWindow( vgui::EditablePanel *pRootPanel, const char *pPanelName );
+void DestroyMayaVGuiWindow( const char *pPanelName );
+
+
+//-----------------------------------------------------------------------------
+// Factory used to install vgui windows easily
+//-----------------------------------------------------------------------------
+class CVsVguiWindowFactoryBase : public IMayaVguiWindowFactory
+{
+public:
+ CVsVguiWindowFactoryBase( const char *pWindowTypeName, const char *pDccStartupCommand );
+
+ // Returns the DCC command
+ const char *GetDccStartupCommand() const;
+
+ // Registers/deregisters all vgui windows
+ static void RegisterAllVguiWindows( );
+ static void UnregisterAllVguiWindows( );
+
+protected:
+ const char *m_pWindowTypeName;
+ const char *m_pDccStartupCommand;
+
+private:
+ CVsVguiWindowFactoryBase *m_pNext;
+ static CVsVguiWindowFactoryBase *s_pFirstCommandFactory;
+};
+
+template< class T >
+class CVsVguiWindowFactory : public CVsVguiWindowFactoryBase
+{
+ typedef CVsVguiWindowFactoryBase BaseClass;
+
+ static bool StringLessFunc( const CUtlString &a, const CUtlString &b )
+ {
+ return StringLessThan( a.Get(), b.Get() );
+ }
+
+
+public:
+ CVsVguiWindowFactory( const char *pWindowTypeName, const char *pDccCommand )
+ : BaseClass( pWindowTypeName, pDccCommand )
+ , m_panelMap( StringLessFunc )
+ {
+ }
+
+ struct PanelMapElem_s
+ {
+ CVsVGuiWindowBase *m_pVGuiWindow;
+ T *m_pPanel;
+ };
+
+ typedef CUtlMap< CUtlString, PanelMapElem_s > PanelMap_t;
+
+ virtual void CreateVguiWindow( const char *pPanelName )
+ {
+ T *pVGuiPanel = new T( NULL, pPanelName );
+ vgui::Frame *pFrame = dynamic_cast< vgui::Frame * >( pVGuiPanel );
+
+ if ( pFrame )
+ {
+ pFrame->SetSizeable( false );
+ pFrame->SetCloseButtonVisible( false );
+ pFrame->SetMoveable( false );
+
+ CVsVGuiWindowBase *pVGuiWindow = CreateMayaVGuiWindow( pVGuiPanel, pPanelName );
+
+ const CUtlString panelName( pPanelName );
+
+ PanelMap_t::IndexType_t nIndex = m_panelMap.Find( panelName );
+ if ( m_panelMap.IsValidIndex( nIndex ) )
+ {
+ merr << "[vsVguiWindow]: Panel \"" << pPanelName << "\" of Type: \"" << m_pWindowTypeName << "\" Already Exists!!!" << std::endl;
+ }
+ else
+ {
+ PanelMap_t::ElemType_t &element = m_panelMap.Element( m_panelMap.Insert( panelName ) );
+ element.m_pVGuiWindow = pVGuiWindow;
+ element.m_pPanel = pVGuiPanel;
+ }
+ }
+ }
+
+ virtual void DestroyVguiWindow( const char *pPanelName )
+ {
+ PanelMap_t::IndexType_t nIndex = m_panelMap.Find( pPanelName );
+ if ( !m_panelMap.IsValidIndex( nIndex ) )
+ return;
+
+ PanelMap_t::ElemType_t &element = m_panelMap.Element( nIndex );
+ delete element.m_pPanel;
+
+ m_panelMap.Remove( CUtlString( pPanelName ) );
+ DestroyMayaVGuiWindow( pPanelName );
+ }
+
+ virtual vgui::Frame *GetVGuiPanel( const char *pPanelName = NULL )
+ {
+ if ( pPanelName )
+ {
+ PanelMap_t::IndexType_t nPanelIndex = m_panelMap.Find( CUtlString( pPanelName ) );
+ if ( m_panelMap.IsValidIndex( nPanelIndex ) )
+ return dynamic_cast< vgui::Frame * >( m_panelMap.Element( nPanelIndex ).m_pPanel );
+ }
+ else if ( m_panelMap.Count() > 0 )
+ {
+ return dynamic_cast< vgui::Frame * >( m_panelMap.Element( m_panelMap.FirstInorder() ).m_pPanel );
+ }
+
+ return NULL;
+ }
+
+ virtual CVsVGuiWindowBase *GetVGuiWindow( const char *pPanelName = NULL )
+ {
+ if ( pPanelName )
+ {
+ PanelMap_t::IndexType_t nPanelIndex = m_panelMap.Find( CUtlString( pPanelName ) );
+ if ( m_panelMap.IsValidIndex( nPanelIndex ) )
+ return m_panelMap.Element( nPanelIndex ).m_pVGuiWindow;
+ }
+ else if ( m_panelMap.Count() > 0 )
+ {
+ return m_panelMap.Element( m_panelMap.FirstInorder() ).m_pVGuiWindow;
+ }
+
+ return NULL;
+ }
+
+private:
+
+ PanelMap_t m_panelMap;
+};
+
+
+#define INSTALL_MAYA_VGUI_WINDOW( _className, _windowTypeName, _dccCommand ) \
+ static CVsVguiWindowFactory< _className > s_VsVguiWindowFactory##_className##( _windowTypeName, _dccCommand )
+
+
+#endif // VSVGUIWINDOW_H
diff --git a/mp/src/public/maya/valveMaya.h b/mp/src/public/maya/valveMaya.h
index f500d6e3..036ab2f2 100644
--- a/mp/src/public/maya/valveMaya.h
+++ b/mp/src/public/maya/valveMaya.h
@@ -1,672 +1,672 @@
-//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
-//
-// Purpose:
-//
-//=============================================================================
-
-#ifndef VALVEMAYA_H
-#define VALVEMAYA_H
-
-#if defined( _WIN32 )
-#pragma once
-#endif
-
-// Maya Includes
-
-#include <maya/MAngle.h>
-#include <maya/MDagModifier.h>
-#include <maya/MEulerRotation.h>
-#include <maya/MFloatVector.h>
-#include <maya/MGlobal.h>
-#include <maya/MIOStream.h>
-#include <maya/MMatrix.h>
-#include <maya/MObject.h>
-#include <maya/MQuaternion.h>
-#include <maya/MSyntax.h>
-#include <maya/MString.h>
-#include <maya/MDagPath.h>
-#include <maya/MVector.h>
-
-// Valve Includes
-
-#include "tier1/stringpool.h"
-#include "tier1/utlstring.h"
-#include "tier1/utlstringmap.h"
-#include "tier1/utlvector.h"
-#include "tier1/interface.h"
-#include "mathlib/mathlib.h"
-
-#include "ValveMaya/Undo.h"
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
-class IMayaVGui;
-
-
-//-----------------------------------------------------------------------------
-// Maya-specific library singletons
-//-----------------------------------------------------------------------------
-extern IMayaVGui *g_pMayaVGui;
-
-
-//-----------------------------------------------------------------------------
-//
-// Purpose: Group a bunch of functions into the Valve Maya Namespace
-//
-//-----------------------------------------------------------------------------
-
-
-namespace ValveMaya
-{
- //-----------------------------------------------------------------------------
- // Forward declarations
- //-----------------------------------------------------------------------------
- class CUndo;
-
- //-----------------------------------------------------------------------------
- // Statics
- //-----------------------------------------------------------------------------
- extern const MQuaternion v2mQuat; // Valve Engine -> Maya Quaternion
- extern const MQuaternion m2vQuat; // Maya -> Valve Engine Quaternion
- extern const MMatrix v2mMat; // Valve Engine -> Maya Matrix
- extern const MMatrix m2vMat; // Maya -> Valve Engine Matrix
-
- extern const MQuaternion vc2mcQuat; // Valve Engine Camera -> Maya Camera Quaternion
- extern const MQuaternion mc2vcQuat; // Maya Camera -> Valve Camera Engine Quaternion
- extern const MMatrix vc2mcMat; // Valve Engine Camera -> Maya Camera Quaternion
- extern const MMatrix mc2vcMat; // Maya Camera -> Valve Camera Engine Quaternion
-
- inline MQuaternion ValveToMaya( const MQuaternion &q ) { return q * v2mQuat; }
- inline MQuaternion ValveCameraToMayaCamera( const MQuaternion &q ) { return vc2mcQuat * q * v2mQuat; }
- inline MQuaternion MayaToValve( const MQuaternion &q ) { return q * m2vQuat; }
- inline MQuaternion MayaCameraToValveCamera( const MQuaternion &q ) { return mc2vcQuat * q * m2vQuat; }
-
- inline MVector ValveToMaya( const MVector &p ) { return p.rotateBy( v2mQuat ); }
- inline MVector ValveCameraToMayaCamera( const MVector &p ) { return p.rotateBy( v2mQuat ); }
- inline MVector MayaToValve( const MVector &p ) { return p.rotateBy( m2vQuat ); }
- inline MVector MayaCameraToValveCamera( const MVector &p ) { return p.rotateBy( m2vQuat ); }
-
-//-----------------------------------------------------------------------------
-// Connect, disconnect
-//-----------------------------------------------------------------------------
-bool ConnectLibraries( CreateInterfaceFn factory );
-void DisconnectLibraries();
-
-MStatus CreateDagNode(
- const char *const i_nodeType,
- const char *const i_transformName = NULL,
- const MObject &i_parentObj = MObject::kNullObj,
- MObject *o_pTransformObj = NULL,
- MObject *o_pShapeObj = NULL,
- MDagModifier *i_mDagModifier = NULL);
-
-inline MStatus CreateDagNode(
- CUndo &undo,
- const char *const i_nodeType,
- const char *const i_transformName = NULL,
- const MObject &i_parentObj = MObject::kNullObj,
- MObject *o_pTransformObj = NULL,
- MObject *o_pShapeObj = NULL )
-{
- return CreateDagNode( i_nodeType, i_transformName, i_parentObj, o_pTransformObj, o_pShapeObj, &undo.DagModifier() );
-}
-
-bool IsNodeVisible( const MDagPath &mDagPath, bool bTemplateAsInvisible = true );
-bool IsPathVisible( MDagPath mDagPath, bool bTemplateAsInvisible = true );
-
-class CMSyntaxHelp
-{
-public:
- CMSyntaxHelp()
- : m_groupedHelp( false ) // Make case sensitive
- , m_helpCount( 0 )
- , m_shortNameLength( 0 )
- {}
-
- void Clear();
-
- MStatus AddFlag(
- MSyntax &i_mSyntax,
- const char *i_shortName,
- const char *i_longName,
- const char *i_group,
- const char *i_help,
- const MSyntax::MArgType i_argType1 = MSyntax::kNoArg,
- const MSyntax::MArgType i_argType2 = MSyntax::kNoArg,
- const MSyntax::MArgType i_argType3 = MSyntax::kNoArg,
- const MSyntax::MArgType i_argType4 = MSyntax::kNoArg,
- const MSyntax::MArgType i_argType5 = MSyntax::kNoArg,
- const MSyntax::MArgType i_argType6 = MSyntax::kNoArg);
-
- void PrintHelp(
- const char *const i_cmdName,
- const char *const i_cmdDesc,
- int i_lineLength = 0U);
-
- void PrintHelp(
- const MString &i_cmdName,
- const MString &i_cmdDesc,
- int i_lineLength = 0U)
- {
- PrintHelp( i_cmdName.asChar(), i_cmdDesc.asChar(), i_lineLength );
- }
-
-protected:
-public:
-protected:
- CCountedStringPool m_stringPool;
-
- struct HelpData_t
- {
- const char *m_shortName;
- const char *m_longName;
- const char *m_help;
- CUtlVector<MSyntax::MArgType> m_argTypes;
- };
-
- CUtlVector<const char *> m_groupOrder;
- CUtlStringMap<CUtlVector<HelpData_t> > m_groupedHelp;
- int m_helpCount;
- int m_shortNameLength;
-};
-
-MString RemoveNameSpace( const MString &mString );
-
-MString &BackslashToSlash( MString &mString );
-
-template < class T_t > bool IsDefault( T_t &, const MPlug & );
-
-bool IsDefault( const MPlug &aPlug );
-
-uint NextAvailable( MPlug &mPlug );
-
-MPlug NextAvailablePlug( MPlug &mPlug );
-
-MObject AddColorSetToMesh(
- const MString &colorSetName,
- const MDagPath &mDagPath,
- MDagModifier &mDagModifier );
-
-MString GetMaterialPath(
- const MObject &shadingGroupObj,
- MObject *pSurfaceShaderObj,
- MObject *pFileObj,
- MObject *pPlace2dTextureObj,
- MObject *pVmtObj,
- bool *pbTransparent,
- MString *pDebugWhy );
-
-// Returns the first node that is connected to the specified plug as input or output
-MObject FindConnectedNode( const MPlug &mPlug );
-
-// Returns the plug connected to the specified plug as an input, a NULL plug if no plug is connected
-MPlug FindInputPlug( const MPlug &dstPlug );
-
-MPlug FindInputPlug( const MObject &dstNodeObj, const MString &dstPlugName );
-
-MObject FindInputNode( const MPlug &dstPlug );
-
-MObject FindInputNode( const MObject &dstNodeObj, const MString &dstPlugName );
-
-MObject FindInputAttr( const MPlug &dstPlug );
-
-MObject FindInputAttr( const MObject &dstNodeObj, const MString &dstPlugName );
-
-// Returns the first found node MObject of the specified type in the history of the specified node
-MObject FindInputNodeOfType( const MObject &dstNodeObj, const MString &typeName, const MString &dstPlugName );
-
-MObject FindInputNodeOfType( const MObject &dstNodeObj, const MString &typeName, MSelectionList &doneList );
-
-// Creates a deformer of the specified type and deforms the specified shape with an optional component
-MObject DeformShape( ValveMaya::CUndo &undo, const MString &deformerType, const MDagPath &inOrigDagPath, MObject &origCompObj = MObject::kNullObj );
-
-bool Substitute( MString &str, const MString &searchStr, const MString &replaceStr );
-
-bool SubstituteCaseInsensitive( MString &str, const MString &searchStr, const MString &replaceStr );
-
-bool SubstituteAll( MString &str, const MString &searchStr, const MString &replaceStr );
-
-bool SubstituteAllCaseInsensitive( MString &str, const MString &searchStr, const MString &replaceStr );
-
-void FixSlashes( MString &str, char correctPathSeparator = '/' );
-
-//-----------------------------------------------------------------------------
-// Converts a Maya MMatrix to a Valve matrix3x4_t (transpose)
-//-----------------------------------------------------------------------------
-inline void MatrixMayaToValve( matrix3x4_t &mValve, const MMatrix &mMaya )
-{
- mValve[0][0] = mMaya[0][0]; mValve[0][1] = mMaya[1][0]; mValve[0][2] = mMaya[2][0]; mValve[0][3] = mMaya[3][0];
- mValve[1][0] = mMaya[0][1]; mValve[1][1] = mMaya[1][1]; mValve[1][2] = mMaya[2][1]; mValve[1][3] = mMaya[3][1];
- mValve[2][0] = mMaya[0][2]; mValve[2][1] = mMaya[1][2]; mValve[2][2] = mMaya[2][2]; mValve[2][3] = mMaya[3][2];
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Valve matrix3x4_t to a Maya MMatrix (transpose)
-//-----------------------------------------------------------------------------
-inline void MatrixValveToMaya( MMatrix &mMaya, const matrix3x4_t &mValve )
-{
- mMaya[0][0] = mValve[0][0]; mMaya[0][1] = mValve[1][0]; mMaya[0][2] = mValve[2][0]; mMaya[3][0] = 0.0;
- mMaya[1][0] = mValve[0][1]; mMaya[1][1] = mValve[1][1]; mMaya[1][2] = mValve[2][1]; mMaya[3][1] = 0.0;
- mMaya[2][0] = mValve[0][2]; mMaya[2][1] = mValve[1][2]; mMaya[2][2] = mValve[2][2]; mMaya[3][2] = 0.0;
- mMaya[3][0] = mValve[0][3]; mMaya[3][1] = mValve[1][3]; mMaya[3][2] = mValve[2][3]; mMaya[3][3] = 1.0;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Maya MVector to a Valve Vector
-//-----------------------------------------------------------------------------
-inline void VectorMayaToValve( Vector &vValve, const MVector &vMaya )
-{
- vValve.x = vMaya.x;
- vValve.y = vMaya.y;
- vValve.z = vMaya.z;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Valve Vector to a Maya MVector
-//-----------------------------------------------------------------------------
-inline void VectorValveToMaya( MVector &vMaya, const Vector &vValve )
-{
- vMaya.x = vValve.x;
- vMaya.y = vValve.y;
- vMaya.z = vValve.z;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Maya MQuaternion to a Valve Quaternion
-//-----------------------------------------------------------------------------
-inline void QuaternionMayaToValve( Quaternion &qValve, const MQuaternion &qMaya )
-{
- qValve.x = qMaya.x;
- qValve.y = qMaya.y;
- qValve.z = qMaya.z;
- qValve.w = qMaya.w;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Maya MQuaternion to a Valve Quaternion
-//-----------------------------------------------------------------------------
-inline void QuaternionMayaToValve( Quaternion &qValve, const MEulerRotation &eMaya )
-{
- const MQuaternion qMaya = eMaya.asQuaternion();
-
- qValve.x = qMaya.x;
- qValve.y = qMaya.y;
- qValve.z = qMaya.z;
- qValve.w = qMaya.w;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Valve Quaternion to a Maya MQuaternion
-//-----------------------------------------------------------------------------
-inline void QuaternionValveToMaya( MQuaternion &qMaya, const Quaternion &qValve )
-{
- qMaya.x = qValve.x;
- qMaya.y = qValve.y;
- qMaya.z = qValve.z;
- qMaya.w = qValve.w;
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Valve Quaternion to a Maya MQuaternion
-//-----------------------------------------------------------------------------
-inline void QuaternionValveToMaya( MEulerRotation &eMaya, const Quaternion &qValve )
-{
- MQuaternion qMaya;
- QuaternionValveToMaya( qMaya, qValve );
-
- const MEulerRotation::RotationOrder roTmp = eMaya.order;
-
- eMaya = qMaya;
-
- if ( eMaya.order != roTmp )
- {
- eMaya.reorder( roTmp );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Maya MEulerRotation to a Valve RadianEuler
-//-----------------------------------------------------------------------------
-inline void RadianEulerMayaToValve( RadianEuler &eValve, const MEulerRotation &eMaya )
-{
- if ( eMaya.order == MEulerRotation::kXYZ )
- {
- eValve.x = eMaya.x;
- eValve.y = eMaya.y;
- eValve.z = eMaya.z;
- }
- else
- {
- MEulerRotation eTmp = eMaya;
- eTmp.reorder( MEulerRotation::kXYZ );
-
- eValve.x = eTmp.x;
- eValve.y = eTmp.y;
- eValve.z = eTmp.z;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Converts a Valve RadianEuler to a Maya MEulerRotation
-//-----------------------------------------------------------------------------
-inline void RadianEulerValveToMaya( MEulerRotation &eMaya, const RadianEuler &eValve )
-{
- const MEulerRotation::RotationOrder roTmp = eMaya.order;
-
- if ( roTmp == MEulerRotation::kXYZ )
- {
- eMaya.x = eValve.x;
- eMaya.y = eValve.y;
- eMaya.z = eValve.z;
- }
- else
- {
- eMaya.reorder( MEulerRotation::kXYZ );
-
- eMaya.x = eValve.x;
- eMaya.y = eValve.y;
- eMaya.z = eValve.z;
-
- eMaya.reorder( roTmp );
- }
-}
-
-
-} // end namespace ValveMaya
-
-
-// Make an alias for the ValveMaya namespace
-
-namespace vm = ValveMaya;
-
-
-//-----------------------------------------------------------------------------
-// A simple stream class for printing information to the Maya script editor
-//-----------------------------------------------------------------------------
-class CMayaStream
-{
-public:
- enum StreamType { kInfo, kWarning, kError };
-
- CMayaStream( const StreamType i_streamType = kInfo )
- : m_streamType( i_streamType )
- {}
-
- template < class T_t >
- CMayaStream &operator<<( const T_t &v );
-
- // This is a hack so CMayaStream << std::endl works as expected
- CMayaStream &operator<<( std::ostream &(*StdEndl_t)( std::ostream & ) )
- {
- return flush();
- }
-
- CMayaStream &flush() { return outputString(); }
-
-protected:
- CMayaStream &outputString()
- {
- // Always ensure it's terminated with a newline
- if ( *( m_string.asChar() + m_string.length() - 1 ) != '\n' )
- {
- m_string += "\n";
- }
-
- const char *pBegin = m_string.asChar();
- const char *const pEnd = pBegin + m_string.length();
- const char *pCurr = pBegin;
-
- while ( *pCurr && pCurr < pEnd )
- {
- if ( *pCurr == '\n' )
- {
- switch ( m_streamType )
- {
- case kWarning:
- MGlobal::displayWarning( MString( pBegin, pCurr - pBegin ) );
- break;
- case kError:
- MGlobal::displayError( MString( pBegin, pCurr - pBegin ) );
- break;
- default:
- MGlobal::displayInfo( MString( pBegin, pCurr - pBegin ) );
- break;
- }
-
- ++pCurr;
- pBegin = pCurr;
- }
- else
- {
- ++pCurr;
- }
- }
-
- m_string.clear();
-
- return *this;
- }
-
- CMayaStream &checkForFlush()
- {
- const char *pCurr = m_string.asChar();
- const char *pEnd = pCurr + m_string.length();
- while ( *pCurr && pCurr != pEnd )
- {
- if ( *pCurr == '\n' )
- {
- return outputString();
- }
-
- ++pCurr;
- }
-
- return *this;
- }
-
- StreamType m_streamType;
- MString m_string;
-};
-
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-class CMayaWarnStream : public CMayaStream
-{
-public:
- CMayaWarnStream()
- : CMayaStream( CMayaStream::kWarning )
- {}
-
-};
-
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-class CMayaErrStream : public CMayaStream
-{
-public:
- CMayaErrStream()
- : CMayaStream( CMayaStream::kError )
- {}
-};
-
-
-//-----------------------------------------------------------------------------
-// Specialization for std::string
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const std::string &v )
-{
- *this << v.c_str();
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for char
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const char &v )
-{
- m_string += MString( &v, 1 );
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for MVector
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const MVector &v )
-{
- m_string += v.x;
- m_string += " ";
- m_string += v.y;
- m_string += " ";
- m_string += v.z;
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for MFloatVector
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const MFloatVector &v )
-{
- m_string += v.x;
- m_string += " ";
- m_string += v.y;
- m_string += " ";
- m_string += v.z;
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for MEulerRotation
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const MEulerRotation &e )
-{
- m_string += MAngle( e.x, MAngle::kRadians ).asDegrees();
- m_string += " ";
- m_string += MAngle( e.y, MAngle::kRadians ).asDegrees();
- m_string += " ";
- m_string += MAngle( e.z, MAngle::kRadians ).asDegrees();
- switch ( e.order )
- {
- case MEulerRotation::kXYZ:
- m_string += " (XYZ)";
- break;
- case MEulerRotation::kXZY:
- m_string += " (XZY)";
- break;
- case MEulerRotation::kYXZ:
- m_string += " (YXZ)";
- break;
- case MEulerRotation::kYZX:
- m_string += " (YZX)";
- break;
- case MEulerRotation::kZXY:
- m_string += " (ZXY)";
- break;
- case MEulerRotation::kZYX:
- m_string += " (ZYX)";
- break;
- default:
- m_string += " (Unknown)";
- break;
- }
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for MQuaternion
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const MQuaternion &q )
-{
- m_string += q.x;
- m_string += " ";
- m_string += q.y;
- m_string += " ";
- m_string += q.z;
- m_string += " ";
- m_string += q.w;
-
- m_string += " (";
- operator<<( q.asEulerRotation() );
- m_string += ")";
-
- return *this;
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for Quaternion
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const Quaternion &q )
-{
- return operator<<( MQuaternion( q.x, q.y, q.z, q.w ) );
-}
-
-
-//-----------------------------------------------------------------------------
-// Specialization for RadianEuler
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const RadianEuler &e )
-{
- return operator<<( MEulerRotation( e.x, e.y, e.z ) );
-}
-
-//-----------------------------------------------------------------------------
-// Specialization for RadianEuler
-//-----------------------------------------------------------------------------
-template <>
-inline CMayaStream &CMayaStream::operator<<( const Vector &v )
-{
- return operator<<( MVector( v.x, v.y, v.z ) );
-}
-
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-template < class T_t >
-inline CMayaStream &CMayaStream::operator<<( const T_t &v )
-{
- m_string += v;
- return checkForFlush();
-}
-
-
-//-----------------------------------------------------------------------------
-//
-// minfo, mwarn & merr are ostreams which can be used to send stuff to
-// the Maya history window
-//
-//-----------------------------------------------------------------------------
-
-extern CMayaStream minfo;
-extern CMayaWarnStream mwarn;
-extern CMayaErrStream merr;
-
-
-#endif // VALVEMAYA_H
+//======= Copyright � 1996-2006, Valve Corporation, All rights reserved. ======
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef VALVEMAYA_H
+#define VALVEMAYA_H
+
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+// Maya Includes
+
+#include <maya/MAngle.h>
+#include <maya/MDagModifier.h>
+#include <maya/MEulerRotation.h>
+#include <maya/MFloatVector.h>
+#include <maya/MGlobal.h>
+#include <maya/MIOStream.h>
+#include <maya/MMatrix.h>
+#include <maya/MObject.h>
+#include <maya/MQuaternion.h>
+#include <maya/MSyntax.h>
+#include <maya/MString.h>
+#include <maya/MDagPath.h>
+#include <maya/MVector.h>
+
+// Valve Includes
+
+#include "tier1/stringpool.h"
+#include "tier1/utlstring.h"
+#include "tier1/utlstringmap.h"
+#include "tier1/utlvector.h"
+#include "tier1/interface.h"
+#include "mathlib/mathlib.h"
+
+#include "ValveMaya/Undo.h"
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class IMayaVGui;
+
+
+//-----------------------------------------------------------------------------
+// Maya-specific library singletons
+//-----------------------------------------------------------------------------
+extern IMayaVGui *g_pMayaVGui;
+
+
+//-----------------------------------------------------------------------------
+//
+// Purpose: Group a bunch of functions into the Valve Maya Namespace
+//
+//-----------------------------------------------------------------------------
+
+
+namespace ValveMaya
+{
+ //-----------------------------------------------------------------------------
+ // Forward declarations
+ //-----------------------------------------------------------------------------
+ class CUndo;
+
+ //-----------------------------------------------------------------------------
+ // Statics
+ //-----------------------------------------------------------------------------
+ extern const MQuaternion v2mQuat; // Valve Engine -> Maya Quaternion
+ extern const MQuaternion m2vQuat; // Maya -> Valve Engine Quaternion
+ extern const MMatrix v2mMat; // Valve Engine -> Maya Matrix
+ extern const MMatrix m2vMat; // Maya -> Valve Engine Matrix
+
+ extern const MQuaternion vc2mcQuat; // Valve Engine Camera -> Maya Camera Quaternion
+ extern const MQuaternion mc2vcQuat; // Maya Camera -> Valve Camera Engine Quaternion
+ extern const MMatrix vc2mcMat; // Valve Engine Camera -> Maya Camera Quaternion
+ extern const MMatrix mc2vcMat; // Maya Camera -> Valve Camera Engine Quaternion
+
+ inline MQuaternion ValveToMaya( const MQuaternion &q ) { return q * v2mQuat; }
+ inline MQuaternion ValveCameraToMayaCamera( const MQuaternion &q ) { return vc2mcQuat * q * v2mQuat; }
+ inline MQuaternion MayaToValve( const MQuaternion &q ) { return q * m2vQuat; }
+ inline MQuaternion MayaCameraToValveCamera( const MQuaternion &q ) { return mc2vcQuat * q * m2vQuat; }
+
+ inline MVector ValveToMaya( const MVector &p ) { return p.rotateBy( v2mQuat ); }
+ inline MVector ValveCameraToMayaCamera( const MVector &p ) { return p.rotateBy( v2mQuat ); }
+ inline MVector MayaToValve( const MVector &p ) { return p.rotateBy( m2vQuat ); }
+ inline MVector MayaCameraToValveCamera( const MVector &p ) { return p.rotateBy( m2vQuat ); }
+
+//-----------------------------------------------------------------------------
+// Connect, disconnect
+//-----------------------------------------------------------------------------
+bool ConnectLibraries( CreateInterfaceFn factory );
+void DisconnectLibraries();
+
+MStatus CreateDagNode(
+ const char *const i_nodeType,
+ const char *const i_transformName = NULL,
+ const MObject &i_parentObj = MObject::kNullObj,
+ MObject *o_pTransformObj = NULL,
+ MObject *o_pShapeObj = NULL,
+ MDagModifier *i_mDagModifier = NULL);
+
+inline MStatus CreateDagNode(
+ CUndo &undo,
+ const char *const i_nodeType,
+ const char *const i_transformName = NULL,
+ const MObject &i_parentObj = MObject::kNullObj,
+ MObject *o_pTransformObj = NULL,
+ MObject *o_pShapeObj = NULL )
+{
+ return CreateDagNode( i_nodeType, i_transformName, i_parentObj, o_pTransformObj, o_pShapeObj, &undo.DagModifier() );
+}
+
+bool IsNodeVisible( const MDagPath &mDagPath, bool bTemplateAsInvisible = true );
+bool IsPathVisible( MDagPath mDagPath, bool bTemplateAsInvisible = true );
+
+class CMSyntaxHelp
+{
+public:
+ CMSyntaxHelp()
+ : m_groupedHelp( false ) // Make case sensitive
+ , m_helpCount( 0 )
+ , m_shortNameLength( 0 )
+ {}
+
+ void Clear();
+
+ MStatus AddFlag(
+ MSyntax &i_mSyntax,
+ const char *i_shortName,
+ const char *i_longName,
+ const char *i_group,
+ const char *i_help,
+ const MSyntax::MArgType i_argType1 = MSyntax::kNoArg,
+ const MSyntax::MArgType i_argType2 = MSyntax::kNoArg,
+ const MSyntax::MArgType i_argType3 = MSyntax::kNoArg,
+ const MSyntax::MArgType i_argType4 = MSyntax::kNoArg,
+ const MSyntax::MArgType i_argType5 = MSyntax::kNoArg,
+ const MSyntax::MArgType i_argType6 = MSyntax::kNoArg);
+
+ void PrintHelp(
+ const char *const i_cmdName,
+ const char *const i_cmdDesc,
+ int i_lineLength = 0U);
+
+ void PrintHelp(
+ const MString &i_cmdName,
+ const MString &i_cmdDesc,
+ int i_lineLength = 0U)
+ {
+ PrintHelp( i_cmdName.asChar(), i_cmdDesc.asChar(), i_lineLength );
+ }
+
+protected:
+public:
+protected:
+ CCountedStringPool m_stringPool;
+
+ struct HelpData_t
+ {
+ const char *m_shortName;
+ const char *m_longName;
+ const char *m_help;
+ CUtlVector<MSyntax::MArgType> m_argTypes;
+ };
+
+ CUtlVector<const char *> m_groupOrder;
+ CUtlStringMap<CUtlVector<HelpData_t> > m_groupedHelp;
+ int m_helpCount;
+ int m_shortNameLength;
+};
+
+MString RemoveNameSpace( const MString &mString );
+
+MString &BackslashToSlash( MString &mString );
+
+template < class T_t > bool IsDefault( T_t &, const MPlug & );
+
+bool IsDefault( const MPlug &aPlug );
+
+uint NextAvailable( MPlug &mPlug );
+
+MPlug NextAvailablePlug( MPlug &mPlug );
+
+MObject AddColorSetToMesh(
+ const MString &colorSetName,
+ const MDagPath &mDagPath,
+ MDagModifier &mDagModifier );
+
+MString GetMaterialPath(
+ const MObject &shadingGroupObj,
+ MObject *pSurfaceShaderObj,
+ MObject *pFileObj,
+ MObject *pPlace2dTextureObj,
+ MObject *pVmtObj,
+ bool *pbTransparent,
+ MString *pDebugWhy );
+
+// Returns the first node that is connected to the specified plug as input or output
+MObject FindConnectedNode( const MPlug &mPlug );
+
+// Returns the plug connected to the specified plug as an input, a NULL plug if no plug is connected
+MPlug FindInputPlug( const MPlug &dstPlug );
+
+MPlug FindInputPlug( const MObject &dstNodeObj, const MString &dstPlugName );
+
+MObject FindInputNode( const MPlug &dstPlug );
+
+MObject FindInputNode( const MObject &dstNodeObj, const MString &dstPlugName );
+
+MObject FindInputAttr( const MPlug &dstPlug );
+
+MObject FindInputAttr( const MObject &dstNodeObj, const MString &dstPlugName );
+
+// Returns the first found node MObject of the specified type in the history of the specified node
+MObject FindInputNodeOfType( const MObject &dstNodeObj, const MString &typeName, const MString &dstPlugName );
+
+MObject FindInputNodeOfType( const MObject &dstNodeObj, const MString &typeName, MSelectionList &doneList );
+
+// Creates a deformer of the specified type and deforms the specified shape with an optional component
+MObject DeformShape( ValveMaya::CUndo &undo, const MString &deformerType, const MDagPath &inOrigDagPath, MObject &origCompObj = MObject::kNullObj );
+
+bool Substitute( MString &str, const MString &searchStr, const MString &replaceStr );
+
+bool SubstituteCaseInsensitive( MString &str, const MString &searchStr, const MString &replaceStr );
+
+bool SubstituteAll( MString &str, const MString &searchStr, const MString &replaceStr );
+
+bool SubstituteAllCaseInsensitive( MString &str, const MString &searchStr, const MString &replaceStr );
+
+void FixSlashes( MString &str, char correctPathSeparator = '/' );
+
+//-----------------------------------------------------------------------------
+// Converts a Maya MMatrix to a Valve matrix3x4_t (transpose)
+//-----------------------------------------------------------------------------
+inline void MatrixMayaToValve( matrix3x4_t &mValve, const MMatrix &mMaya )
+{
+ mValve[0][0] = mMaya[0][0]; mValve[0][1] = mMaya[1][0]; mValve[0][2] = mMaya[2][0]; mValve[0][3] = mMaya[3][0];
+ mValve[1][0] = mMaya[0][1]; mValve[1][1] = mMaya[1][1]; mValve[1][2] = mMaya[2][1]; mValve[1][3] = mMaya[3][1];
+ mValve[2][0] = mMaya[0][2]; mValve[2][1] = mMaya[1][2]; mValve[2][2] = mMaya[2][2]; mValve[2][3] = mMaya[3][2];
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Valve matrix3x4_t to a Maya MMatrix (transpose)
+//-----------------------------------------------------------------------------
+inline void MatrixValveToMaya( MMatrix &mMaya, const matrix3x4_t &mValve )
+{
+ mMaya[0][0] = mValve[0][0]; mMaya[0][1] = mValve[1][0]; mMaya[0][2] = mValve[2][0]; mMaya[3][0] = 0.0;
+ mMaya[1][0] = mValve[0][1]; mMaya[1][1] = mValve[1][1]; mMaya[1][2] = mValve[2][1]; mMaya[3][1] = 0.0;
+ mMaya[2][0] = mValve[0][2]; mMaya[2][1] = mValve[1][2]; mMaya[2][2] = mValve[2][2]; mMaya[3][2] = 0.0;
+ mMaya[3][0] = mValve[0][3]; mMaya[3][1] = mValve[1][3]; mMaya[3][2] = mValve[2][3]; mMaya[3][3] = 1.0;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Maya MVector to a Valve Vector
+//-----------------------------------------------------------------------------
+inline void VectorMayaToValve( Vector &vValve, const MVector &vMaya )
+{
+ vValve.x = vMaya.x;
+ vValve.y = vMaya.y;
+ vValve.z = vMaya.z;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Valve Vector to a Maya MVector
+//-----------------------------------------------------------------------------
+inline void VectorValveToMaya( MVector &vMaya, const Vector &vValve )
+{
+ vMaya.x = vValve.x;
+ vMaya.y = vValve.y;
+ vMaya.z = vValve.z;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Maya MQuaternion to a Valve Quaternion
+//-----------------------------------------------------------------------------
+inline void QuaternionMayaToValve( Quaternion &qValve, const MQuaternion &qMaya )
+{
+ qValve.x = qMaya.x;
+ qValve.y = qMaya.y;
+ qValve.z = qMaya.z;
+ qValve.w = qMaya.w;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Maya MQuaternion to a Valve Quaternion
+//-----------------------------------------------------------------------------
+inline void QuaternionMayaToValve( Quaternion &qValve, const MEulerRotation &eMaya )
+{
+ const MQuaternion qMaya = eMaya.asQuaternion();
+
+ qValve.x = qMaya.x;
+ qValve.y = qMaya.y;
+ qValve.z = qMaya.z;
+ qValve.w = qMaya.w;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Valve Quaternion to a Maya MQuaternion
+//-----------------------------------------------------------------------------
+inline void QuaternionValveToMaya( MQuaternion &qMaya, const Quaternion &qValve )
+{
+ qMaya.x = qValve.x;
+ qMaya.y = qValve.y;
+ qMaya.z = qValve.z;
+ qMaya.w = qValve.w;
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Valve Quaternion to a Maya MQuaternion
+//-----------------------------------------------------------------------------
+inline void QuaternionValveToMaya( MEulerRotation &eMaya, const Quaternion &qValve )
+{
+ MQuaternion qMaya;
+ QuaternionValveToMaya( qMaya, qValve );
+
+ const MEulerRotation::RotationOrder roTmp = eMaya.order;
+
+ eMaya = qMaya;
+
+ if ( eMaya.order != roTmp )
+ {
+ eMaya.reorder( roTmp );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Maya MEulerRotation to a Valve RadianEuler
+//-----------------------------------------------------------------------------
+inline void RadianEulerMayaToValve( RadianEuler &eValve, const MEulerRotation &eMaya )
+{
+ if ( eMaya.order == MEulerRotation::kXYZ )
+ {
+ eValve.x = eMaya.x;
+ eValve.y = eMaya.y;
+ eValve.z = eMaya.z;
+ }
+ else
+ {
+ MEulerRotation eTmp = eMaya;
+ eTmp.reorder( MEulerRotation::kXYZ );
+
+ eValve.x = eTmp.x;
+ eValve.y = eTmp.y;
+ eValve.z = eTmp.z;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Converts a Valve RadianEuler to a Maya MEulerRotation
+//-----------------------------------------------------------------------------
+inline void RadianEulerValveToMaya( MEulerRotation &eMaya, const RadianEuler &eValve )
+{
+ const MEulerRotation::RotationOrder roTmp = eMaya.order;
+
+ if ( roTmp == MEulerRotation::kXYZ )
+ {
+ eMaya.x = eValve.x;
+ eMaya.y = eValve.y;
+ eMaya.z = eValve.z;
+ }
+ else
+ {
+ eMaya.reorder( MEulerRotation::kXYZ );
+
+ eMaya.x = eValve.x;
+ eMaya.y = eValve.y;
+ eMaya.z = eValve.z;
+
+ eMaya.reorder( roTmp );
+ }
+}
+
+
+} // end namespace ValveMaya
+
+
+// Make an alias for the ValveMaya namespace
+
+namespace vm = ValveMaya;
+
+
+//-----------------------------------------------------------------------------
+// A simple stream class for printing information to the Maya script editor
+//-----------------------------------------------------------------------------
+class CMayaStream
+{
+public:
+ enum StreamType { kInfo, kWarning, kError };
+
+ CMayaStream( const StreamType i_streamType = kInfo )
+ : m_streamType( i_streamType )
+ {}
+
+ template < class T_t >
+ CMayaStream &operator<<( const T_t &v );
+
+ // This is a hack so CMayaStream << std::endl works as expected
+ CMayaStream &operator<<( std::ostream &(*StdEndl_t)( std::ostream & ) )
+ {
+ return flush();
+ }
+
+ CMayaStream &flush() { return outputString(); }
+
+protected:
+ CMayaStream &outputString()
+ {
+ // Always ensure it's terminated with a newline
+ if ( *( m_string.asChar() + m_string.length() - 1 ) != '\n' )
+ {
+ m_string += "\n";
+ }
+
+ const char *pBegin = m_string.asChar();
+ const char *const pEnd = pBegin + m_string.length();
+ const char *pCurr = pBegin;
+
+ while ( *pCurr && pCurr < pEnd )
+ {
+ if ( *pCurr == '\n' )
+ {
+ switch ( m_streamType )
+ {
+ case kWarning:
+ MGlobal::displayWarning( MString( pBegin, pCurr - pBegin ) );
+ break;
+ case kError:
+ MGlobal::displayError( MString( pBegin, pCurr - pBegin ) );
+ break;
+ default:
+ MGlobal::displayInfo( MString( pBegin, pCurr - pBegin ) );
+ break;
+ }
+
+ ++pCurr;
+ pBegin = pCurr;
+ }
+ else
+ {
+ ++pCurr;
+ }
+ }
+
+ m_string.clear();
+
+ return *this;
+ }
+
+ CMayaStream &checkForFlush()
+ {
+ const char *pCurr = m_string.asChar();
+ const char *pEnd = pCurr + m_string.length();
+ while ( *pCurr && pCurr != pEnd )
+ {
+ if ( *pCurr == '\n' )
+ {
+ return outputString();
+ }
+
+ ++pCurr;
+ }
+
+ return *this;
+ }
+
+ StreamType m_streamType;
+ MString m_string;
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+class CMayaWarnStream : public CMayaStream
+{
+public:
+ CMayaWarnStream()
+ : CMayaStream( CMayaStream::kWarning )
+ {}
+
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+class CMayaErrStream : public CMayaStream
+{
+public:
+ CMayaErrStream()
+ : CMayaStream( CMayaStream::kError )
+ {}
+};
+
+
+//-----------------------------------------------------------------------------
+// Specialization for std::string
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const std::string &v )
+{
+ *this << v.c_str();
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for char
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const char &v )
+{
+ m_string += MString( &v, 1 );
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for MVector
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const MVector &v )
+{
+ m_string += v.x;
+ m_string += " ";
+ m_string += v.y;
+ m_string += " ";
+ m_string += v.z;
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for MFloatVector
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const MFloatVector &v )
+{
+ m_string += v.x;
+ m_string += " ";
+ m_string += v.y;
+ m_string += " ";
+ m_string += v.z;
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for MEulerRotation
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const MEulerRotation &e )
+{
+ m_string += MAngle( e.x, MAngle::kRadians ).asDegrees();
+ m_string += " ";
+ m_string += MAngle( e.y, MAngle::kRadians ).asDegrees();
+ m_string += " ";
+ m_string += MAngle( e.z, MAngle::kRadians ).asDegrees();
+ switch ( e.order )
+ {
+ case MEulerRotation::kXYZ:
+ m_string += " (XYZ)";
+ break;
+ case MEulerRotation::kXZY:
+ m_string += " (XZY)";
+ break;
+ case MEulerRotation::kYXZ:
+ m_string += " (YXZ)";
+ break;
+ case MEulerRotation::kYZX:
+ m_string += " (YZX)";
+ break;
+ case MEulerRotation::kZXY:
+ m_string += " (ZXY)";
+ break;
+ case MEulerRotation::kZYX:
+ m_string += " (ZYX)";
+ break;
+ default:
+ m_string += " (Unknown)";
+ break;
+ }
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for MQuaternion
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const MQuaternion &q )
+{
+ m_string += q.x;
+ m_string += " ";
+ m_string += q.y;
+ m_string += " ";
+ m_string += q.z;
+ m_string += " ";
+ m_string += q.w;
+
+ m_string += " (";
+ operator<<( q.asEulerRotation() );
+ m_string += ")";
+
+ return *this;
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for Quaternion
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const Quaternion &q )
+{
+ return operator<<( MQuaternion( q.x, q.y, q.z, q.w ) );
+}
+
+
+//-----------------------------------------------------------------------------
+// Specialization for RadianEuler
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const RadianEuler &e )
+{
+ return operator<<( MEulerRotation( e.x, e.y, e.z ) );
+}
+
+//-----------------------------------------------------------------------------
+// Specialization for RadianEuler
+//-----------------------------------------------------------------------------
+template <>
+inline CMayaStream &CMayaStream::operator<<( const Vector &v )
+{
+ return operator<<( MVector( v.x, v.y, v.z ) );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+template < class T_t >
+inline CMayaStream &CMayaStream::operator<<( const T_t &v )
+{
+ m_string += v;
+ return checkForFlush();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+// minfo, mwarn & merr are ostreams which can be used to send stuff to
+// the Maya history window
+//
+//-----------------------------------------------------------------------------
+
+extern CMayaStream minfo;
+extern CMayaWarnStream mwarn;
+extern CMayaErrStream merr;
+
+
+#endif // VALVEMAYA_H