Ejemplo n.º 1
0
MStatus HesMeshNode::initialize()
{
	MFnNumericAttribute numAttr;
	MStatus				stat;
	
	MFnTypedAttribute stringAttr;
	input = stringAttr.create( "hesPath", "hsp", MFnData::kString );
 	stringAttr.setStorable(true);
	addAttribute( input );
	
	ameshname = stringAttr.create( "meshName", "mn", MFnData::kString );
 	stringAttr.setStorable(true);
    stringAttr.setArray(true);
    stringAttr.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( ameshname );
	
	MFnTypedAttribute meshAttr;
	outMesh = meshAttr.create( "outMesh", "o", MFnData::kMesh ); 
	meshAttr.setStorable(false);
	meshAttr.setWritable(false);
    meshAttr.setArray(true);
    meshAttr.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( outMesh );
    
	attributeAffects( input, outMesh );
	
	return MS::kSuccess;
}
Ejemplo n.º 2
0
MStatus fullLoft::initialize()
{
	MStatus stat;
	MFnTypedAttribute typedAttr;
	
	inputCurve=typedAttr.create( "inputCurve", "in",
										 MFnNurbsCurveData::kNurbsCurve,
										 &stat );
	PERRORfail("initialize create input attribute");
	stat = typedAttr.setArray( true );
	PERRORfail("initialize set input attribute array");
	
	outputSurface=typedAttr.create( "outputSurface", "out",
											MFnNurbsSurfaceData::kNurbsSurface,
											&stat );
	PERRORfail("initialize create output attribute");
	stat = typedAttr.setStorable( false );
	PERRORfail("initialize set output attribute storable");

	stat = addAttribute( inputCurve );
	PERRORfail("addAttribute(inputCurve)");

	stat = addAttribute( outputSurface );
	PERRORfail("addAttribute(outputSurface)");

	stat = attributeAffects( inputCurve, outputSurface );
	PERRORfail("attributeAffects(inputCurve, outputSurface)");

	return MS::kSuccess;
}
Ejemplo n.º 3
0
MStatus testNucleusNode::initialize()
{
	MStatus stat;

	MFnTypedAttribute tAttr;

	startState = tAttr.create("startState", "sst", MFnData::kNObject, MObject::kNullObj, &stat );

	statCheck(stat, "failed to create startState");
	tAttr.setWritable(true);
	tAttr.setStorable(true);
	tAttr.setHidden(true);
    tAttr.setArray(true);


    currentState = tAttr.create("currentState", "cst", MFnData::kNObject, MObject::kNullObj, &stat );

	statCheck(stat, "failed to create currentState");
	tAttr.setWritable(true);
	tAttr.setStorable(true);
	tAttr.setHidden(true);
    tAttr.setArray(true);
	

    nextState = tAttr.create("nextState", "nst", MFnData::kNObject, MObject::kNullObj, &stat );

	statCheck(stat, "failed to create nextState");
	tAttr.setWritable(true);
	tAttr.setStorable(true);
	tAttr.setHidden(true);
    tAttr.setArray(true);

   	MFnUnitAttribute uniAttr;
	currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime,  0.0, &stat  );    	

	addAttribute(startState);
	addAttribute(currentState);
	addAttribute(nextState);
    addAttribute(currentTime);
	
	attributeAffects(startState, nextState);
	attributeAffects(currentState, nextState);	
    attributeAffects(currentTime, nextState);	

	return MStatus::kSuccess;
}
Ejemplo n.º 4
0
MStatus multiCurve::initialize()
{
	MStatus				stat;
	MFnNumericAttribute	nAttr;
	MFnTypedAttribute	typedAttr;
	
	numCurves = nAttr.create ("numCurves", "nc",
							  MFnNumericData::kLong, 5, &stat);
	PERRORfail(stat, "initialize create numCurves attribute");
	CHECK_MSTATUS ( nAttr.setKeyable( true ) );
	stat = addAttribute( numCurves );
	PERRORfail(stat, "addAttribute(numCurves)");
	
	curveOffset = nAttr.create ("curveOffset", "co",
							  MFnNumericData::kDouble, 1.0, &stat);
	PERRORfail(stat, "initialize create curveOffset attribute");
	CHECK_MSTATUS ( nAttr.setKeyable( true ) );
	stat = addAttribute( curveOffset );
	PERRORfail(stat, "addAttribute(curveOffset)");

	inputCurve = typedAttr.create( "inputCurve", "ic",
								   MFnNurbsCurveData::kNurbsCurve, &stat );
	PERRORfail(stat, "initialize create inputCurve attribute");
	CHECK_MSTATUS ( typedAttr.setReadable( false ) );
	CHECK_MSTATUS ( typedAttr.setWritable( true ) );
	stat = addAttribute( inputCurve );
	PERRORfail(stat, "addAttribute(inputCurve)");
	
	outputCurves = typedAttr.create( "outputCurves", "oc",
									 MFnNurbsCurveData::kNurbsCurve, &stat );
	PERRORfail(stat, "initialize create outputCurves attribute");
	CHECK_MSTATUS ( typedAttr.setArray( true ) );
	CHECK_MSTATUS ( typedAttr.setReadable( true ) );
	CHECK_MSTATUS ( typedAttr.setWritable( false ) );
	CHECK_MSTATUS ( typedAttr.setUsesArrayDataBuilder( true ) );
	stat = addAttribute( outputCurves );
	PERRORfail(stat, "addAttribute(outputCurves)");

	stat = attributeAffects( numCurves, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	stat = attributeAffects( curveOffset, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	stat = attributeAffects( inputCurve, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	return stat;
}
Ejemplo n.º 5
0
MStatus TestDeformer::initialize()
{
	MFnNumericAttribute numericAttr;
	MFnTypedAttribute polyMeshAttr;
	MFnEnumAttribute enumAttr;

	MStatus status; // Status will be used to hold the MStatus value

	// vertSnapInput
	driver_mesh = polyMeshAttr.create( "vertSnapInput", "vsnpin", MFnData::kMesh, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( polyMeshAttr.setStorable( false ) );
	CHECK_MSTATUS( polyMeshAttr.setArray(true) );
	CHECK_MSTATUS( polyMeshAttr.setConnectable( true ) );
	CHECK_MSTATUS( addAttribute(driver_mesh) );
	CHECK_MSTATUS( attributeAffects(driver_mesh, outputGeom) );

	// initialize is used to mark this node's state
	initialized_data = enumAttr.create( "initialize", "inl", 0/*default*/, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( enumAttr.addField(	"Off", 0) );
	CHECK_MSTATUS( enumAttr.addField(	"Re-Set Bind", 1) );
	CHECK_MSTATUS( enumAttr.addField(	"Bound", 2) );
	CHECK_MSTATUS( enumAttr.setKeyable(true) );
	CHECK_MSTATUS( enumAttr.setStorable(true) );
	CHECK_MSTATUS( enumAttr.setReadable(true) );
	CHECK_MSTATUS( enumAttr.setWritable(true) );
	CHECK_MSTATUS( enumAttr.setDefault(0) );
	CHECK_MSTATUS( addAttribute( initialized_data ) );
	CHECK_MSTATUS( attributeAffects( initialized_data, outputGeom ) );

    // hold the vertex index mapping
	vert_map = numericAttr.create( "vtxIndexMap", "vtximp", MFnNumericData::kLong, 0/*default*/, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS( numericAttr.setKeyable(false) );
	CHECK_MSTATUS( numericAttr.setArray(true) );
	CHECK_MSTATUS( numericAttr.setStorable(true) );
	CHECK_MSTATUS( numericAttr.setReadable(true) );
	CHECK_MSTATUS( numericAttr.setWritable(true) );
	CHECK_MSTATUS( addAttribute( vert_map ) );
	CHECK_MSTATUS( attributeAffects( vert_map, outputGeom ) );

	CHECK_MSTATUS( MGlobal::executePythonCommand("import maya.cmds; maya.cmds.makePaintable('"+TestDeformer::cTypeName()+"', 'weights', attrType='multiFloat')") );

	return( MS::kSuccess );
}
Ejemplo n.º 6
0
//
//  Initialize the node
//
MStatus jhMeshBlur::initialize()
{
    // attribute types
    MFnUnitAttribute    unitAttr;
    MFnNumericAttribute	nAttr;
    MFnTypedAttribute   tAttr;

    aOldMeshData = tAttr.create("oldMesh","om",MFnData::kPointArray);
    tAttr.setArray(true);
    tAttr.setHidden(true);
    tAttr.setIndexMatters(true);

    // create the attributes
    aStrength = nAttr.create( "Strength", "str", MFnNumericData::kFloat,1.0);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTreshhold = nAttr.create( "Treshold", "tres", MFnNumericData::kFloat,0.0);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMin(0.0);

    aShapeFactor = nAttr.create( "ShapeFactor", "shapef", MFnNumericData::kFloat,0.5);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTweakBlur = nAttr.create( "TweakBlur", "tweak", MFnNumericData::kBoolean,false);
    nAttr.setKeyable(false);
    nAttr.setChannelBox(true);

    aQuadInterp = nAttr.create( "QuadInterpolation", "qi", MFnNumericData::kBoolean,true);
    nAttr.setKeyable(false);
    nAttr.setChannelBox(true);

    aInterpPower = nAttr.create( "InterpolationPower", "interp", MFnNumericData::kDouble, 0.75);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTime = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 1.0 );
    unitAttr.setStorable(true);
    unitAttr.setCached(true);
	unitAttr.setReadable(true);
	unitAttr.setWritable(true);
	unitAttr.setAffectsAppearance(true);
	unitAttr.setAffectsWorldSpace(true);

    // Make the attributes visible to the user
    addAttribute( aStrength);
    addAttribute( aTreshhold);
    addAttribute( aTime);
    addAttribute( aTweakBlur);
    addAttribute( aQuadInterp);
    addAttribute( aInterpPower);
    addAttribute( aOldMeshData);

    // Make sure when an attribute changes, the node updates
    attributeAffects( aTime, outputGeom );
	attributeAffects( aStrength, outputGeom );
    attributeAffects( aTreshhold, outputGeom );
    attributeAffects( aQuadInterp, outputGeom );
    attributeAffects( aInterpPower, outputGeom );

    // Not implented yet, but make the weights paintable :)
    MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer jhMeshBlur weights;");

    return MStatus::kSuccess;
}
Ejemplo n.º 7
0
MStatus AlembicNode::initialize()
{
    MStatus status;

    MFnUnitAttribute    uAttr;
    MFnTypedAttribute   tAttr;
    MFnNumericAttribute nAttr;
    MFnGenericAttribute gAttr;
    MFnEnumAttribute    eAttr;

    // add the input attributes: time, file, sequence time
    mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0);
    status = uAttr.setStorable(true);
    status = addAttribute(mTimeAttr);

    // input file name
    MFnStringData fileFnStringData;
    MObject fileNameDefaultObject = fileFnStringData.create("");
    mAbcFileNameAttr = tAttr.create("abc_File", "fn",
        MFnData::kString, fileNameDefaultObject);
    status = tAttr.setStorable(true);
    status = tAttr.setUsedAsFilename(true);
    status = addAttribute(mAbcFileNameAttr);

    // playback speed
    mSpeedAttr = nAttr.create("speed", "sp",
        MFnNumericData::kDouble, 1.0, &status);
    status = nAttr.setWritable(true);
    status = nAttr.setStorable(true);
    status = nAttr.setKeyable(true);
    status = addAttribute(mSpeedAttr);

    // frame offset
    mOffsetAttr = nAttr.create("offset", "of",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(true);
    status = nAttr.setStorable(true);
    status = nAttr.setKeyable(true);
    status = addAttribute(mOffsetAttr);

    // cycle type
    mCycleTypeAttr = eAttr.create("cycleType", "ct", 0,  &status );
    status = eAttr.addField("Hold", PLAYTYPE_HOLD);
    status = eAttr.addField("Loop", PLAYTYPE_LOOP);
    status = eAttr.addField("Reverse", PLAYTYPE_REVERSE);
    status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE);
    status = eAttr.setWritable(true);
    status = eAttr.setStorable(true);
    status = eAttr.setKeyable(true);
    status = addAttribute(mCycleTypeAttr);

    // Regex Filter
    // This is a hidden variable to preserve a regexIncludefilter string
    // into a .ma file.
    mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift",
        MFnData::kString);
    status = tAttr.setStorable(true);
    status = tAttr.setHidden(true);
    status = addAttribute(mIncludeFilterAttr);

    // Regex Filter
    // This is a hidden variable to preserve a regexExcludefilter string
    // into a .ma file.
    mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft",
        MFnData::kString);
    status = tAttr.setStorable(true);
    status = tAttr.setHidden(true);
    status = addAttribute(mExcludeFilterAttr);

    // sequence min and max in frames
    mStartFrameAttr = nAttr.create("startFrame", "sf",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(false);
    status = nAttr.setStorable(true);
    status = addAttribute(mStartFrameAttr);

    mEndFrameAttr = nAttr.create("endFrame", "ef",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(false);
    status = nAttr.setStorable(true);
    status = addAttribute(mEndFrameAttr);

    // add the output attributes
    // sampled subD mesh
    MFnMeshData fnMeshData;
    MObject meshDefaultObject = fnMeshData.create(&status);
    mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd",
        MFnData::kMesh, meshDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutSubDArrayAttr);

    // sampled poly mesh
    mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly",
        MFnData::kMesh, meshDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutPolyArrayAttr);

    // sampled nurbs surface
    MFnNurbsSurfaceData fnNSData;
    MObject nsDefaultObject = fnNSData.create(&status);
    mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons",
        MFnData::kNurbsSurface, nsDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutNurbsSurfaceArrayAttr);

    // sampled nurbs curve group
    MFnNurbsCurveData fnNCData;
    MObject ncDefaultObject = fnNCData.create(&status);
    mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc",
        MFnData::kNurbsCurve, ncDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutNurbsCurveGrpArrayAttr);

    // sampled locator
    mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutLocatorPosScaleArrayAttr);

    // sampled transform operations
    mOutTransOpArrayAttr = nAttr.create("transOp", "to",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutTransOpArrayAttr);

    // sampled camera
    // assume the boolean variables cannot be keyed
    mOutCameraArrayAttr = nAttr.create("outCamera", "ocam",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutCameraArrayAttr);

    // sampled custom-attributes
    mOutPropArrayAttr = gAttr.create("prop", "pr", &status);
    status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean);
    status = gAttr.addNumericDataAccept(MFnNumericData::kByte);
    status = gAttr.addNumericDataAccept(MFnNumericData::kShort);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Short);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Short);
    status = gAttr.addNumericDataAccept(MFnNumericData::kInt);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Int);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Int);
    status = gAttr.addNumericDataAccept(MFnNumericData::kFloat);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Float);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Float);
    status = gAttr.addNumericDataAccept(MFnNumericData::kDouble);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Double);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Double);
    status = gAttr.addNumericDataAccept(MFnNumericData::k4Double);
    status = gAttr.addDataAccept(MFnData::kString);
    status = gAttr.addDataAccept(MFnData::kIntArray);
    status = gAttr.addDataAccept(MFnData::kDoubleArray);
    status = gAttr.addDataAccept(MFnData::kVectorArray);
    status = gAttr.addDataAccept(MFnData::kPointArray);

    status = gAttr.setWritable(false);
    status = gAttr.setKeyable(false);
    status = gAttr.setArray(true);
    status = gAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutPropArrayAttr);

    // set up affection relationships
    status = attributeAffects(mTimeAttr, mOutSubDArrayAttr);
    status = attributeAffects(mTimeAttr, mOutPolyArrayAttr);
    status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mTimeAttr, mOutCameraArrayAttr);
    status = attributeAffects(mTimeAttr, mOutPropArrayAttr);
    status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutPropArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutPropArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr);

    MGlobal::executeCommand( UITemplateMELScriptStr );

    return status;
}
Ejemplo n.º 8
0
// plugin (un)initialiser
MStatus nwayDeformerNode::initialize()
{
    MFnTypedAttribute tAttr;
    MFnNumericAttribute nAttr;
    MFnEnumAttribute eAttr;
    MFnMatrixAttribute mAttr;

    aBlendMesh = tAttr.create("blendMesh", "mesh", MFnData::kMesh);
    tAttr.setArray(true);
    tAttr.setUsesArrayDataBuilder(true);
    addAttribute(aBlendMesh);
    attributeAffects( aBlendMesh, outputGeom );

    aWeight = nAttr.create("blendWeight", "bw", MFnNumericData::kDouble, 0.0);
    nAttr.setArray(true);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aWeight);
    attributeAffects( aWeight, outputGeom );

    aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aRotationConsistency );
    attributeAffects( aRotationConsistency, outputGeom );

    aInitRotation = nAttr.create("initRotation", "ir", MFnNumericData::kDouble);
    addAttribute(aInitRotation);
    attributeAffects( aInitRotation, outputGeom );

    aVisualiseEnergy = nAttr.create( "visualiseEnergy", "ve", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aVisualiseEnergy );
    attributeAffects( aVisualiseEnergy, outputGeom );

    aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
    addAttribute( aVisualisationMultiplier );
    attributeAffects( aVisualisationMultiplier, outputGeom );

    aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL );
    eAttr.addField( "expSO+expSym", BM_SRL );
    eAttr.addField( "logmatrix3", BM_LOG3 );
    eAttr.addField( "quat+linear", BM_SQL );
    eAttr.addField( "expSO+linear", BM_SlRL );
    eAttr.addField( "linear", BM_AFF );
    eAttr.addField( "off", BM_OFF );
    addAttribute( aBlendMode );
    attributeAffects( aBlendMode, outputGeom );

    aTetMode = eAttr.create( "tetMode", "tm", TM_FACE );
    eAttr.addField( "face", TM_FACE );
    eAttr.addField( "edge", TM_EDGE );
    eAttr.addField( "vertex", TM_VERTEX );
    eAttr.addField( "vface", TM_VFACE );
    addAttribute( aTetMode );
    attributeAffects( aTetMode, outputGeom );

    aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1);
    addAttribute(aIteration);
    attributeAffects(aIteration, outputGeom);

    // this shouldn't affect outputGeom
    aEnergy = nAttr.create("energy", "energy", MFnNumericData::kDouble, 0.0);
    nAttr.setArray(true);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aEnergy);

    // Make the deformer weights paintable
    MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer nwayBlender weights;" );

    return MS::kSuccess;
}
Ejemplo n.º 9
0
MStatus NBuddyEMPSaverNode::initialize()

{
    MStatus status;

    MFnTypedAttribute typedAttr; //Typed attributes
    MFnUnitAttribute unitAttr;
    MFnStringData stringData; //String Attributes
    MFnNumericAttribute numFn; //Numerics
    MFnPluginData dataFn;

    //Create the body input array attribute
    _inBodies = typedAttr.create("inBodies","inb" , naiadBodyData::id , MObject::kNullObj , &status);
    NM_CheckMStatus(status, "ERROR creating inBodies attribute.\n");
    typedAttr.setStorable( false );
    typedAttr.setKeyable( false );
    typedAttr.setWritable(true);
    typedAttr.setReadable(false);
    typedAttr.setArray( true );
    status = addAttribute( _inBodies );
    NM_CheckMStatus(status, "ERROR adding inBodies attribute.\n");

    //Attribute for the folder in which to put the emp files
    _empOutputPath = typedAttr.create( "empOutputPath", "ef", MFnData::kString ,stringData.create(MString("/home/jimmi/dev/naiad/emopen/maya/naiadForMaya/test.#.emp")), &status);
    NM_CheckMStatus( status, "Failed to create empOutputPath attribute");
    typedAttr.setStorable( true );
    status = addAttribute( _empOutputPath );
    NM_CheckMStatus( status, "Failed to add empOutputPath plug");

    //Time input
    _time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &status );
    NM_CheckMStatus( status, "Failed to create time attribute");
    unitAttr.setStorable(true);
    unitAttr.setWritable(true);
    status = addAttribute( _time );
    NM_CheckMStatus( status, "Failed to add time plug");

    _framePadding = numFn.create( "framePadding", "fp", MFnNumericData::kInt, 4 , &status );
    NM_CheckMStatus( status, "Failed to create framePadding attribute");
    numFn.setStorable(true);
    numFn.setWritable(true);
    status = addAttribute( _framePadding );
    NM_CheckMStatus( status, "Failed to add framePadding plug");
 
    _timeStep = numFn.create( "timeStep", "ts", MFnNumericData::kInt, 0 , &status );
    NM_CheckMStatus( status, "Failed to create timeStep attribute");
    numFn.setStorable(true);
    numFn.setWritable(true);
    status = addAttribute( _timeStep );
    NM_CheckMStatus( status, "Failed to add timeStep plug");

    // an dummy output trigger to force evaluation of the node
    _outTrigger = numFn.create("outTrigger", "ot", MFnNumericData::kBoolean);
    NM_CheckMStatus( status, "Failed to create outTrigger attribute");
    numFn.setStorable(false);
    numFn.setWritable(false);
    status = addAttribute( _outTrigger );
    NM_CheckMStatus( status, "Failed to add outTrigger plug");

    //Attribute Affects
    attributeAffects( _inBodies, _outTrigger );
    attributeAffects( _time, _outTrigger );
    attributeAffects( _framePadding, _outTrigger );
    attributeAffects( _timeStep, _outTrigger );
    attributeAffects( _empOutputPath, _outTrigger );

    return MS::kSuccess;
}
Ejemplo n.º 10
0
MStatus ProxyViz::initialize()
{ 
	MFnNumericAttribute numFn;
	MStatus			 stat;
	
	alodgatehigh = numFn.create( "lodGateMax", "ldmx", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	numFn.setMax(2.f);
	addAttribute(alodgatehigh);
	
	alodgatelow = numFn.create( "lodGateMin", "ldmin", MFnNumericData::kFloat, 0.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.f);
	numFn.setMax(0.999f);
	addAttribute(alodgatelow);

	abboxminx = numFn.create( "bBoxMinX", "bbmnx", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminx);
	
	abboxminy = numFn.create( "bBoxMinY", "bbmny", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminy);
	
	abboxminz = numFn.create( "bBoxMinZ", "bbmnz", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminz);
	
	abboxmaxx = numFn.create( "bBoxMaxX", "bbmxx", MFnNumericData::kFloat, 1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxx);
	
	abboxmaxy = numFn.create( "bBoxMaxY", "bbmxy", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxy);
	
	abboxmaxz = numFn.create( "bBoxMaxZ", "bbmxz", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxz);
	
	aradiusMult = numFn.create( "radiusMultiplier", "rml", MFnNumericData::kFloat);
	numFn.setStorable(true);
	numFn.setKeyable(true);
	numFn.setDefault(1.f);
	numFn.setMin(.05f);
	addAttribute(aradiusMult);
	
	axmultiplier = numFn.create( "visualMultiplierX", "vmx", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(axmultiplier);	
	aymultiplier = numFn.create( "visualMultiplierY", "vmy", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(aymultiplier);
	
	azmultiplier = numFn.create( "visualMultiplierZ", "vmz", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(azmultiplier);
	
	agroupcount = numFn.create( "numberInstances", "nis", MFnNumericData::kInt, 1);
	numFn.setKeyable(false);
	numFn.setStorable(true);
	numFn.setMin(1);
	addAttribute(agroupcount);
	
	ainstanceId = numFn.create( "instanceId", "iis", MFnNumericData::kInt, 0);
	numFn.setKeyable(false);
	numFn.setStorable(true);
	numFn.setMin(0);
	addAttribute(ainstanceId);

	MFnTypedAttribute typedAttrFn;
	MVectorArray defaultVectArray;
	MFnVectorArrayData vectArrayDataFn;
	vectArrayDataFn.create( defaultVectArray );
	outPositionPP = typedAttrFn.create( "outPosition",
											"opos",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create pospp");

	typedAttrFn.setStorable(false);
	if(addAttribute( outPositionPP ) != MS::kSuccess) MGlobal::displayWarning("failed add pospp");
	
	outScalePP = typedAttrFn.create( "outScale",
											"oscl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create sclpp");

        typedAttrFn.setStorable(false);
        if(addAttribute(outScalePP) != MS::kSuccess) MGlobal::displayWarning("failed add sclpp");
		
	outRotationPP = typedAttrFn.create( "outRotation",
											"orot",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create rotpp");

        typedAttrFn.setStorable(false);
        if(addAttribute(outRotationPP) != MS::kSuccess) MGlobal::displayWarning("failed add rotpp");
		
	MDoubleArray defaultDArray;
	MFnDoubleArrayData dArrayDataFn;
	dArrayDataFn.create( defaultDArray );
	
	outReplacePP = typedAttrFn.create( "outReplace", "orpl",
									MFnData::kDoubleArray, dArrayDataFn.object(),
									&stat );
											
	if(stat != MS::kSuccess) {
		MGlobal::displayWarning("failed create outReplace");
	}
	
	typedAttrFn.setStorable(false);
	
	stat = addAttribute(outReplacePP);
	if(stat != MS::kSuccess) {
		MGlobal::displayWarning("failed add outReplace");
	}
	
    outValue = numFn.create( "outValue", "ov", MFnNumericData::kFloat );
	numFn.setStorable(false);
	numFn.setWritable(false);
	addAttribute(outValue);
	
	outValue1 = numFn.create( "outValue1", "ov1", MFnNumericData::kFloat );
	numFn.setStorable(false);
	numFn.setWritable(false);
	addAttribute(outValue1);
	
	MFnTypedAttribute   stringAttr;
	acachename = stringAttr.create( "cachePath", "cp", MFnData::kString );
 	stringAttr.setStorable(true);
	addAttribute( acachename );
	
	astandinNames = stringAttr.create( "standinNames", "sdn", MFnData::kString );
 	stringAttr.setStorable(true);
	stringAttr.setArray(true);
	addAttribute(astandinNames);
	
	MFnMatrixAttribute matAttr;
	acameraspace = matAttr.create( "cameraSpace", "cspc", MFnMatrixAttribute::kDouble );
 	matAttr.setStorable(false);
	matAttr.setWritable(true);
	matAttr.setConnectable(true);
	addAttribute(acameraspace);
	
	ahapeture = numFn.create( "horizontalFilmAperture", "hfa", MFnNumericData::kDouble, 1.0 );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( ahapeture );
	
	avapeture = numFn.create( "verticalFilmAperture", "vfa", MFnNumericData::kDouble, 1.0 );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( avapeture );
	
	afocallength = numFn.create( "focalLength", "fl", MFnNumericData::kDouble );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( afocallength );
	
	aconvertPercentage = numFn.create( "convertPercentage", "cvp", MFnNumericData::kDouble );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	numFn.setDefault(1.0);
	numFn.setMax(1.0);
	numFn.setMin(0.01);
	addAttribute(aconvertPercentage);
    
    agroundMesh = typedAttrFn.create("groundMesh", "grdm", MFnMeshData::kMesh);
	typedAttrFn.setStorable(false);
	typedAttrFn.setWritable(true);
	typedAttrFn.setConnectable(true);
    typedAttrFn.setArray(true);
    typedAttrFn.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( agroundMesh );
	attributeAffects(agroundMesh, outValue);
	
	agroundSpace = matAttr.create("groundSpace", "grdsp", MFnMatrixAttribute::kDouble);
	matAttr.setStorable(false);
	matAttr.setWritable(true);
	matAttr.setConnectable(true);
    matAttr.setArray(true);
    matAttr.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( agroundSpace );
	attributeAffects(agroundSpace, outValue);
	
	MPointArray defaultPntArray;
	MFnPointArrayData pntArrayDataFn;
	pntArrayDataFn.create( defaultPntArray );
	aplantTransformCache = typedAttrFn.create( "transformCachePlant",
											"tmcpl",
											MFnData::kPointArray,
											pntArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTransformCache);
	
	MIntArray defaultIntArray;
	MFnIntArrayData intArrayDataFn;
	
	intArrayDataFn.create( defaultIntArray );
	aplantIdCache = typedAttrFn.create( "idCachePlant",
											"idcpl",
											MFnData::kIntArray,
											intArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantIdCache);
	
	aplantTriangleIdCache = typedAttrFn.create( "triCachePlant",
											"trcpl",
											MFnData::kIntArray,
											intArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTriangleIdCache);
	
	aplantTriangleCoordCache = typedAttrFn.create( "coordCachePlant",
											"crcpl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTriangleCoordCache);
	
	aplantOffsetCache = typedAttrFn.create( "offsetCachePlant",
											"otcpl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantOffsetCache);
	
	ainexamp = typedAttrFn.create("inExample", "ixmp", MFnData::kPlugin);
	typedAttrFn.setStorable(false);
	typedAttrFn.setConnectable(true);
	typedAttrFn.setArray(true);
	addAttribute(ainexamp);
    
    adisplayVox = numFn.create( "showVoxelThreshold", "svt", MFnNumericData::kFloat );
	numFn.setDefault(1.0);
    numFn.setMin(.7);
    numFn.setMax(1.0);
    numFn.setStorable(true);
	numFn.setKeyable(true);
    addAttribute(adisplayVox);
	
	acheckDepth = numFn.create( "checkDepth", "cdp", MFnNumericData::kBoolean );
	numFn.setDefault(0);
	numFn.setStorable(false);
	addAttribute(acheckDepth);
	
	ainoverscan = numFn.create( "cameraOverscan", "cos", MFnNumericData::kDouble );
	numFn.setDefault(1.33);
	numFn.setStorable(false);
	addAttribute(ainoverscan);
    
    aactivated = numFn.create( "activated", "act", MFnNumericData::kBoolean );
	numFn.setDefault(0);
	numFn.setStorable(false);
	addAttribute(aactivated);
    
	attributeAffects(ainexamp, outValue1);
	attributeAffects(aradiusMult, outValue1);
	attributeAffects(abboxminx, outValue);
	attributeAffects(abboxmaxx, outValue);
	attributeAffects(abboxminy, outValue);
	attributeAffects(abboxmaxy, outValue);
	attributeAffects(abboxminz, outValue);
	attributeAffects(abboxmaxz, outValue);
	attributeAffects(outPositionPP, outValue);
	
	return MS::kSuccess;
}
Ejemplo n.º 11
0
MStatus snapDeformer::initialize() {
	MStatus stat;

    MFnNumericAttribute FnNumeric;
    MFnNumericAttribute FnNumericA;
    MFnTypedAttribute FnTyped;
    MFnEnumAttribute FnEnum;

	//weight
	weight = FnNumeric.create("weight", "we", MFnNumericData::kFloat);
	FnNumeric.setKeyable(true);
	FnNumeric.setStorable(true);
	FnNumeric.setReadable(true);
	FnNumeric.setWritable(true);
    FnNumeric.setDefault( 1.0 );
	addAttribute( weight );


    ///space target
	space = FnEnum.create("space", "sp", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(space);

    ///space source
	spaceSource = FnEnum.create("spaceSource", "sps", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(spaceSource);


	//pointlist
	pointList = FnNumericA.create("pointList", "pl", MFnNumericData::kInt);
	FnNumericA.setArray( true );
	FnNumericA.setKeyable(false);
	FnNumericA.setStorable(true);
	FnNumericA.setReadable(true);
	FnNumericA.setWritable(true);
    FnNumericA.setIndexMatters(true);
	addAttribute( pointList );


	//snapMesh
	snapMesh = FnTyped.create("snapMesh", "sm", MFnData::kMesh);
	FnTyped.setArray( false );
	FnTyped.setReadable(true);
	FnTyped.setWritable(true);
	addAttribute( snapMesh );



	attributeAffects(snapMesh, outputGeom);
	attributeAffects(pointList, outputGeom);
	attributeAffects(space, outputGeom);
    attributeAffects(spaceSource, outputGeom);
	attributeAffects(weight, outputGeom);

    return stat;
}
Ejemplo n.º 12
0
MStatus AlembicCurvesNode::initialize()
{
  MStatus status;

  MFnUnitAttribute uAttr;
  MFnTypedAttribute tAttr;
  MFnNumericAttribute nAttr;
  MFnGenericAttribute gAttr;
  MFnStringData emptyStringData;
  MObject emptyStringObject = emptyStringData.create("");

  // input time
  mTimeAttr = uAttr.create("inTime", "tm", MFnUnitAttribute::kTime, 0.0);
  status = uAttr.setStorable(true);
  status = uAttr.setKeyable(true);
  status = addAttribute(mTimeAttr);

  // input file name
  mFileNameAttr =
      tAttr.create("fileName", "fn", MFnData::kString, emptyStringObject);
  status = tAttr.setStorable(true);
  status = tAttr.setUsedAsFilename(true);
  status = tAttr.setKeyable(false);
  status = addAttribute(mFileNameAttr);

  // input identifier
  mIdentifierAttr =
      tAttr.create("identifier", "if", MFnData::kString, emptyStringObject);
  status = tAttr.setStorable(true);
  status = tAttr.setKeyable(false);
  status = addAttribute(mIdentifierAttr);

  // output curve
  mOutGeometryAttr = tAttr.create("outCurve", "os", MFnData::kNurbsCurve);
  status = tAttr.setArray(true);
  status = tAttr.setReadable(true);
  status = tAttr.setUsesArrayDataBuilder(true);
  status = tAttr.setStorable(false);
  status = tAttr.setWritable(false);
  status = tAttr.setKeyable(false);
  status = tAttr.setHidden(false);
  status = addAttribute(mOutGeometryAttr);

  // output for list of ArbGeomParams
  mGeomParamsList = tAttr.create("ExocortexAlembic_GeomParams", "exo_gp",
      MFnData::kString, emptyStringObject);
  status = tAttr.setStorable(true);
  status = tAttr.setKeyable(false);
  status = tAttr.setHidden(false);
  status = tAttr.setInternal(true);
  status = addAttribute(mGeomParamsList);

  // output for list of UserAttributes
  mUserAttrsList = tAttr.create("ExocortexAlembic_UserAttributes", "exo_ua",
      MFnData::kString, emptyStringObject);
  status = tAttr.setStorable(true);
  status = tAttr.setKeyable(false);
  status = tAttr.setHidden(false);
  status = tAttr.setInternal(true);
  status = addAttribute(mUserAttrsList);

  // create a mapping
  status = attributeAffects(mTimeAttr, mOutGeometryAttr);
  status = attributeAffects(mFileNameAttr, mOutGeometryAttr);
  status = attributeAffects(mIdentifierAttr, mOutGeometryAttr);
  return status;
}
Ejemplo n.º 13
0
// initialize
// ------------
//! Initialises the Attributes on the node, and set the evaluation dependencies
MStatus NBuddySurfaceToBodyNode::initialize()

{
    MStatus status;

    //Function sets needed
    MFnStringData stringData;
    MFnPluginData dataFn;
    MFnMatrixData matrixFn;
    MFnGenericAttribute genFn;
    MFnTypedAttribute typedAttr;
    MFnNumericAttribute numAttr;
    MFnMatrixAttribute  mAttr;

    //Attribute that specifies if the object should be converted to worldspace or localspace
    _useTransform = numAttr.create( "useTransform", "ut",  MFnNumericData::kBoolean, true, &status );
    NM_CheckMStatus(status, "ERROR creating useWorldSpace attribute.\n");
    status = addAttribute( _useTransform );

    //The input transform for the object
    _inTransform = mAttr.create("inTransform","it", MFnMatrixAttribute::kDouble, &status);
    mAttr.setStorable( true );
    mAttr.setConnectable(true);
    NM_CheckMStatus(status, "ERROR creating inTransform attribute.\n");
    status = addAttribute( _inTransform );
    NM_CheckMStatus(status, "ERROR adding inTransform attribute.\n");

    //Create the inSurface plug
    _inSurface = genFn.create( "inSurface", "surf", &status);
    NM_CheckMStatus( status, "Failed to create inSurface GenericAttribute");
    genFn.addAccept(MFnData::kNurbsSurface);
    genFn.addAccept(MFnData::kMesh);
    genFn.addAccept(MFnData::kSubdSurface);
    genFn.setStorable(false);
    genFn.setCached(false);
    status = addAttribute( _inSurface );
    NM_CheckMStatus(status, "ERROR adding inSurface attribute.\n");

    // Create the attribute for the body output
    _outBody = typedAttr.create("outBody","ob" , naiadBodyData::id , MObject::kNullObj , &status);
    NM_CheckMStatus(status, "ERROR creating outBody attribute.\n");
    typedAttr.setKeyable( false  );
    typedAttr.setWritable( false );
    typedAttr.setReadable( true  );
    typedAttr.setStorable( false );
    status = addAttribute( _outBody );
    NM_CheckMStatus(status, "ERROR adding outBody attribute.\n");

    // Create the attribute for the body name
    _bodyName = typedAttr.create( "bodyName", "bn", MFnData::kString ,stringData.create( MString("mesh-body") ), &status);
    NM_CheckMStatus( status, "Failed to create bodyName attribute");
    typedAttr.setStorable( true );
    typedAttr.setArray( false );
    status = addAttribute( _bodyName );
    NM_CheckMStatus( status, "Failed to add bodyName plug");

    //Tesselation settings
    _subDivide = numAttr.create( "subDivide", "td", MFnNumericData::kInt , 0, &status);
    NM_CheckMStatus( status, "Failed to create subDivide attribute");
    numAttr.setStorable( true );
    numAttr.setArray( false );
    status = addAttribute( _subDivide );
    NM_CheckMStatus( status, "Failed to add bodyName plug");

    // Attribute affects
    attributeAffects( _bodyName, _outBody );
    attributeAffects( _subDivide, _outBody );
    attributeAffects( _inSurface, _outBody );
    attributeAffects( _useTransform, _outBody );
    attributeAffects( _inTransform, _outBody );

    return MS::kSuccess;
}
// create attributes
MStatus probeDeformerARAPNode::initialize(){
    MFnTypedAttribute tAttr;
    MFnNumericAttribute nAttr;
    MFnEnumAttribute eAttr;
    MFnMatrixAttribute mAttr;
   	MRampAttribute rAttr;

    // this attr will be dirtied when ARAP recomputation is needed
    aARAP = nAttr.create( "arap", "arap", MFnNumericData::kBoolean, true );
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setHidden(true);
    addAttribute( aARAP );

    // this attr will be dirtied when weight recomputation is needed
    aComputeWeight = nAttr.create( "computeWeight", "computeWeight", MFnNumericData::kBoolean, true );
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setHidden(true);
    addAttribute( aComputeWeight );

    aMatrix = mAttr.create("probeMatrix", "pm");
    mAttr.setStorable(false);
    mAttr.setHidden(true);
    mAttr.setArray(true);
    mAttr.setUsesArrayDataBuilder(true);
    mAttr.setDisconnectBehavior(MFnMatrixAttribute::kDelete);
    addAttribute(aMatrix);
    attributeAffects( aMatrix, outputGeom );

    aInitMatrix = mAttr.create("initProbeMatrix", "ipm");
    mAttr.setHidden(true);
    mAttr.setArray(true);
    mAttr.setStorable(true);
    mAttr.setUsesArrayDataBuilder(true);
    addAttribute(aInitMatrix);
    attributeAffects( aInitMatrix, outputGeom );

    aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL );
    eAttr.addField( "expSO+expSym", BM_SRL );
    eAttr.addField( "expSE+expSym", BM_SSE );
    eAttr.addField( "logmatrix3", BM_LOG3 );
    eAttr.addField( "logmatrix4", BM_LOG4 );
    eAttr.addField( "quat+linear", BM_SQL );
    eAttr.addField( "linear", BM_AFF );
    eAttr.addField( "off", BM_OFF );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aBlendMode );
    attributeAffects( aBlendMode, outputGeom );

	aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false );
    nAttr.setKeyable(false);
    nAttr.setStorable(true);
    addAttribute( aRotationConsistency );
    attributeAffects( aRotationConsistency, outputGeom );

	aFrechetSum = nAttr.create( "frechetSum", "fs", MFnNumericData::kBoolean, false );
    nAttr.setKeyable(false);
    nAttr.setStorable(true);
    addAttribute( aFrechetSum );
    attributeAffects( aFrechetSum, outputGeom );
    
    aNormaliseWeight = eAttr.create( "normaliseWeight", "nw", NM_LINEAR );
    eAttr.addField( "NONE", NM_NONE );
    eAttr.addField( "Linear",  NM_LINEAR );
    eAttr.addField( "Softmax", NM_SOFTMAX );
    eAttr.setStorable(true);
    addAttribute( aNormaliseWeight );
    attributeAffects( aNormaliseWeight, outputGeom );
    attributeAffects( aNormaliseWeight, aComputeWeight );

    aWeightMode = eAttr.create( "weightMode", "wtm", WM_HARMONIC_COTAN );
    eAttr.addField( "inverse", WM_INV_DISTANCE );
    eAttr.addField( "cut-off", WM_CUTOFF_DISTANCE );
    eAttr.addField( "draw", WM_DRAW );
//    eAttr.addField( "harmonic-arap", WM_HARMONIC_ARAP);
    eAttr.addField( "harmonic-cotan", WM_HARMONIC_COTAN);
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aWeightMode );
    attributeAffects( aWeightMode, outputGeom );
    attributeAffects( aWeightMode, aComputeWeight );
    
    aConstraintMode = eAttr.create( "constraintMode", "ctm", CONSTRAINT_CLOSEST );
    eAttr.addField( "neighbour",  CONSTRAINT_NEIGHBOUR);
    eAttr.addField( "closestFace", CONSTRAINT_CLOSEST );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aConstraintMode );
    attributeAffects( aConstraintMode, outputGeom );
    attributeAffects( aConstraintMode, aARAP);

    aTetMode = eAttr.create( "tetMode", "tm", TM_FACE );
    eAttr.addField( "face", TM_FACE );
    eAttr.addField( "edge", TM_EDGE );
    eAttr.addField( "vertex", TM_VERTEX );
    eAttr.addField( "vface", TM_VFACE );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aTetMode );
    attributeAffects( aTetMode, outputGeom );
    attributeAffects( aTetMode, aARAP );
    attributeAffects( aTetMode, aComputeWeight );

	aWorldMode = nAttr.create( "worldMode", "wrldmd", MFnNumericData::kBoolean, true );
    nAttr.setStorable(true);
    nAttr.setKeyable(false);
    addAttribute( aWorldMode );
    attributeAffects( aWorldMode, outputGeom );
    attributeAffects( aWorldMode, aARAP );
    
	aEffectRadius = nAttr.create("effectRadius", "er", MFnNumericData::kDouble, 8.0);
    nAttr.setMin( EPSILON );
    nAttr.setStorable(true);
	addAttribute( aEffectRadius );
	attributeAffects( aEffectRadius, outputGeom );
	attributeAffects( aEffectRadius, aComputeWeight );
    
	aTransWeight = nAttr.create("translationWeight", "tw", MFnNumericData::kDouble, 1e-20);
    nAttr.setStorable(true);
	addAttribute( aTransWeight );
	attributeAffects( aTransWeight, outputGeom );
	attributeAffects( aTransWeight, aARAP );

    aAreaWeighted = nAttr.create( "areaWeighted", "aw", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aAreaWeighted );
    attributeAffects( aAreaWeighted, outputGeom );
    attributeAffects( aAreaWeighted, aARAP );

    aNeighbourWeighting = nAttr.create( "neighbourWeighting", "nghbrw", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aNeighbourWeighting );
    attributeAffects( aNeighbourWeighting, outputGeom );
    attributeAffects( aNeighbourWeighting, aComputeWeight );
    attributeAffects( aNeighbourWeighting, aARAP );

	aConstraintWeight = nAttr.create("constraintWeight", "cw", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aConstraintWeight );
	attributeAffects( aConstraintWeight, outputGeom );
	attributeAffects( aConstraintWeight, aARAP );
    
	aNormExponent = nAttr.create("normExponent", "ne", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aNormExponent );
	attributeAffects( aNormExponent, outputGeom );
	attributeAffects( aNormExponent, aARAP );
	attributeAffects( aNormExponent, aComputeWeight );
    
	aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1);
    nAttr.setStorable(true);
    addAttribute(aIteration);
    attributeAffects(aIteration, outputGeom);
    
	aConstraintRadius = nAttr.create("constraintRadius", "cr", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aConstraintRadius );
	attributeAffects( aConstraintRadius, outputGeom );
	attributeAffects( aConstraintRadius, aARAP );

    aVisualisationMode = eAttr.create( "visualisationMode", "vm", VM_OFF );
    eAttr.addField( "off", VM_OFF );
    eAttr.addField( "energy", VM_ENERGY );
    eAttr.addField( "effect", VM_EFFECT );
    eAttr.addField( "constraint", VM_CONSTRAINT );
    eAttr.addField( "stiffness", VM_STIFFNESS );
    eAttr.setStorable(true);
    addAttribute( aVisualisationMode );
    attributeAffects( aVisualisationMode, outputGeom );
    
	aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aVisualisationMultiplier );
	attributeAffects( aVisualisationMultiplier, outputGeom );
    
    aStiffness = eAttr.create( "stiffnessMode", "stfm", SM_NONE );
    eAttr.addField( "off", SM_NONE );
    eAttr.addField( "painted weight", SM_PAINT );
    eAttr.addField( "learn", SM_LEARN );
    eAttr.setStorable(true);
    addAttribute( aStiffness );
    attributeAffects( aStiffness, outputGeom );
    attributeAffects( aStiffness, aARAP );
    
	aSupervisedMesh = tAttr.create("supervisedMesh", "svmesh", MFnData::kMesh);
    tAttr.setStorable(true);
    tAttr.setArray(true);
    tAttr.setUsesArrayDataBuilder(true);
    addAttribute(aSupervisedMesh);
	attributeAffects( aSupervisedMesh, outputGeom );
	attributeAffects( aSupervisedMesh, aARAP );
    
    aProbeWeight = nAttr.create("probeWeight", "prw", MFnNumericData::kDouble, 1.0);
    nAttr.setArray(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aProbeWeight);
	attributeAffects( aProbeWeight, outputGeom );
	attributeAffects( aProbeWeight, aComputeWeight );

    aProbeConstraintRadius = nAttr.create("probeConstraintRadius", "prcr", MFnNumericData::kDouble, 1.0);
    nAttr.setArray(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aProbeConstraintRadius);
	attributeAffects( aProbeConstraintRadius, outputGeom );
	attributeAffects( aProbeConstraintRadius, aARAP );

	//ramp
    aWeightCurveR = rAttr.createCurveRamp( "weightCurveRotation", "wcr" );
    addAttribute( aWeightCurveR );
	attributeAffects( aWeightCurveR, outputGeom );
	attributeAffects( aWeightCurveR, aComputeWeight );
    aWeightCurveS = rAttr.createCurveRamp( "weightCurveShear", "wcs" );
    addAttribute( aWeightCurveS );
	attributeAffects( aWeightCurveS, outputGeom );
	attributeAffects( aWeightCurveS, aComputeWeight );
    aWeightCurveL = rAttr.createCurveRamp( "weightCurveTranslation", "wcl" );
    addAttribute( aWeightCurveL );
	attributeAffects( aWeightCurveL, outputGeom );
	attributeAffects( aWeightCurveL, aComputeWeight );
    
    // Make the deformer weights paintable
    MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer probeDeformerARAP weights;" );

    return MS::kSuccess;
}
Ejemplo n.º 15
0
// add some additional inputs
MStatus HRBFSkinCluster::initialize()
{
	std::cout << "called initialize" << std::endl;

	MFnNumericAttribute numAttr;
	MFnTypedAttribute typedAttr;
	//MFnCompoundAttribute cmpdAttr;

	MStatus returnStatus;
	HRBFSkinCluster::rebuildHRBF = numAttr.create("RebuildHRBF", "rbld", MFnNumericData::kInt,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating rbld attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::rebuildHRBF);
	McheckErr(returnStatus, "ERROR adding rbld attribute\n");

	HRBFSkinCluster::exportComposition = numAttr.create("ExportComp", "exprtC", MFnNumericData::kInt,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating exprtC attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::exportComposition);
	McheckErr(returnStatus, "ERROR adding exprtC attribute\n");

	HRBFSkinCluster::exportHRBFSamples = typedAttr.create("ExportHRBFs", "exprtS", MFnNumericData::kString,
		&returnStatus);
	McheckErr(returnStatus, "ERROR creating exprtS attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::exportHRBFSamples);
	McheckErr(returnStatus, "ERROR adding exprtS attribute\n");

	HRBFSkinCluster::exportHRBFValues = typedAttr.create("ExportHRBFv", "exprtV", MFnNumericData::kString,
		&returnStatus);
	McheckErr(returnStatus, "ERROR creating exprtV attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::exportHRBFValues);
	McheckErr(returnStatus, "ERROR adding exprtV attribute\n");

	HRBFSkinCluster::useDQ = numAttr.create("UseDualQuaternions", "useDQ", MFnNumericData::kInt,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating useDQ attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::useDQ);
	McheckErr(returnStatus, "ERROR adding useDQ attribute\n");

	HRBFSkinCluster::useHRBF = numAttr.create("UseHRBFCorrection", "useHRBF", MFnNumericData::kInt,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating useHRBF attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::useHRBF);
	McheckErr(returnStatus, "ERROR adding useHRBF attribute\n");

	HRBFSkinCluster::checkHRBFAt = numAttr.create("checkHRBFAt", "chkHRBF", MFnNumericData::k3Double,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating checkHRBFAt attribute\n");
	returnStatus = addAttribute(HRBFSkinCluster::checkHRBFAt);
	McheckErr(returnStatus, "ERROR adding checkHRBFAt attribute\n");

	// hierarchy information
	// http://download.autodesk.com/us/maya/2011help/API/weight_list_node_8cpp-example.html#a15
	HRBFSkinCluster::jointParentIdcs = numAttr.create("parentJointIDCS", "pJIDCS", MFnNumericData::kInt,
		0, &returnStatus);
	McheckErr(returnStatus, "ERROR creating pIDCS attribute\n");
	numAttr.setArray(true);
	returnStatus = addAttribute(HRBFSkinCluster::jointParentIdcs);
	McheckErr(returnStatus, "ERROR adding pIDCS attribute\n");

	// joint names
	HRBFSkinCluster::jointNames = typedAttr.create("jointNames", "jNms", MFnData::kString,
		&returnStatus);
	McheckErr(returnStatus, "ERROR creating pIDCS attribute\n");
	typedAttr.setArray(true);
	returnStatus = addAttribute(HRBFSkinCluster::jointNames);
	McheckErr(returnStatus, "ERROR adding jNms attribute\n");

	// set up affects
	returnStatus = attributeAffects(HRBFSkinCluster::rebuildHRBF,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with rebuildHRBF\n");

	returnStatus = attributeAffects(HRBFSkinCluster::exportComposition,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with exportComposition\n");

	returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFSamples,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFSamples\n");

	returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFValues,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFValues\n");

	returnStatus = attributeAffects(HRBFSkinCluster::useDQ,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with useDQ\n");

	returnStatus = attributeAffects(HRBFSkinCluster::useHRBF,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with useHRBF\n");

	returnStatus = attributeAffects(HRBFSkinCluster::jointParentIdcs,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with jointParentIdcs\n");

	returnStatus = attributeAffects(HRBFSkinCluster::checkHRBFAt,
		HRBFSkinCluster::outputGeom);
	McheckErr(returnStatus, "ERROR in attributeAffects with checkHRBFAt\n");

    return returnStatus;
}