本文整理汇总了C++中MFnUnitAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ MFnUnitAttribute类的具体用法?C++ MFnUnitAttribute怎么用?C++ MFnUnitAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFnUnitAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
MStatus animCube::initialize()
{
MFnUnitAttribute unitAttr;
MFnTypedAttribute typedAttr;
MStatus returnStatus;
animCube::time = unitAttr.create( "time", "tm",
MFnUnitAttribute::kTime,
0.0, &returnStatus );
McheckErr(returnStatus, "ERROR creating animCube time attribute\n");
animCube::outputMesh = typedAttr.create( "outputMesh", "out",
MFnData::kMesh,
&returnStatus );
McheckErr(returnStatus, "ERROR creating animCube output attribute\n");
typedAttr.setStorable(false);
returnStatus = addAttribute(animCube::time);
McheckErr(returnStatus, "ERROR adding time attribute\n");
returnStatus = addAttribute(animCube::outputMesh);
McheckErr(returnStatus, "ERROR adding outputMesh attribute\n");
returnStatus = attributeAffects(animCube::time,
animCube::outputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
return MS::kSuccess;
}
示例2: initialize
MStatus ClothSimMayaPlugin::initialize()
{
MFnUnitAttribute unitAttr;
MFnTypedAttribute typedAttr;
MStatus returnStatus;
g_aTime = unitAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus);
McheckErr(returnStatus, "ERROR creating time attribute\n");
g_aOutputMesh = typedAttr.create("outputMesh", "out", MFnData::kMesh, &returnStatus);
McheckErr(returnStatus, "ERROR creating output attribute\n");
typedAttr.setStorable(false);
returnStatus = addAttribute(g_aTime);
McheckErr(returnStatus, "ERROR adding time attribute\n");
returnStatus = addAttribute(g_aOutputMesh);
McheckErr(returnStatus, "ERROR adding outputMesh attribute\n");
returnStatus = attributeAffects(g_aTime, g_aOutputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
return MS::kSuccess;
}
示例3: initialize
MStatus testNpassiveNode::initialize()
{
MStatus stat;
MFnTypedAttribute tAttr;
inputGeom = tAttr.create("inputGeom", "ing", MFnData::kMesh, MObject::kNullObj, &stat );
//statCheck(stat, "failed to create inputGeom");
tAttr.setWritable(true);
tAttr.setStorable(true);
tAttr.setHidden(true);
currentState = tAttr.create("currentState", "cus", MFnData::kNObject, MObject::kNullObj, &stat );
// statCheck(stat, "failed to create currentState");
tAttr.setWritable(true);
tAttr.setStorable(false);
tAttr.setHidden(true);
startState = tAttr.create( "startState", "sts", MFnData::kNObject, MObject::kNullObj, &stat );
//statCheck(stat, "failed to create startState");
tAttr.setWritable(true);
tAttr.setStorable(false);
tAttr.setHidden(true);
MFnUnitAttribute uniAttr;
currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime, 0.0, &stat );
addAttribute(inputGeom);
addAttribute(currentTime);
addAttribute(startState);
addAttribute(currentState);
attributeAffects(inputGeom, startState);
attributeAffects(inputGeom, currentState);
attributeAffects(currentTime, currentState);
attributeAffects(currentTime, startState);
return MStatus::kSuccess;
}
示例4: initialize
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;
}
示例5: MDistance
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;
}
示例6: McheckErr
MStatus LSystemNode::initialize()
{
MFnUnitAttribute unitAttr;
MFnTypedAttribute typedAttr;
MFnNumericAttribute numericAttr;
MStatus returnStatus;
//(i)angle
LSystemNode::angle = numericAttr.create("angle","ag",MFnNumericData::kDouble,90.0,&returnStatus);
McheckErr(returnStatus, "ERROR creating LSystemNode angle attribute\n");
//(ii)size
step = numericAttr.create("step","st",MFnNumericData::kDouble,1.0, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSystemNode step attribute\n");//(iv)time
//(iii)grammar
LSystemNode::grammar = typedAttr.create( "grammar", "grm", MFnData::kString, &returnStatus );
McheckErr(returnStatus, "ERROR creating LSystemNode grammar attribute\n");
//(iv)time
LSystemNode::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus );
McheckErr(returnStatus, "ERROR creating LSystemNode time attribute\n");
//(v)output
LSystemNode::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus );
McheckErr(returnStatus, "ERROR creating LSystemNode output attribute\n");
typedAttr.setStorable(false);
//(i)angle
returnStatus = addAttribute(LSystemNode::angle);
McheckErr(returnStatus, "ERROR adding angle attribute\n");
//(ii)step
returnStatus = addAttribute(LSystemNode::step);
McheckErr(returnStatus, "ERROR adding step attribute\n");
//(iii)grammar
returnStatus = addAttribute(LSystemNode::grammar);
McheckErr(returnStatus, "ERROR adding grammar attribute\n");
//(iv)time
returnStatus = addAttribute(LSystemNode::time);
McheckErr(returnStatus, "ERROR adding time attribute\n");
//(v)output
returnStatus = addAttribute(LSystemNode::outputMesh);
McheckErr(returnStatus, "ERROR adding outputMesh attribute\n");
returnStatus = attributeAffects(LSystemNode::angle,LSystemNode::outputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
returnStatus = attributeAffects(LSystemNode::step,LSystemNode::outputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
returnStatus = attributeAffects(LSystemNode::grammar,LSystemNode::outputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
returnStatus = attributeAffects(LSystemNode::time,LSystemNode::outputMesh);
McheckErr(returnStatus, "ERROR in attributeAffects\n");
return MS::kSuccess;
}
示例7: MPlug
MPlug TransformationMatrixParameterHandler<T>::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const
{
typename IECore::TypedParameter<IECore::TransformationMatrix<T> >::ConstPtr p = IECore::runTimeCast<const IECore::TypedParameter<IECore::TransformationMatrix<T> > >( parameter );
if( !p )
{
return MPlug();
}
MFnCompoundAttribute fnCAttr;
MObject attribute = fnCAttr.create( plugName, plugName );
MFnNumericAttribute fnNAttr;
MFnUnitAttribute fnUAttr;
// As TransformationMatrix embodies a fairly comprehensive rotation model, were going to be a little
// more basic here, and just supply a V3f rotation and pretend that the Quartonean isn't there.
///\todo Expose rotation order and rotationOrientation.
// These use the '0', '1' and '2' child suffixes instead of 'X' 'Y' and 'Z' to match those created by fnNAttr.create() @ L188.
MObject p1 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", MFnUnitAttribute::kDistance );
MObject p2 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", MFnUnitAttribute::kDistance );
MObject p3 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", MFnUnitAttribute::kDistance );
fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ], plugName + g_attributeNames[ TRANSLATE_INDEX ], p1, p2, p3 ) );
p1 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "0", plugName + g_attributeNames[ ROTATE_INDEX ] + "0", MFnUnitAttribute::kAngle );
p2 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "1", plugName + g_attributeNames[ ROTATE_INDEX ] + "1", MFnUnitAttribute::kAngle );
p3 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "2", plugName + g_attributeNames[ ROTATE_INDEX ] + "2", MFnUnitAttribute::kAngle );
fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ], plugName + g_attributeNames[ ROTATE_INDEX ], p1, p2, p3 ) );
for( unsigned int i=2; i<8; i++ )
{
fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[i], plugName + g_attributeNames[i], NumericTraits<Imath::Vec3<T> >::dataType() ) );
}
MPlug result = finishCreating( parameter, attribute, node );
if( !doUpdate( parameter, result ) )
{
return MPlug(); // failure
}
if( !finishUpdating( parameter, result ) )
{
return MPlug(); // failure
}
return result;
}
示例8: initialize
MStatus footPrint::initialize()
{
MFnUnitAttribute unitFn;
MStatus stat;
size = unitFn.create( "size", "sz", MFnUnitAttribute::kDistance );
unitFn.setDefault( 1.0 );
stat = addAttribute( size );
if (!stat) {
stat.perror("addAttribute");
return stat;
}
return MS::kSuccess;
}
示例9: statCheck
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;
}
示例10: initialize
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;
}
示例11:
MStatus TransformationMatrixParameterHandler<T>::setUnitVecDefaultValues( MPlug vecPlug, Imath::Vec3<T> &defaultValue ) const
{
if( vecPlug.numChildren() != 3 )
{
return MS::kFailure;
}
MFnUnitAttribute fnU;
for( unsigned int i=0; i<3; i++ )
{
fnU.setObject( vecPlug.child(i).attribute() );
if( !fnU.setDefault( defaultValue[i] ) )
{
return MS::kFailure;
}
}
return MS::kSuccess;
}
示例12:
//- 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;
}
示例13: MDistance
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;
}
示例14: initialize
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;
}
示例15: initialize
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;
}