[QUOTE=Bronwen;10515]You pegged the problem in a previous post:
So here’s my question. Why name the initializer functions the same thing?
Name them each something different. There’s not enforcement for the name of the function. The initializer only gets called once per class, on plugin registration, and you pass the function to the initializer. You can call them whatever you want.[/QUOTE]
I am fuzzy.
Do you mean why bother naming the initializers all initialize so that when I call a sub-child, that calls the super, that calls yet another super, they call a static, but a differently named static?
If the initializer (initialize) is the entry point for Maya to make the attributes, seperating them and calling the portion that makes the attributes from another function during the initialize callback amounts to the same thing? Yeah I am probably not grokking again.
Not that it is necessarily the proper way, but it obviously work(s)(ed) in Maya API books by David Gould for the example when the book was published (volume II btw pgs. 340+), and not much has changed node wise in Maya?
He does call each super class initialize from the children (forgive the formatting – PDF version copy-paste):
File: CmpMeshModi fi erNode, h
class CmpMeshModifierNode : public MPxNode
{
public:
static Mstatus initialize() ;
protected:
static MObject inMesh;
static MObject outMesh;
};
File: CmpMeshModifierNode, cpp
MObject CmpMeshModifierNode''inMesh"
MObject CmpMeshModifierNode''outMesh"
MStatus CmpMeshModifierNode::initialize()
{
MFnTypedAttribute tAttr;
inMesh = tAttr.create( "inMesh", "im", MFnData::kMesh );
outMesh = tAttr.create( "outMesh", "om", MFnData--kMesh )-
tAttr.setStorable( false )"
addAttribute( inMesh )-
addAttribute( outMesh ).
attributeAffects( inMesh, outMesh ).
return MS::kSuccess;
}
Plug-in: Di spl aceMesh
File: Di spl aceMeshNode.h
class DisplaceMeshNode : public CmpMeshModifierNode
{
public:
virtual MStatus compute( const MPlug &plug, MDataBlock &data );
static void *creator( ) ;
static MStatus initialize( ) ;
static MTypeld id ;
static MObject strength ;
static MObject imageFilename;
static double strengthDefault();
static MString imageFilenameDefault();
};
Plug-in: oi spl aceMesh
File: Di spl aceMeshNode, cpp
MTypeld DisplaceMeshNode::id( 0x00338 );
MObject DisplaceMeshNode::strength;
MObject DisplaceMeshNode::imageFilename;
void *DisplaceMeshNode::creator()
{
return new DisplaceMeshNode();
}
MStatus DisplaceMeshNode::initialize()
{
CmpMeshModifierNode::initialize( ) ;
MFnNumericAttribute nAttr ;
strength = nAttr.create ( "strength" , "str" , MFnNumericData::kDouble, 1.0 );
nAttr.setKeyable( true );
MFnTypedAttribute tAttr ;
imageFilename = tAttr.create( "imageFilename", "img",MFnData: :kString );
addAttribute( strength );
addAttribute( imageFilename );
attributeAffects ( strength, outMesh );
attributeAffects ( imageFilename, outMesh );
return MS::kSuccess;
}