~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to COLLADAMaya/include/COLLADAMayaDagHelper.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
        This file is part of COLLADAMaya.
 
5
 
 
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.
 
10
 
 
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
 
14
*/
 
15
 
 
16
#ifndef __COLLADA_MAYA_DAG_HELPER_H__
 
17
#define __COLLADA_MAYA_DAG_HELPER_H__
 
18
 
 
19
#ifndef _MFnNumericData
 
20
#include <maya/MFnNumericData.h>
 
21
#endif // _MFnNumericData
 
22
 
 
23
#include "COLLADAMayaPrerequisites.h"
 
24
#include "COLLADAMayaPlatform.h"
 
25
 
 
26
namespace COLLADAMaya
 
27
{
 
28
 
 
29
    class DagHelper
 
30
    {
 
31
 
 
32
    public:
 
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 );
 
50
 
 
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 );
 
54
 
 
55
        // Find a child plug
 
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
 
58
 
 
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 );
 
84
 
 
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 );
 
89
#ifdef UNICODE
 
90
        static bool   setPlugValue ( MPlug& plug, const String& value );
 
91
#endif // UNICODE
 
92
        static bool   setPlugValue ( MPlug& plug, const MString& value )
 
93
        {
 
94
            return plug.setValue ( const_cast<MString&> ( value ) ) == MStatus::kSuccess;
 
95
        }
 
96
 
 
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 );
 
101
#if defined(WIN32)
 
102
        static bool   setPlugValue ( MPlug& plug, int32 value )
 
103
        {
 
104
            return setPlugValue ( plug, ( int ) value );
 
105
        }
 
106
 
 
107
#endif // windows-only.
 
108
        static bool setPlugValue ( MPlug& plug, bool value );
 
109
        static bool setPlugValue ( MPlug& plug, MStringArray& stringArray );
 
110
 
 
111
        // Helper to avoid the findPlug.
 
112
        template <class ValueType>
 
113
        static bool setPlugValue ( 
 
114
            const MObject& node, 
 
115
            const char* attributeName, 
 
116
            const ValueType& value )
 
117
        {
 
118
            MPlug p = MFnDependencyNode ( node ).findPlug ( attributeName );
 
119
            return setPlugValue ( p, value );
 
120
        }
 
121
 
 
122
        // set an array plug size before creating the element plugs
 
123
        static void setArrayPlugSize ( MPlug& plug, uint size );
 
124
 
 
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 );
 
128
 
 
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 );
 
134
 
 
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 );
 
139
 
 
140
        // get the first empty item in the named array plug
 
141
        static unsigned getFirstEmptyElementId ( const MPlug& parent );
 
142
 
 
143
    private:
 
144
 
 
145
        /** Don't create an object of this class. */
 
146
        DagHelper() {};
 
147
    };
 
148
}
 
149
 
 
150
#endif // __COLLADA_MAYA_DAG_HELPER_H__