forked from kattkieru/nodesmith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpxnode_template.cpp
153 lines (119 loc) · 3.45 KB
/
mpxnode_template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// ----------------------------------------------------------------------
#include "common.h"
#include "{header_name}.h"
// ----------------------------------------------------------------------
MTypeId {class_name}::id( {typeID} );
// static attribute memory allocation-- inputs
{static_input_attributes}
// outputs
{static_output_attributes}
const struct {{
MMatrix identity {{}};
{constants}
}} SS {{}}; // need to force the initializer in gcc
// ----------------------------------------------------------------------
/*
class method implementations
*/
// ----------------------------------------------------------------------
{class_name}::{class_name}()
{{
}}
{class_name}::~{class_name}()
{{
}}
// ----------------------------------------------------------------------
MStatus {class_name}::setDependentsDirty( const MPlug &plugBeingDirtied, MPlugArray &affectedPlugs )
{{
/*
// example usage
MObject mob = plugBeingDirtied.attribute();
if (mob == iOutputCount)
should_resize_ = true;
return(MStatus::kSuccess);
*/
return MStatus::kSuccess;
}}
// ----------------------------------------------------------------------
inline void {class_name}::set_all_clean(MDataBlock& data)
{{
{set_all_clean}}}
// ----------------------------------------------------------------------
MStatus {class_name}::compute( const MPlug& plug, MDataBlock& data )
{{
MStatus stat;
MObject node = thisMObject();
bool plug_check {{
{plug_check} }};
if( plug_check ) {{
// collect all inputs
{input_collection}
// call external compute function
node_main();
// set all outputs
{output_setting}
set_all_clean(data);
return MS::kSuccess;
}}
return MS::kUnknownParameter;
}}
// ----------------------------------------------------------------------
void* {class_name}::creator()
{{
return new {class_name}();
}}
// ----------------------------------------------------------------------
MStatus {class_name}::initialize()
{{
MStatus stat;
char msg[1024];
// attribute function classes
MFnEnumAttribute eAttr;
MFnUnitAttribute uAttr;
MFnTypedAttribute tAttr;
MFnNumericAttribute nAttr;
MRampAttribute rAttr;
MFnCompoundAttribute cAttr;
MFnMatrixAttribute mAttr;
MFloatMatrix identity;
identity.setToIdentity();
// input plugs
{attribute_creation_inputs}
// output plugs
{attribute_creation_outputs}
// attributeAffects maps
std::map<std::string, MObject *> all_inputs = {{
{attribute_creation_affects_inputs}
}};
std::map<std::string, MObject *> all_outputs = {{
{attribute_creation_affects_outputs}
}};
for (const auto &input_pair : all_inputs) {{
for (const auto &output_pair : all_outputs) {{
stat = attributeAffects(*input_pair.second, *output_pair.second);
if (!stat) {{
sprintf(msg, "attributeAffects: %s >> %s",
(const char *)input_pair.first.c_str(),
(const char *)output_pair.first.c_str());
stat.perror(msg);
return stat;
}}
}}
}}
return MS::kSuccess;
}}
// ----------------------------------------------------------------------
void {class_name}::aeTemplate() {{
const char *msg = R"(
global proc AE{node_name}Template(string $nodeName) {{
// AEswatchDisplay $nodeName;
editorTemplate -beginScrollLayout;
editorTemplate -beginLayout "Parameters" -collapse 0;
{attribute_editor_parameters} editorTemplate -endLayout;
// AEdependNodeTemplate $nodeName;
editorTemplate -addExtraControls -collapse 1;
editorTemplate -endScrollLayout;
}}
)";
MGlobal::executeCommand(msg);
}}