2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAMaya.
6
Portions of the code are:
7
Copyright (c) 2005-2007 Feeling Software Inc.
8
Copyright (c) 2005-2007 Sony Computer Entertainment America
9
Copyright (c) 2004-2005 Alias Systems Corp.
11
Licensed under the MIT Open Source License,
12
for details please see LICENSE file or the website
13
http://www.opensource.org/licenses/mit-license.php
16
#ifndef __COLLADA_MAYA_DAG_HELPER_H__
17
#define __COLLADA_MAYA_DAG_HELPER_H__
19
#ifndef _MFnNumericData
20
#include <maya/MFnNumericData.h>
21
#endif // _MFnNumericData
23
#include "COLLADAMayaPrerequisites.h"
24
#include "COLLADAMayaPlatform.h"
33
// Handle node connections
34
static MObject getNodeConnectedTo ( const MObject& node, const String& attribute );
35
static MObject getSourceNodeConnectedTo ( const MObject& node, const MString& attribute );
36
static bool getPlugConnectedTo ( const MObject& node, const String& attribute, MPlug& plug );
37
static MObject getSourceNodeConnectedTo ( const MPlug& inPlug );
38
static bool getPlugConnectedTo ( const MPlug& inPlug, MPlug& plug );
39
static bool getPlugArrayConnectedTo ( const MObject& node, const MString& attribute, MPlug& plug );
40
static MObject getNodeConnectedTo ( const MPlug& plug );
41
static int getNextAvailableIndex ( const MObject& object, const MString& attribute, int startIndex = 0 );
42
static int getNextAvailableIndex ( const MPlug& p, int startIndex = 0 );
43
static bool connect ( const MObject& source, const MString& sourceAttribute, const MObject& destination, const MString& destinationAttribute );
44
static bool connect ( const MObject& source, const MString& sourceAttribute, const MPlug& destination );
45
static bool connect ( const MPlug& source, const MObject& destination, const MString& destinationAttribute );
46
static bool connect ( const MPlug& source, const MPlug& destination );
47
static bool connectToList ( const MObject& source, const MString& sourceAttribute, const MObject& destination, const MString& destinationAttribute, int* index = NULL );
48
static bool connectToList ( const MPlug& source, const MObject& destination, const MString& destinationAttribute, int* index = NULL );
49
static bool hasConnection ( const MPlug& plug, bool asSource = true, bool asDestination = true );
51
// Get/set the bind pose for a transform
52
static MMatrix getBindPoseInverse ( const MObject& controller, const MObject& influence );
53
static MStatus setBindPoseInverse ( const MObject& node, const MMatrix& bindPoseInverse );
56
static MPlug getChildPlug ( const MPlug& parent, const MString& name, MStatus* rc=NULL );
57
static int getChildPlugIndex ( const MPlug& parent, const MString& name, MStatus* rc=NULL ); // Useful for performance reasons when iterating over many plugs
59
// Get/set a plug's value
60
static bool getPlugValue ( const MObject& node, const String attributeName, double &value );
61
static bool getPlugValue ( const MObject& node, const String attributeName, float &value );
62
static bool getPlugValue ( const MObject& node, const String attributeName, MEulerRotation& value );
63
static bool getPlugValue ( const MObject& node, const String attributeName, bool& value );
64
static bool getPlugValue ( const MObject& node, const String attributeName, int& value );
65
static bool getPlugValue ( const MObject& node, const String attributeName, MMatrix& value );
66
static bool getPlugValue ( const MObject& node, const String attributeName, MColor& value );
67
static bool getPlugValue ( const MObject& node, const String attributeName, MString& value );
68
static bool getPlugValue ( const MObject& node, const String attributeName, MVector& value );
69
static bool getPlugValue ( const MPlug& plug, bool& value );
70
static bool getPlugValue ( const MPlug& plug, MMatrix& value );
71
static bool getPlugValue ( const MPlug& plug, MColor& value );
72
static bool getPlugValue ( const MPlug& plug, int& value );
73
static bool getPlugValue ( const MPlug& plug, uint32& value );
74
static bool getPlugValue ( const MPlug& plug, short& value );
75
static bool getPlugValue ( const MPlug& plug, uint16& value );
76
static bool getPlugValue ( const MPlug& plug, char& value );
77
static bool getPlugValue ( const MPlug& plug, uint8& value );
78
static bool getPlugValue ( const MPlug& plug, float& x );
79
static bool getPlugValue ( const MPlug& plug, float& x, float& y );
80
static bool getPlugValue ( const MPlug& plug, float& x, float& y, float& z );
81
static bool getPlugValue ( const MPlug& plug, MVector& value );
82
static void getPlugValue ( const MObject& node, const String attributeName, MStringArray& output, MStatus* status = NULL );
83
static void getPlugValue ( const MPlug& plug, MStringArray& output, MStatus* status = NULL );
85
static bool setPlugValue ( MPlug& plug, const MVector& value );
86
static bool setPlugValue ( MPlug& plug, const MMatrix& value );
87
static bool setPlugValue ( MPlug& plug, const MColor& value );
88
static bool setPlugValue ( MPlug& plug, const String& value );
90
static bool setPlugValue ( MPlug& plug, const String& value );
92
static bool setPlugValue ( MPlug& plug, const MString& value )
94
return plug.setValue ( const_cast<MString&> ( value ) ) == MStatus::kSuccess;
97
static bool setPlugValue ( MPlug& plug, float value );
98
static bool setPlugValue ( MPlug& plug, double value );
99
static bool setPlugValue ( MPlug& plug, float x, float y );
100
static bool setPlugValue ( MPlug& plug, int value );
102
static bool setPlugValue ( MPlug& plug, int32 value )
104
return setPlugValue ( plug, ( int ) value );
107
#endif // windows-only.
108
static bool setPlugValue ( MPlug& plug, bool value );
109
static bool setPlugValue ( MPlug& plug, MStringArray& stringArray );
111
// Helper to avoid the findPlug.
112
template <class ValueType>
113
static bool setPlugValue (
115
const char* attributeName,
116
const ValueType& value )
118
MPlug p = MFnDependencyNode ( node ).findPlug ( attributeName );
119
return setPlugValue ( p, value );
122
// set an array plug size before creating the element plugs
123
static void setArrayPlugSize ( MPlug& plug, uint size );
125
// Attempt to translate a String path/name into a dag path or node
126
static MDagPath getShortestDagPath ( const MObject& node );
127
static MObject getNode ( const MString& name );
129
// Create an animation curve for the given plug
130
static MObject createAnimationCurve ( const MObject& node, const char* attributeName, const char* curveType );
131
static MObject createAnimationCurve ( const MPlug& plug, const char* curveType );
132
static bool plugHasAnimation ( const MPlug& plug );
133
static MObject createExpression ( const MPlug& plug, const MString& expression );
135
// Create a String-typed attribute on a given node
136
static MObject createAttribute ( const MObject& node, const char* attributeName, const char* attributeShortName, MFnData::Type type, const char *value );
137
static MObject createAttribute ( const MObject& node, const char* attributeName, const char* attributeShortName, MFnNumericData::Type type, const char *value );
138
static MPlug addAttribute ( const MObject& node, const MObject& attribute );
140
// get the first empty item in the named array plug
141
static unsigned getFirstEmptyElementId ( const MPlug& parent );
145
/** Don't create an object of this class. */
150
#endif // __COLLADA_MAYA_DAG_HELPER_H__