本文整理汇总了C++中MFnTypedAttribute::setDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnTypedAttribute::setDefault方法的具体用法?C++ MFnTypedAttribute::setDefault怎么用?C++ MFnTypedAttribute::setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnTypedAttribute
的用法示例。
在下文中一共展示了MFnTypedAttribute::setDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
MStatus DynamicEnum::initialize()
{
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
MFnStringData sData;
MStatus status; // Status will be used to hold the MStatus value
// returned by each api function call. It is important
// to check the status returned by a call to aid in
// debugging. Failed API calls can result in subtle
// errors that can be difficult to track down, you may
// wish to use the CHECK_MSTATUS macro for any API
// call where you do not need to provide your own
// error handling.
//
// Attribute Initialization:
aFilePath = tAttr.create( "filepath", "file", MFnData::kString, &status );
CHECK_MSTATUS( status );
CHECK_MSTATUS( tAttr.setKeyable( true ) );
CHECK_MSTATUS( tAttr.setStorable( true ) );
CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) );
aGridName = tAttr.create( "grid", "grd", MFnData::kString, &status );
CHECK_MSTATUS( status );
CHECK_MSTATUS( tAttr.setKeyable( true ) );
CHECK_MSTATUS( tAttr.setStorable( true ) );
CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) );
aOutColor = nAttr.createColor( "outColor", "oc", &status );
CHECK_MSTATUS( status );
CHECK_MSTATUS( nAttr.setHidden( false ) );
CHECK_MSTATUS( nAttr.setReadable( true ) );
CHECK_MSTATUS( nAttr.setWritable( false ) );
// Next we will add the attributes we have defined to the node
//
CHECK_MSTATUS( addAttribute( aFilePath ) );
CHECK_MSTATUS( addAttribute( aGridName ) );
CHECK_MSTATUS( addAttribute( aOutColor ) );
// The attributeAffects() method is used to indicate when the input
// attribute affects the output attribute. This knowledge allows Maya
// to optimize dependencies in the graph in more complex nodes where
// there may be several inputs and outputs, but not all the inputs
// affect all the outputs.
//
CHECK_MSTATUS( attributeAffects( aFilePath, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aGridName, aOutColor ) );
return( MS::kSuccess );
}
示例2: initialize
//-----------------------------------------------------------------------
MStatus visualizeMeshNode::initialize()
//-----------------------------------------------------------------------
{
MStatus stat;
MFnNumericAttribute numericAttr;
MFnTypedAttribute typedAttr;
//!!!####################################################
//COLOR
//!!!####################################################
vtxColorObj = numericAttr.createColor("aColor","col");
numericAttr.setKeyable(true);
numericAttr.setStorable(true);
numericAttr.setDefault(1.0,0.0,0.1);
//!!!####################################################
//COLOR2
//!!!####################################################
vtxColorObj2 = numericAttr.createColor("aColor2","col2");
numericAttr.setKeyable(true);
numericAttr.setStorable(true);
numericAttr.setDefault(1.0,0.785,0.0);
//!!!####################################################
//DRAWING ENABLED
//!!!####################################################
drawingEnabled = numericAttr.create( "drawingEnabled", "en",
MFnNumericData::kBoolean, 1, &stat );
numericAttr.setKeyable(true);
numericAttr.setStorable(true);
if (!stat) {
stat.perror("create drawingEnabled attribute");
return stat;
}
/* // Dieses Feature ist eigentlich ziemlich unnötig
//!!!####################################################
//SHOW ORIGINAL MESH
//!!!####################################################
showOriginalObj = numericAttr.create( "showOriginal", "so",
MFnNumericData::kBoolean, 1, &stat );
numericAttr.setKeyable(true);
numericAttr.setStorable(true);
if (!stat) {
stat.perror("create showOriginal attribute");
return stat;
}
*/
//!!!####################################################
//POINTSIZE
//!!!####################################################
pointSize = numericAttr.create( "pointSize", "ps",
MFnNumericData::kFloat, 10.0, &stat );
numericAttr.setKeyable(true);
numericAttr.setStorable(true);
if (!stat) {
stat.perror("create pointSize attribute");
return stat;
}
//!!!####################################################
//INPUT MESH
//!!!####################################################
inputMesh = typedAttr.create( "inputMesh", "is",
MFnMeshData::kMesh, &stat);
if (!stat) {
stat.perror("create inputMesh attribute");
return stat;
}
//!!!####################################################
//VTXLOCATIONS (DUMMY OUT)
//!!!####################################################
vtxLocations = numericAttr.create( "vtxLocations", "cv",
MFnNumericData::kBoolean,1, &stat);
if (!stat) {
stat.perror("create vtxLocations attribute");
return stat;
}
//!!!####################################################
//.........这里部分代码省略.........
示例3: initialize
MStatus cvColor::initialize()
{
MStatus stat;
MFnNumericAttribute numericAttr;
MFnTypedAttribute typedAttr;
drawingEnabled = numericAttr.create( "drawingEnabled", "en",
MFnNumericData::kBoolean, 1, &stat );
if (!stat) {
stat.perror("create drawingEnabled attribute");
return stat;
}
pointSize = numericAttr.create( "pointSize", "ps",
MFnNumericData::kFloat, 4.0, &stat );
if (!stat) {
stat.perror("create pointSize attribute");
return stat;
}
inputSurface = typedAttr.create( "inputSurface", "is",
MFnNurbsSurfaceData::kNurbsSurface, &stat);
if (!stat) {
stat.perror("create inputSurface attribute");
return stat;
}
cvLocations = typedAttr.create( "cvLocations", "cv",
MFnPointArrayData::kPointArray, &stat);
if (!stat) {
stat.perror("create cvLocations attribute");
return stat;
}
MPointArray defaultPoints;
MFnPointArrayData defaultArray;
MObject defaultAttr;
defaultPoints.clear(); // Empty array
defaultAttr = defaultArray.create (defaultPoints);
stat = typedAttr.setDefault(defaultAttr);
if (!stat) {
stat.perror("could not create default output attribute");
return stat;
}
stat = addAttribute (drawingEnabled);
if (!stat) { stat.perror("addAttribute"); return stat;}
stat = addAttribute (pointSize);
if (!stat) { stat.perror("addAttribute"); return stat;}
stat = addAttribute (inputSurface);
if (!stat) { stat.perror("addAttribute"); return stat;}
stat = addAttribute (cvLocations);
if (!stat) { stat.perror("addAttribute"); return stat;}
stat = attributeAffects( inputSurface, cvLocations );
if (!stat) { stat.perror("attributeAffects"); return stat;}
stat = attributeAffects( drawingEnabled, cvLocations );
if (!stat) { stat.perror("attributeAffects"); return stat;}
stat = attributeAffects( pointSize, cvLocations );
if (!stat) { stat.perror("attributeAffects"); return stat;}
return MS::kSuccess;
}