MStatus SwirlDeformer::initialize()
{
MFnMatrixAttribute mAttr;
deformSpace = mAttr.create( "deformSpace", "dSp" );
mAttr.setStorable( false );

MFnUnitAttribute unitFn;    
startDist = unitFn.create( "startDist", "sd", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance( 0.0, MDistance::uiUnit() ) );
unitFn.setMin( MDistance( 0.0, MDistance::uiUnit() ) );
unitFn.setKeyable( true );

endDist = unitFn.create( "endDist", "ed", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance( 3.0, MDistance::uiUnit() ) );
unitFn.setMin( MDistance( 0.0, MDistance::uiUnit() ) );
unitFn.setKeyable( true );

addAttribute( deformSpace );
addAttribute( startDist );
addAttribute( endDist );

attributeAffects( deformSpace, outputGeom );
attributeAffects( startDist, outputGeom );
attributeAffects( endDist, outputGeom );

return MS::kSuccess;
}
示例#2
0
MStatus timeControl::initialize()
{
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnUnitAttribute uAttr;

	aOutTime = uAttr.create( "outTime", "outTime", MFnUnitAttribute::kTime, 0.0 );
	uAttr.setStorable( true );
	CHECK_MSTATUS( addAttribute( aOutTime ) );

	aOutWeight = nAttr.create( "outWeight", "outWeight", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable( true );
	CHECK_MSTATUS( addAttribute( aOutWeight ) );

	aInTime = uAttr.create( "inTime", "inTime", MFnUnitAttribute::kTime, 0.0 );
	uAttr.setStorable( true );
	CHECK_MSTATUS( addAttribute( aInTime ) );
	CHECK_MSTATUS( attributeAffects( aInTime, aOutTime ) );

	aWeight = nAttr.create( "weight", "weight", MFnNumericData::kDouble, 10.0 );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aWeight ) );
	CHECK_MSTATUS( attributeAffects( aWeight, aOutWeight ) );

	aOffset = nAttr.create( "offset", "offset", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aOffset ) );
	CHECK_MSTATUS( attributeAffects( aOffset, aOutTime ) );

	aMult = nAttr.create( "mult", "mult", MFnNumericData::kDouble, 1.0 );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aMult ) );
	CHECK_MSTATUS( attributeAffects( aMult, aOutTime ) );

	aLimitAble = nAttr.create( "limitAble", "limitAble", MFnNumericData::kBoolean, false );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aLimitAble ) );
	CHECK_MSTATUS( attributeAffects( aLimitAble, aOutTime ) );

	aMinTime = uAttr.create( "minTime", "minTime", MFnUnitAttribute::kTime, 1.0 );
	uAttr.setStorable( true );
	uAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aMinTime ) );
	CHECK_MSTATUS( attributeAffects( aMinTime, aOutTime ) );

	aMaxTime = uAttr.create( "maxTime", "maxTime", MFnUnitAttribute::kTime, 20.0 );
	uAttr.setStorable( true );
	uAttr.setKeyable( true );
	CHECK_MSTATUS( addAttribute( aMaxTime ) );
	CHECK_MSTATUS( attributeAffects( aMaxTime, aOutTime ) );


	return MS::kSuccess;
}
MStatus arrowLocator::initialize()
{
	//Here we create a new attribute type that handles units: angle, distance or time
	MFnUnitAttribute uAttr;
	windDirection = uAttr.create("windDirection", "wd", MFnUnitAttribute::kAngle, 0.0);
	uAttr.setStorable(true);
	uAttr.setWritable(true);
	uAttr.setReadable(true);
	uAttr.setKeyable(true);

	uAttr.setDefault(MAngle(0.0, MAngle::kDegrees));

	addAttribute(windDirection);

	//- TODO: To make connection between your custom node and your custom 
	//- TODO: manipulator node, you need to name your custom manipulator 
	//- TODO: after your custom node type name, also in your custom node's initialize()
	//- TODO: function, you need to call MPxManipContainer::addToManipConnectTable().
	//- TODO: This method adds the user defined node as an entry in the manipConnectTable 
	//- TODO: so that when this node is selected the user can use the show manip tool to 
	//- TODO: get the user defined manipulator associated with this node.
	//...

	return MS::kSuccess;
}
示例#4
0
MStatus ArrayAngleConstructorNode::initialize()
{
    MStatus status;

    MFnNumericAttribute N;
    MFnTypedAttribute T;
    MFnUnitAttribute U;

    aSize = N.create("size", "size", MFnNumericData::kInt, 8.0, &status);
    N.setKeyable(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(8);

    aInput = U.create("input", "i", MFnUnitAttribute::kAngle, 0.0, &status);
    U.setKeyable(false);
    U.setStorable(true);
    U.setWritable(true);
    U.setArray(true);

    aOutput = T.create("output", "o", MFnData::kDoubleArray, &status);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setWritable(false);
    T.setStorable(false);

    addAttribute(aSize);
    addAttribute(aInput);
    addAttribute(aOutput);

    attributeAffects(aSize, aOutput);
    attributeAffects(aInput, aOutput);

    return MS::kSuccess;
}
MStatus simpleEvaluationNode::initialize()
{
	MFnNumericAttribute nAttr;
	MFnUnitAttribute    uAttr;
	MStatus				status;

	input = nAttr.create( "input", "in", MFnNumericData::kFloat, 2.0 );
 	nAttr.setStorable(true);

	aTimeInput = uAttr.create( "inputTime", "itm", MFnUnitAttribute::kTime, 0.0 );
	uAttr.setWritable(true);
	uAttr.setStorable(true);
    uAttr.setReadable(true);
    uAttr.setKeyable(true);

	output = nAttr.create( "output", "out", MFnNumericData::kFloat, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	status = addAttribute( input );
		if (!status) { status.perror("addAttribute"); return status;}
	status = addAttribute( aTimeInput );
		if (!status) { status.perror("addAttribute"); return status;}
	status = addAttribute( output );
		if (!status) { status.perror("addAttribute"); return status;}

	status = attributeAffects( input, output );
		if (!status) { status.perror("attributeAffects"); return status;}
	status = attributeAffects( aTimeInput, output );
		if (!status) { status.perror("attributeAffects"); return status;}

	return MS::kSuccess;
}
MStatus BasicLocator::initialize()
{ 
MFnUnitAttribute unitFn;    
MFnNumericAttribute numFn;
MStatus stat;
    
xWidth = unitFn.create( "xWidth", "xw", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) );
unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) );
unitFn.setKeyable( true );
stat = addAttribute( xWidth );
if (!stat) 
    {
	stat.perror( "Unable to add \"xWidth\" attribute" );
	return stat;
    } 

zWidth = unitFn.create( "zWidth", "zw", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) );
unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) );
unitFn.setKeyable( true );
stat = addAttribute( zWidth );
if (!stat) 
    {
	stat.perror( "Unable to add \"zWidth\" attribute" );
	return stat;
    } 

dispType = numFn.create( "dispType", "att", MFnNumericData::kShort );
numFn.setDefault( 0);
numFn.setMin( 0 );
numFn.setMax( 2 );
numFn.setKeyable( true );
stat = addAttribute( dispType );
if (!stat) 
    {
	stat.perror( "Unable to add \"dispType\" attribute" );
	return stat;
    }

// Notify Maya that there is an associated manipulator for this particular type of node
MPxManipContainer::addToManipConnectTable( const_cast<MTypeId &>( typeId ) );

return MS::kSuccess;
}
MStatus AlembicCurvesDeformNode::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 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, outputGeom);
  status = attributeAffects(mFileNameAttr, outputGeom);
  status = attributeAffects(mIdentifierAttr, outputGeom);

  return status;
}
//- The initialize method is called to create and initialize all of the 
//- attributes and attribute dependencies for this node type. This is 
//- only called once when the node type is registered with Maya.
//- Return Values: MS::kSuccess / MS::kFailure
//-
/*static*/ MStatus arrowLocator::initialize()
{
	//- Here we create a new attribute type that handles units: angle, distance or time
	MFnUnitAttribute uAttr;
	windDirection = uAttr.create("windDirection", "wd", MFnUnitAttribute::kAngle, 0.0);
	uAttr.setStorable(true);
	uAttr.setWritable(true);
	uAttr.setReadable(true);
	uAttr.setKeyable(true);
	uAttr.setMin(0.0);
	uAttr.setMax(2*PI);
	uAttr.setDefault(MAngle(0.0, MAngle::kRadians));
	addAttribute(windDirection);

	return MS::kSuccess;
}
//- The initialize method is called to create and initialize all of the 
//- attributes and attribute dependencies for this node type. This is 
//- only called once when the node type is registered with Maya.
//- Return Values: MS::kSuccess / MS::kFailure
//-
/*static*/ MStatus arrowLocator::initialize()
{
	//- Here we create a new attribute type that handles units: angle, distance or time
	MFnUnitAttribute uAttr;
	//- TODO: Create a angle attribute with long name "windDirection" and short name "wd"
	windDirection = //...
	uAttr.setStorable(true);
	uAttr.setWritable(true);
	uAttr.setReadable(true);
	uAttr.setKeyable(true);
	//- TODO: Set the min and max value this attribute can have 0, 2PI
	//...
	//...
	uAttr.setDefault(MAngle(0.0, MAngle::kRadians));
	addAttribute(windDirection);

	return MS::kSuccess;
}
MStatus AlembicCurvesLocatorNode::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);

  // sentinel attr
  mSentinelAttr = nAttr.create("sentinel", "sent", MFnNumericData::kInt, 0);
  nAttr.setHidden(true);
  status = addAttribute(mSentinelAttr);

  // create a mapping
  status = attributeAffects(mTimeAttr, mSentinelAttr);
  status = attributeAffects(mFileNameAttr, mSentinelAttr);
  status = attributeAffects(mIdentifierAttr, mSentinelAttr);

  return status;
}
示例#11
0
MStatus dgTransform::initialize()
{
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnMatrixAttribute mAttr;
	MFnUnitAttribute uAttr;

	aTranslateX = nAttr.create( "translateX", "tx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslateY = nAttr.create( "translateY", "ty", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslateZ = nAttr.create( "translateZ", "tz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslate  = nAttr.create( "translate", "t", aTranslateX, aTranslateY, aTranslateZ );
	nAttr.setStorable( true );
	status = addAttribute( aTranslate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aRotateX = uAttr.create( "rotateX", "rx", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotateY = uAttr.create( "rotateY", "ry", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotateZ = uAttr.create( "rotateZ", "rz", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotate  = nAttr.create( "rotate", "r", aRotateX, aRotateY, aRotateZ );
	nAttr.setStorable( true );
	status = addAttribute( aRotate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aScaleX = nAttr.create( "scaleX", "sx", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScaleY = nAttr.create( "scaleY", "sy", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScaleZ = nAttr.create( "scaleZ", "sz", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScale  = nAttr.create( "scale", "s", aScaleX, aScaleY, aScaleZ );
	nAttr.setStorable( true );
	status = addAttribute( aScale );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aShearX = nAttr.create( "shearX", "shx", MFnNumericData::kDouble, 0.0 );
	aShearY = nAttr.create( "shearY", "shy", MFnNumericData::kDouble, 0.0 );
	aShearZ = nAttr.create( "shearZ", "shz", MFnNumericData::kDouble, 0.0 );
	aShear  = nAttr.create( "shear", "sh", aShearX, aShearY, aShearZ );
	nAttr.setStorable( true );
	status = addAttribute( aShear );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aJointOrientX = uAttr.create( "jointOrientX", "jox", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrientY = uAttr.create( "jointOrientY", "joy", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrientZ = uAttr.create( "jointOrientZ", "joz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrient  = nAttr.create( "jointOrient", "jo", aJointOrientX, aJointOrientY, aJointOrientZ );
	nAttr.setStorable( true );
	status = addAttribute( aJointOrient );
	CHECK_MSTATUS_AND_RETURN_IT( status );


	aInputTranslateX = nAttr.create( "inputTranslateX", "itx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslateY = nAttr.create( "inputTranslateY", "ity", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslateZ = nAttr.create( "inputTranslateZ", "itz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslate  = nAttr.create( "inputTranslate", "it", aInputTranslateX, aInputTranslateY, aInputTranslateZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputTranslate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputRotateX = uAttr.create( "inputRotateX", "irx", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotateY = uAttr.create( "inputRotateY", "iry", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotateZ = uAttr.create( "inputRotateZ", "irz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotate  = nAttr.create( "inputRotate", "ir", aInputRotateX, aInputRotateY, aInputRotateZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputRotate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputScaleX = nAttr.create( "inputScaleX", "isx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScaleY = nAttr.create( "inputScaleY", "isy", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScaleZ = nAttr.create( "inputScaleZ", "isz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScale  = nAttr.create( "inputScale", "is", aInputScaleX, aInputScaleY, aInputScaleZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputScale );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputShearX = nAttr.create( "inputShearX", "ishx", MFnNumericData::kDouble, 0.0 );
	aInputShearY = nAttr.create( "inputShearY", "ishy", MFnNumericData::kDouble, 0.0 );
	aInputShearZ = nAttr.create( "inputShearZ", "ishz", MFnNumericData::kDouble, 0.0 );
	aInputShear  = nAttr.create( "inputShear", "ish", aInputShearX, aInputShearY, aInputShearZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputShear );
	CHECK_MSTATUS_AND_RETURN_IT( status );


	MObject* affectedAttrs[6];

	aMatrix = mAttr.create( "matrix", "m" );
	nAttr.setStorable( false );
	status = addAttribute( aMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[0] = &aMatrix;

	aInverseMatrix = mAttr.create( "inverseMatrix", "im" );
	nAttr.setStorable( false );
	status = addAttribute( aInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[1] = &aInverseMatrix;

	aWorldMatrix = mAttr.create( "worldMatrix", "wm" );
	nAttr.setStorable( false );
	status = addAttribute( aWorldMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[2] = &aWorldMatrix;

	aWorldInverseMatrix = mAttr.create( "worldInverseMatrix", "wim" );
	nAttr.setStorable( false );
	status = addAttribute( aWorldInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[3] = &aWorldInverseMatrix;

	aParentMatrix = mAttr.create( "parentMatrix", "pm" );
	nAttr.setStorable( false );
	status = addAttribute( aParentMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[4] = &aParentMatrix;

	aParentInverseMatrix = mAttr.create( "parentInverseMatrix", "pim" );
	nAttr.setStorable( false );
	status = addAttribute( aParentInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[5] = &aParentInverseMatrix;

	status = attributeAffectsArray( aTranslate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aRotate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aScale, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aShear, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aJointOrient, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputTranslate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputRotate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputScale, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputShear, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	return MS::kSuccess;
}