initial
This commit is contained in:
46
public/maya/valvemaya/HyperShadeUtil.h
Normal file
46
public/maya/valvemaya/HyperShadeUtil.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//======= Copyright <20> 1996-2007, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Purpose: Utils for working with HyperShade in Maya
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
// Maya includes
|
||||
#include <maya/MObject.h>
|
||||
|
||||
|
||||
// Valve includes
|
||||
#include "valveMaya/Undo.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace ValveMaya
|
||||
{
|
||||
|
||||
class CHyperShadeUtil
|
||||
{
|
||||
public:
|
||||
CHyperShadeUtil();
|
||||
|
||||
CHyperShadeUtil( CUndo &undo );
|
||||
|
||||
MStatus AddUtility( const MObject &utilityNode );
|
||||
|
||||
MStatus AddShader( const MObject &shaderNode );
|
||||
|
||||
MStatus AddTexture( const MObject &textureNode );
|
||||
|
||||
protected:
|
||||
CUndo m_tmpUndo;
|
||||
CUndo &m_undo;
|
||||
|
||||
MObject m_renderUtilityListObj;
|
||||
MObject m_shaderListObj;
|
||||
MObject m_textureListObj;
|
||||
|
||||
void Init();
|
||||
};
|
||||
|
||||
}
|
||||
106
public/maya/valvemaya/MDLImport.h
Normal file
106
public/maya/valvemaya/MDLImport.h
Normal file
@@ -0,0 +1,106 @@
|
||||
//======= Copyright <20> 1996-2008, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Purpose: MDL Import class for Maya
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef MDLIMPORT_H
|
||||
#define MDLIMPORT_H
|
||||
|
||||
|
||||
// Maya includes
|
||||
#include <maya/MDagPathArray.h>
|
||||
#include <maya/MMatrix.h>
|
||||
#include <maya/MObjectArray.h>
|
||||
#include <maya/MSelectionList.h>
|
||||
|
||||
|
||||
// Valve includes
|
||||
#include "datacache/imdlcache.h"
|
||||
#include "ValveMaya/Undo.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
struct mstudioboneweight_t;
|
||||
|
||||
|
||||
namespace ValveMaya
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMDLImport
|
||||
{
|
||||
public:
|
||||
CMDLImport();
|
||||
|
||||
CMDLImport( ValveMaya::CUndo &undo );
|
||||
|
||||
MStatus DoIt( const char *pFilename, MSelectionList &createdNodes );
|
||||
|
||||
MStatus DoIt( const char *pFilename );
|
||||
|
||||
bool m_bOptMeshOnly : 1; // Only import meshes
|
||||
bool m_bOptSingleMesh : 1; // Merge all meshes in a MDL into a single Maya mesh
|
||||
bool m_bOptVstInfo : 1; // Group everything under a vstInfo node
|
||||
bool m_bOptImportSkeleton : 1; // Import the skeleton
|
||||
bool m_bOptImportMesh : 1; // Import the mesh
|
||||
bool m_bOptEngineSpace : 1; // Import data in engine space
|
||||
bool m_bOptNormals : 1; // Set normals on mesh
|
||||
bool m_bOptEdgeHardness : 1; // Set edge hard/softness data
|
||||
bool m_bOptSkinMeshes : 1; // Apply bone weights to meshes
|
||||
int m_nOptLod; // Import the specified LOD only, -2 means root LOD, -1 means all LODs, otherwise the LOD that matches, or all if no match
|
||||
int m_nOptSkin; // Import the specified Skin only, -1 means all skins, otherwise the skin that matches or all if no match
|
||||
MStringArray m_optRemovePrefix; // A list of prefixes to remove on import
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
static MDLHandle_t GetMDLHandle( const char *pFilename );
|
||||
|
||||
MObject CreateVstInfo( const char *pModelName, MSelectionList &createdNodes );
|
||||
|
||||
static MStatus AddDagMObject( const MObject &dagObj, MSelectionList &createdNodes );
|
||||
|
||||
void ImportBones( MDLHandle_t mdlHandle, const MObject &parentObj, MDagPathArray &mayaBones, MSelectionList &createdNodes );
|
||||
|
||||
static MStatus ApplyCompDefaultShader( MObject &geoObj, ValveMaya::CUndo &undo );
|
||||
|
||||
static MObject FindOrCreateFileObj( ValveMaya::CUndo &undo, const MString &materialPath, MSelectionList &createdNodes );
|
||||
|
||||
MStatus AssignShadingGroup(
|
||||
ValveMaya::CUndo &undo,
|
||||
const MDagPath &meshDagPath,
|
||||
MIntArray &faceList,
|
||||
const MStringArray &materialPaths,
|
||||
MSelectionList &createdList ) const;
|
||||
|
||||
void SkinMesh( MDagPath &meshDagPath, const MDagPathArray &mayaBones, const CUtlVector< const mstudioboneweight_t * > &tmpVertexBoneWeightArray );
|
||||
|
||||
void ImportMeshes( MDLHandle_t mdlHandle, MObject parentObj, const MDagPathArray &mayaBones, MSelectionList &createdNodes );
|
||||
|
||||
void ReorientMdl( MDLHandle_t mdlHandle, MObject &vstInfoObj, const MDagPathArray &mayaBones );
|
||||
|
||||
static void InitBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr );
|
||||
|
||||
static void TransformBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr );
|
||||
|
||||
static void ComputeSequenceBones( Vector p[ MAXSTUDIOBONES ], QuaternionAligned q[ MAXSTUDIOBONES ], studiohdr_t *pHdr, int nSequence = 0, float flTime = 0.0f );
|
||||
|
||||
bool ComputeMdlToMayaMatrix( MMatrix &mMdlToMaya, studiohdr_t* pHdr ) const;
|
||||
|
||||
void TransformPointArray( MFloatPointArray &vertexArray, const MMatrix &mMatrix ) const;
|
||||
|
||||
void TransformNormalArray( MVectorArray &normalArray, const MMatrix &mMatrix ) const;
|
||||
|
||||
MString GetBoneName( MString boneName ) const;
|
||||
|
||||
ValveMaya::CUndo &m_undo;
|
||||
ValveMaya::CUndo m_tmpUndo;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // MDLIMPORT_H
|
||||
20
public/maya/valvemaya/MeshUtils.h
Normal file
20
public/maya/valvemaya/MeshUtils.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//======= Copyright <20> 1996-2008, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef MESHUTIL_H
|
||||
#define MESHUTIL_H
|
||||
|
||||
#include <maya/MDagPath.h>
|
||||
#include <maya/MVector.h>
|
||||
|
||||
namespace ValveMaya
|
||||
{
|
||||
MStatus SetEdgeHardnessFromNormals( MObject &meshObj, double dTol = MVector_kTol );
|
||||
|
||||
MStatus SetEdgeHardnessFromNormals( const MDagPath &meshDagPath, double dTol = MVector_kTol );
|
||||
}
|
||||
|
||||
#endif // MESHUTIL_H
|
||||
327
public/maya/valvemaya/Undo.h
Normal file
327
public/maya/valvemaya/Undo.h
Normal file
@@ -0,0 +1,327 @@
|
||||
//======= Copyright <20> 1996-2006, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Maya Undo helper, use it like this
|
||||
//
|
||||
// class CMyCmd : MPxCommand
|
||||
// {
|
||||
// // ... regular stuff ... //
|
||||
//
|
||||
// ValveMaya::CUndo m_undo;
|
||||
// };
|
||||
//
|
||||
// MStatus CMyCmd::doIt( const MArgList &mArgList )
|
||||
// {
|
||||
// m_undo.SetArgList( Syntax(), mArgList );
|
||||
// }
|
||||
//
|
||||
// MStatus CMyCmd::redoIt( const MArgList &mArgList )
|
||||
// {
|
||||
// // Get at command line args
|
||||
// m_undo.ArgDatabase().isFlagSet( ... );
|
||||
//
|
||||
// // Do operations
|
||||
// m_undo.SaveCurrentSelection();
|
||||
// m_undo.DagModifier().createNode( ... );
|
||||
// m_undo.DagModifierDoIt();
|
||||
// m_undo.SetAttr( mPlug, value );
|
||||
//
|
||||
// /// etc ...
|
||||
// }
|
||||
//
|
||||
// MStatus CMyCmd::undoIt( const MArgList &mArgList )
|
||||
// {
|
||||
// m_undo.Undo();
|
||||
// }
|
||||
//
|
||||
// bool CMyCmd::isUndoable()
|
||||
// {
|
||||
// return m_undo.IsUndoable();
|
||||
// }
|
||||
//
|
||||
// If there's a need to get fancy, any of the CUndoOp* classes can be
|
||||
// constructed via 'new' and a boost::shared_ptr< CUndoOp > constructed
|
||||
// with that pointed can be passed to CUndo::Push(). Note that means
|
||||
// that the pointer will be managed by boost::shared_ptr so if the
|
||||
// lifetime of the data needs to be controlled by the caller (it shouldn't)
|
||||
// then a shared_ptr should be kept
|
||||
//
|
||||
// Setting the ArgList and using ArgDatabase doesn't affect the undo/redo
|
||||
// ability but it's a convnient place to keep that data
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef VALVEMAYA_UNDO_H
|
||||
#define VALVEMAYA_UNDO_H
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// Standard includes
|
||||
|
||||
|
||||
// Maya includes
|
||||
#include <maya/MArgDatabase.h>
|
||||
#include <maya/MArgList.h>
|
||||
#include <maya/MDagModifier.h>
|
||||
#include <maya/MDagPath.h>
|
||||
#include <maya/MObject.h>
|
||||
#include <maya/MPlug.h>
|
||||
#include <maya/MSelectionList.h>
|
||||
#include <maya/MStatus.h>
|
||||
#include <maya/MString.h>
|
||||
#include <maya/MSyntax.h>
|
||||
#include <maya/MTransformationMatrix.h>
|
||||
|
||||
|
||||
// Valve includes
|
||||
#include "tier1/utlstack.h"
|
||||
|
||||
|
||||
namespace ValveMaya
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class CUndoOp;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndo: Undo stack manager class
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class CUndo
|
||||
{
|
||||
public:
|
||||
CUndo();
|
||||
|
||||
~CUndo();
|
||||
|
||||
void Clear();
|
||||
|
||||
MStatus SetArgList(
|
||||
const MSyntax &mSyntax,
|
||||
const MArgList &mArgList );
|
||||
|
||||
const MArgDatabase &ArgDatabase();
|
||||
|
||||
void SaveCurrentSelection();
|
||||
|
||||
MDagModifier &DagModifier();
|
||||
|
||||
MStatus DagModifierDoIt();
|
||||
|
||||
MStatus Connect(
|
||||
const MPlug &srcP,
|
||||
const MPlug &dstP,
|
||||
bool force = false );
|
||||
|
||||
bool SetAttr(
|
||||
MPlug &mPlug,
|
||||
MObject &val );
|
||||
|
||||
bool SetAttr(
|
||||
MPlug &mPlug,
|
||||
double val );
|
||||
|
||||
bool Lock(
|
||||
MPlug &mPlug,
|
||||
bool lock );
|
||||
|
||||
void NodeCreated( MObject &nodeObject );
|
||||
|
||||
void Push(
|
||||
CUndoOp *pUndoOp );
|
||||
|
||||
bool IsUndoable() const;
|
||||
|
||||
MStatus Undo();
|
||||
|
||||
protected:
|
||||
MArgDatabase *m_pArgDatabase;
|
||||
CUtlStack< CUndoOp * > m_undoStack;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndoOp: Undo stack member abstract base class
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOp
|
||||
{
|
||||
public:
|
||||
virtual ~CUndoOp()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo() = 0;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndoOpDagModifier: Undo stack member Dag Modifier class
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOpDagModifier : public CUndoOp
|
||||
{
|
||||
public:
|
||||
virtual ~CUndoOpDagModifier()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo()
|
||||
{
|
||||
m_mDagModifier.undoIt();
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class CUndo;
|
||||
|
||||
MDagModifier m_mDagModifier;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndoOpSetAttr: Undo stack member for setting attributes
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOpSetAttr : public CUndoOp
|
||||
{
|
||||
public:
|
||||
CUndoOpSetAttr(
|
||||
MPlug &mPlug,
|
||||
MObject &mObjectVal );
|
||||
|
||||
CUndoOpSetAttr(
|
||||
MPlug &mPlug,
|
||||
double numericVal );
|
||||
|
||||
virtual ~CUndoOpSetAttr()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo();
|
||||
|
||||
protected:
|
||||
MPlug m_mPlug;
|
||||
MObject m_mObjectVal;
|
||||
double m_numericVal;
|
||||
const bool m_numeric;
|
||||
|
||||
private:
|
||||
// Visual C++ is retarded - tell it there's no assignment operator
|
||||
CUndoOpSetAttr &operator=( const CUndoOpSetAttr &rhs );
|
||||
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndoOpSelection: Undo stack member for changing selection
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOpSelection : public CUndoOp
|
||||
{
|
||||
public:
|
||||
CUndoOpSelection();
|
||||
|
||||
virtual ~CUndoOpSelection()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo();
|
||||
|
||||
protected:
|
||||
MSelectionList m_mSelectionList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// CUndoOpSelection: Undo stack member for locking and unlocking attributes
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOpLock : public CUndoOp
|
||||
{
|
||||
public:
|
||||
|
||||
CUndoOpLock(
|
||||
MPlug &mPlug,
|
||||
bool lock );
|
||||
|
||||
virtual ~CUndoOpLock()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo();
|
||||
|
||||
protected:
|
||||
MPlug m_mPlug;
|
||||
const bool m_locked;
|
||||
|
||||
private:
|
||||
// Visual C++ is retarded - tell it there's no assignment operator
|
||||
CUndoOpLock &operator=( const CUndoOpLock &rhs );
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//=============================================================================
|
||||
class CUndoOpResetRestPosition : public CUndoOp
|
||||
{
|
||||
public:
|
||||
CUndoOpResetRestPosition(
|
||||
const MDagPath &mDagPath );
|
||||
|
||||
virtual ~CUndoOpResetRestPosition()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo();
|
||||
|
||||
protected:
|
||||
const MDagPath m_mDagPath;
|
||||
MTransformationMatrix m_matrix;
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// For node creation via something like MFnMesh::create, etc..
|
||||
//=============================================================================
|
||||
class CUndoOpNodeCreated : public CUndoOp
|
||||
{
|
||||
public:
|
||||
CUndoOpNodeCreated(
|
||||
MObject &mObject );
|
||||
|
||||
virtual ~CUndoOpNodeCreated()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Undo();
|
||||
|
||||
protected:
|
||||
MObject m_nodeObject;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // VALVEMAYA_UNDO_H
|
||||
64
public/maya/valvemaya/vsskinnerutils.h
Normal file
64
public/maya/valvemaya/vsskinnerutils.h
Normal file
@@ -0,0 +1,64 @@
|
||||
//====== Copyright (c) 1996-2009, Valve Corporation, All rights reserved. =====
|
||||
//
|
||||
// vsskinnerutils
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef VSSKINNERUTILS_H
|
||||
#define VSSKINNERUTILS_H
|
||||
|
||||
|
||||
// Maya includes
|
||||
#include <maya/MDagPath.h>
|
||||
#include <maya/MSelectionList.h>
|
||||
#include <maya/MMatrix.h>
|
||||
|
||||
|
||||
// Valve includes
|
||||
#include "mathlib/vmatrix.h"
|
||||
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
class CVsSkinnerUtils
|
||||
{
|
||||
public:
|
||||
|
||||
static MDagPath GetSpecifiedSkinnerNode( const MSelectionList &iList );
|
||||
|
||||
static MStatus GetSpecifiedSkinnerNodes( const MSelectionList &iList, MSelectionList &oList );
|
||||
|
||||
static MStatus FindSkinnerNodesInHierarchy( const MDagPath &iDagPath, MSelectionList &oList );
|
||||
|
||||
static MStatus ConnectedToSkinnerNode( const MDagPath &iDagPath, MDagPath &oDagPath );
|
||||
|
||||
static MStatus IsSkinnerNode( const MObject &iObject );
|
||||
|
||||
static MStatus IsSkinnerNode( const MDagPath &iDagPath );
|
||||
|
||||
static MStatus IsSkinnerVol( const MObject &iObject );
|
||||
|
||||
static MStatus IsSkinnerVol( const MDagPath &iDagPath );
|
||||
|
||||
static MStatus IsSkinnerJoint( const MObject &iObject );
|
||||
|
||||
static MStatus IsSkinnerJoint( const MDagPath &mDagPath );
|
||||
|
||||
static MStatus IsSkinnerBone( const MObject &iObject );
|
||||
|
||||
static MObject GetSkinnerBoneFromSkinnerJoint( const MObject &iObject );
|
||||
|
||||
static MObject GetSkinnerBoneFromSkinnerJoint( const MDagPath &iDagPath );
|
||||
|
||||
static VMatrix MMatrixToVMatrix( const MMatrix &mMatrix );
|
||||
};
|
||||
|
||||
|
||||
#endif // VSSKINNERUTILS_H
|
||||
Reference in New Issue
Block a user