本文整理汇总了C++中MFnEnumAttribute类的典型用法代码示例。如果您正苦于以下问题:C++ MFnEnumAttribute类的具体用法?C++ MFnEnumAttribute怎么用?C++ MFnEnumAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFnEnumAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_enum_attribute
//create_enum_attribute
void Ocio_test::create_enum_attribute(std::string attribute_name,
std::vector<std::string>& value_list,
MObject& node)
{
//eAttr
MFnEnumAttribute eAttr;
//a_attribute
MObject a_attribute = eAttr.create(attribute_name.c_str(), attribute_name.c_str(), 0);
eAttr.setStorable(true);
//iterate and add values
for(int index = 0; index < value_list.size(); index++)
eAttr.addField(value_list[index].c_str(), index);
//dg_modifier
MDGModifier dg_modifier;
dg_modifier.addAttribute(node, a_attribute);
dg_modifier.doIt();
//reload AE
MGlobal::executeCommandOnIdle(MString("openAEWindow;"));
//tmp
MGlobal::displayInfo(MString("Reopened AE"));
};
示例2: MFnCompoundAttrAddEnum
void MFnCompoundAttrAddEnum( MFnCompoundAttribute &attr, const char* full, const char* brief, const char** pEnumStrings, unsigned short count, unsigned short def )
{
MStatus status;
MFnEnumAttribute enumAttr;
MObject enumObj = enumAttr.create( full, brief, def, &status );
for(short index = 0; index < count; ++index)
enumAttr.addField( pEnumStrings[index], index );
attr.addChild( enumObj );
}
示例3: initialize
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 );
}
示例4: initialize
MStatus sgLockAngleMatrix::initialize()
{
MStatus status;
MFnMatrixAttribute mAttr;
MFnNumericAttribute nAttr;
MFnEnumAttribute eAttr;
aBaseMatrix = mAttr.create( "baseMatrix", "baseMatrix" );
CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aBaseMatrix ) );
aInputMatrix = mAttr.create( "inputMatrix", "inputMatrix" );
CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputMatrix ) );
aAngleAxis = eAttr.create( "angleAxis", "angleAxis" );
eAttr.addField( " X", 0 );eAttr.addField( " Y", 1 );eAttr.addField( " Z", 2 );
eAttr.addField( "-X", 3 );eAttr.addField( "-Y", 4 );eAttr.addField( "-Z", 5 );
eAttr.setStorable( true );
CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aAngleAxis ) );
aInputAngle = nAttr.create( "inputAngle", "inputAngle", MFnNumericData::kDouble, 45 );
nAttr.setStorable( true );
CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputAngle ) );
aOutputMatrix = mAttr.create( "outputMatrix", "outputMatrix" );
mAttr.setStorable( false );
CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutputMatrix ) );
CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aBaseMatrix, aOutputMatrix ) );
CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputMatrix, aOutputMatrix ) );
CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aAngleAxis, aOutputMatrix ) );
CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputAngle, aOutputMatrix ) );
return MS::kSuccess;
}
示例5: initialize
MStatus BasicLocator::initialize()
{
//standard attribute creation for the locator node
MStatus status;
MFnNumericAttribute nAttr;
MFnEnumAttribute eAttr;
//output attribute
aIsDrawing = nAttr.create("draw", "d", MFnNumericData::kBoolean, 1);
nAttr.setWritable(true);
nAttr.setStorable(true);
addAttribute(aIsDrawing);
aIsTransparent = nAttr.create("transparent", "tpart", MFnNumericData::kFloat, 0.5);
nAttr.setMin(0.0);
nAttr.setMax(1.0);
nAttr.setWritable(true);
nAttr.setStorable(true);
addAttribute(aIsTransparent);
aShapeColor = nAttr.createColor("color", "col");
nAttr.setDefault(0.1, 0.1, 0.8);
nAttr.setStorable(true);
nAttr.setWritable(true);
addAttribute(aShapeColor);
aShapeType = eAttr.create("shapeType", "styp", 0);
eAttr.setStorable(true);
eAttr.setKeyable(true);
eAttr.addField("arrow", 0);
eAttr.addField("disc", 1);
addAttribute(aShapeType);
return MS::kSuccess;
}
示例6: initialize
MStatus liqCoordSysNode::initialize()
{
MFnEnumAttribute eAttr;
MFnNumericAttribute numAttr;
MStatus status;
aCoordType = eAttr.create( "type", "t", 0, &status );
eAttr.addField( "Card", 0 );
eAttr.addField( "Sphere", 1 );
eAttr.addField( "Cylinder", 2 );
eAttr.addField( "Cube", 3 );
eAttr.addField( "Deep Card", 4 );
eAttr.addField( "Clipping Plane", 5 );
MAKE_INPUT(eAttr);
CHECK_MSTATUS(eAttr.setConnectable(false));
CHECK_MSTATUS( addAttribute( aCoordType ) );
aCoordColor = numAttr.createColor( "coordColor", "cc", &status );
MAKE_INPUT(numAttr);
CHECK_MSTATUS( numAttr.setMin( 0.0, 0.0, 0.0 ) );
CHECK_MSTATUS( numAttr.setMax( 1.0, 1.0, 1.0 ) );
CHECK_MSTATUS( numAttr.setDefault( 0.0, 0.0, 0.5) );
CHECK_MSTATUS( addAttribute( aCoordColor ) );
aCoordOpacity = numAttr.create( "coordOpacity", "co", MFnNumericData::kFloat, 0.0, &status );
MAKE_INPUT(numAttr);
CHECK_MSTATUS( numAttr.setMin( 0.0 ) );
CHECK_MSTATUS( numAttr.setMax( 1.0 ) );
CHECK_MSTATUS( addAttribute( aCoordOpacity ) );
return MS::kSuccess;
}
示例7: Initialize
//-----------------------------------------------------------------------------
// Purpose: Initialize the node, add static attributes, etc...
// Output : MStatus::kSuccess if everything was ok
//-----------------------------------------------------------------------------
MStatus CVstExampleLocator::Initialize()
{
// Add a little enum attribute to control how it's drawn
MFnEnumAttribute eFn;
s_iaDisplayStyle = eFn.create( "displayStyle", "ds", 0 );
eFn.setKeyable ( true );
eFn.addField( "maya", 0 );
eFn.addField( "shaded", 1 );
eFn.addField( "wireframe", 2 );
eFn.addField( "points", 3 );
addAttribute(s_iaDisplayStyle);
return MS::kSuccess;
}
示例8: initialize
MStatus mpBox::initialize()
{
MFnNumericAttribute nAttr;
MFnEnumAttribute enumAttr;
// add the custom attributes for mpBox //
_COMMON_ATTR_INIT_;
aXsize = nAttr.create( "xsize", "xsz", MFnNumericData::kFloat);
nAttr.setDefault(0.5f);
nAttr.setKeyable(1);
nAttr.setReadable(1);
nAttr.setWritable(1);
nAttr.setStorable(1);
aYsize = nAttr.create( "ysize", "ysz", MFnNumericData::kFloat);
nAttr.setDefault(0.5f);
nAttr.setKeyable(1);
nAttr.setReadable(1);
nAttr.setWritable(1);
nAttr.setStorable(1);
aZsize = nAttr.create( "zsize", "zsz", MFnNumericData::kFloat);
nAttr.setDefault(0.5f);
nAttr.setKeyable(1);
nAttr.setReadable(1);
nAttr.setWritable(1);
nAttr.setStorable(1);
aDrawType = enumAttr.create( "drawType" , "dt");
enumAttr.addField("wireframe", 0);
enumAttr.addField("shaded", 1);
enumAttr.addField("normal", 2);
enumAttr.setHidden(false);
enumAttr.setKeyable(true);
enumAttr.setDefault(2);
addAttribute(aXsize);
addAttribute(aYsize);
addAttribute(aZsize);
addAttribute(aDrawType);
return MS::kSuccess;
}
示例9: initialize
//initialize
//-----------------------------------------------
MStatus TesselationVisualization::initialize()
{
//Attr functionsets
MFnEnumAttribute eAttr;
MFnTypedAttribute tAttr;
MFnNumericAttribute nAttr;
//aVerbose
aVerbose = eAttr.create("verbose", "verbose", 0);
eAttr.addField("noVerbose", 0);
eAttr.addField("Verbose", 1);
addAttribute(aVerbose);
//aTesselationType
aTesselationType = eAttr.create("tesselationType", "tesselationType", 0);
eAttr.addField("Structural", 0);
eAttr.addField("Shear", 1);
addAttribute(aTesselationType);
//aInputGeo
aInputGeo = tAttr.create("inputGeo", "inputGeo", MFnData::kMesh);
tAttr.setReadable(false);
addAttribute(aInputGeo);
//aOutputGeo
aOutputGeo = tAttr.create("outputGeo", "outputGeo", MFnData::kMesh);
tAttr.setWritable(false);
tAttr.setStorable(false);
addAttribute(aOutputGeo);
//aCurrentFrame
aCurrentFrame = nAttr.create("currentFrame", "currentFrame", MFnNumericData::kFloat);
addAttribute(aCurrentFrame);
//AttributeAffects
attributeAffects(aTesselationType, aOutputGeo);
attributeAffects(aInputGeo, aOutputGeo);
attributeAffects(aCurrentFrame, aOutputGeo);
return MStatus::kSuccess;
};
示例10: initialize
//
// DESCRIPTION:
MStatus fresnel::initialize()
{
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
MFnGenericAttribute gAttr;
MFnEnumAttribute eAttr;
MFnMessageAttribute mAttr;
MStatus status;
outColor = nAttr.createColor("outColor", "outColor");
MAKE_OUTPUT(nAttr);
CHECK_MSTATUS(addAttribute( outColor ));
//---------------------------- automatically created attributes start ------------------------------------
filename = tAttr.create("filename", "filename", MFnNumericData::kString);
CHECK_MSTATUS(addAttribute( filename ));
name = eAttr.create("name", "name", 0, &status);
status = eAttr.addField( "aluminium", 0 );
status = eAttr.addField( "amorphous carbon", 1 );
status = eAttr.addField( "silver", 2 );
status = eAttr.addField( "gold", 3 );
status = eAttr.addField( "copper", 4 );
MAKE_INPUT(eAttr);
CHECK_MSTATUS(addAttribute( name ));
luxOutFresnel = nAttr.create("luxOutFresnel", "luxOutFresnel", MFnNumericData::kFloat);
MAKE_OUTPUT(nAttr);
CHECK_MSTATUS(addAttribute( luxOutFresnel ));
CHECK_MSTATUS ( attributeAffects( filename, luxOutFresnel));
CHECK_MSTATUS ( attributeAffects( filename, outColor));
//---------------------------- automatically created attributes end ------------------------------------
return MS::kSuccess;
}
示例11: initialize
MStatus LSSolverNode::initialize()
{
MFnNumericAttribute nAttr;
MFnUnitAttribute uAttr;
MFnTypedAttribute tAttr;
MFnEnumAttribute eAttr;
MFnMatrixAttribute mAttr;
tetWorldMatrix = mAttr.create("tet_world_matrix","twm",MFnMatrixAttribute::kDouble,&returnStatus);
McheckErr(returnStatus, "ERROR creating LSTetgenNode worldMatrix attribute\n");
MAKE_INPUT(mAttr);
mAttr.setHidden(true);
restShape = tAttr.create("restShape", "rs", MFnMeshData::kMesh, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n");
MAKE_INPUT(tAttr);
restElements = tAttr.create("restElements", "re", MFnData::kIntArray, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n");
MAKE_INPUT(tAttr);
restVertices = tAttr.create("restVertices", "rv", MFnData::kDoubleArray, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n");
MAKE_INPUT(tAttr);
selectedConstraintVerts = tAttr.create("selectedConstraintVerts", "scv", MFnData::kIntArray, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode selectedConstraintVerts attribute\n");
MAKE_INPUT(tAttr);
selectedForceVerts = tAttr.create("selectedForceVerts", "sfv", MFnData::kIntArray, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode selectedForceVerts attribute\n");
MAKE_INPUT(tAttr);
time = uAttr.create("time", "t", MFnUnitAttribute::kTime,0.0, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode time attribute\n");
MAKE_INPUT(uAttr);
deformed = tAttr.create("deformed", "d", MFnMeshData::kMesh, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode deformed attribute\n");
MAKE_OUTPUT(tAttr);
poissonRatio = nAttr.create("poissonRatio", "pr", MFnNumericData::kDouble, 0.45, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode poisson ratio\n");
MAKE_INPUT(nAttr);
nAttr.setMax(0.45);
nAttr.setMin(0);
youngsModulus = nAttr.create("youngsModulus", "ym", MFnNumericData::kDouble, 90000000000, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode youngsModulus\n");
MAKE_INPUT(nAttr);
//nAttr.setMax(50000);
//nAttr.setMin(1);
objectDensity = nAttr.create("density", "objd", MFnNumericData::kDouble, 1000, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode objectDensity\n");
MAKE_INPUT(nAttr);
nAttr.setMax(10000);
nAttr.setMin(1);
friction = nAttr.create("friction", "f", MFnNumericData::kDouble, 0.98, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode friction\n");
MAKE_INPUT(nAttr);
nAttr.setMax(1);
nAttr.setMin(0);
restitution = nAttr.create("restitution", "r", MFnNumericData::kDouble, 0.4, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode restitution\n");
MAKE_INPUT(nAttr);
nAttr.setMax(1);
nAttr.setMin(0);
damping = nAttr.create("damping", "dmp", MFnNumericData::kDouble, 0.0, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode damping\n");
MAKE_INPUT(nAttr);
nAttr.setMax(1);
nAttr.setMin(0);
userSuppliedDt = nAttr.create("timeStep","ts",MFnNumericData::kDouble,0.01, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode userSuppliedDt\n");
MAKE_INPUT(nAttr);
nAttr.setMax(1);
nAttr.setMin(0.00001);
forceApplicationTime = nAttr.create("forceApplicationTime", "fat", MFnNumericData::kInt, 50, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode forceApplicationTime ratio\n");
MAKE_INPUT(nAttr);
forceReleasedTime = nAttr.create("forceReleasedTime", "frt", MFnNumericData::kInt, 100, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode forceReleasedTime ratio\n");
MAKE_INPUT(nAttr);
forceIncrementTime = nAttr.create("forceIncrementTime", "fit", MFnNumericData::kInt, 10, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode forceIncrementTime ratio\n");
MAKE_INPUT(nAttr);
forceStartTime = nAttr.create("forceStartTime", "fst", MFnNumericData::kInt,100, &returnStatus);
McheckErr(returnStatus, "ERROR creating LSSolverNode forceStartTime\n");
MAKE_INPUT(nAttr);
forceStopTime = nAttr.create("forceStopTime", "fet", MFnNumericData::kInt, 200, &returnStatus);
//.........这里部分代码省略.........
示例12: MCHECKERR
// Create and Add Attributes
//
// Description:
// This 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
//
MStatus
MayaPolySmooth::initialize() {
MStatus stat;
MFnCompoundAttribute cAttr;
MFnEnumAttribute eAttr;
MFnGenericAttribute gAttr;
MFnLightDataAttribute lAttr;
MFnMatrixAttribute mAttr;
MFnMessageAttribute msgAttr;
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
MFnUnitAttribute uAttr;
// MAYA_NODE_BUILDER:BEG [ATTRIBUTE CREATION] ==========
// a_inputPolymesh : This is a description for this attribute
a_inputPolymesh = tAttr.create("inputPolymesh", "ip", MFnData::kMesh, MObject::kNullObj, &stat);
MCHECKERR( stat, "cannot create MayaPolySmooth::inputPolymesh" );
stat = tAttr.setReadable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setReadable()" );
stat = tAttr.setWritable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setWritable()" );
stat = tAttr.setHidden(true);
MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setHidden()" );
stat = addAttribute( a_inputPolymesh );
MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_inputPolymesh)" );
// a_output : This is a description for this attribute
a_output = tAttr.create("output", "out", MFnData::kMesh, MObject::kNullObj, &stat);
MCHECKERR( stat, "cannot create MayaPolySmooth::output" );
stat = tAttr.setReadable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::output.setReadable()" );
stat = tAttr.setWritable(false);
MCHECKERR( stat, "cannot MayaPolySmooth::output.setWritable()" );
stat = tAttr.setHidden(true);
MCHECKERR( stat, "cannot MayaPolySmooth::output.setHidden()" );
stat = addAttribute( a_output );
MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_output)" );
// a_subdivisionLevels : The number of recursive quad subdivisions to perform on each face.
a_subdivisionLevels = nAttr.create("subdivisionLevels", "sl", MFnNumericData::kInt, 0.0, &stat);
MCHECKERR( stat, "cannot create MayaPolySmooth::subdivisionLevels" );
stat = nAttr.setDefault(2);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setDefault(2)" );
stat = nAttr.setMin(0);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMin(0)" );
stat = nAttr.setMax(10);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMax(10)" );
stat = nAttr.setSoftMax(4);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setSoftMax(4)" );
stat = nAttr.setReadable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setReadable()" );
stat = nAttr.setWritable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setWritable()" );
stat = addAttribute( a_subdivisionLevels );
MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_subdivisionLevels)" );
// a_recommendedIsolation : The number of recursive quad subdivisions to perform on each face.
a_recommendedIsolation = nAttr.create("recommendedIsolation", "ri", MFnNumericData::kInt, 0.0, &stat);
MCHECKERR( stat, "cannot create MayaPolySmooth::recommendedIsolation" );
stat = nAttr.setDefault(2);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setDefault(0)" );
stat = nAttr.setMin(0);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setMin(0)" );
stat = nAttr.setMax(10);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setSoftMax(10)" );
stat = nAttr.setReadable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setReadable()" );
stat = nAttr.setWritable(false);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setWritable()" );
stat = nAttr.setHidden(false);
MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setHidden()" );
stat = addAttribute( a_recommendedIsolation );
MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_recommendedIsolation)" );
// a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul>
a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat);
MCHECKERR( stat, "cannot create MayaPolySmooth::vertBoundaryMethod" );
stat = eAttr.addField("Interpolate Edges", k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges, k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
stat = eAttr.addField("Interpolate Edges And Corners", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner);
MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges And Corners, k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" );
stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
stat = eAttr.setReadable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setReadable()" );
stat = eAttr.setWritable(true);
MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setWritable()" );
//.........这里部分代码省略.........
示例13: addAttribute
//----------------------------------------------------------------------------------------------------------------------
// this method creates the attributes for our node and sets some default values etc
//----------------------------------------------------------------------------------------------------------------------
MStatus OceanNode::initialize(){
// Attributes to check whether the amplitude or wind vector have changed
m_wdx = 0.0;
m_wdz = 1.0;
m_ws = 100.0;
m_amp = 100.0;
m_res = 0;
MStatus status;
// an emum attribute for use with the resolution
MFnEnumAttribute enumAttr;
// resolution
m_resolution = enumAttr.create("resolution", "res", 0, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"resolution\" attribute");
enumAttr.addField("128x128", RES128);
enumAttr.addField("256x256", RES256);
enumAttr.addField("512x512", RES512);
enumAttr.addField("1024x1024", RES1024);
enumAttr.setKeyable(true);
status = addAttribute(m_resolution);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"resolution\" attribute to OceanNode");
// now we are going to add several number attributes
MFnNumericAttribute numAttr;
// amplitde
m_amplitude = numAttr.create( "amplitude", "amp", MFnNumericData::kDouble, 100.0, &status );
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to create \"amplitude\" attribute" );
numAttr.setChannelBox( true );
// add attribute
status = addAttribute( m_amplitude );
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to add \"amplitude\" attribute to OceanNode" );
// frequency
m_frequency = numAttr.create("frequency", "frq", MFnNumericData::kDouble, 0.5, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"frequency\" attribute");
numAttr.setChannelBox(true);
status = addAttribute(m_frequency);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"frequency\" attribute to OceanNodee");
// the wind speed inputs
MFnNumericAttribute windDirectionAttr;
m_windDirectionX = windDirectionAttr.create( "windDirectionX", "wdx", MFnNumericData::kDouble, 0.0, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"wdx\" attribute");
windDirectionAttr.setChannelBox(true);
windDirectionAttr.setMin(0.0);
windDirectionAttr.setMax(1.0);
// add attribute
status = addAttribute( m_windDirectionX );
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"wdx\" attribute to OceanNode")
m_windDirectionZ = windDirectionAttr.create( "windDirectionZ", "wdz", MFnNumericData::kDouble, 0.5, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"wdy\" attribute");
windDirectionAttr.setChannelBox(true);
windDirectionAttr.setMin(0.0);
windDirectionAttr.setMax(1.0);
// add attribute
status = addAttribute( m_windDirectionZ );
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"wdz\" attribute to OceanNode");
m_windSpeed = numAttr.create( "windSpeed", "ws", MFnNumericData::kDouble, 100.0, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"ws\" attribute");
numAttr.setChannelBox(true);
// add attribute
status = addAttribute( m_windSpeed );
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"ws\" attribute to OceanNode");
MFnNumericAttribute chopAttr;
m_choppiness = chopAttr.create("chopiness", "chp", MFnNumericData::kDouble, 0.0, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"chopiness\" attribute");
chopAttr.setChannelBox(true);
chopAttr.setMax(2.0);
chopAttr.setMin(0.0);
// add attribute
status = addAttribute(m_choppiness);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"choppiness\" attribute to OceanNode");
// now the time inputs
MFnNumericAttribute timeAttr;
m_time = timeAttr.create("time", "t", MFnNumericData::kDouble, 0.0, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"t\" attribute");
// Add the attribute
status = addAttribute(m_time);
timeAttr.setHidden(true);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"t\" attribute to OceanNode");
// create the output attribute
MFnTypedAttribute typeAttr;
m_output = typeAttr.create("output", "out", MFnData::kMesh, &status);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"output\" attribute");
typeAttr.setStorable(false);
typeAttr.setHidden(true);
status = addAttribute(m_output);
CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"output\" attribute to OceanNode");
//.........这里部分代码省略.........
示例14: initialize
static MStatus initialize()
{
MFnEnumAttribute enumAttrFn;
MFnNumericAttribute numericAttrFn;
MFnGenericAttribute genericAttrFn;
MFnTypedAttribute typeAttrFn;
// enable node
aEnable = numericAttrFn.create( "enbale", "e", MFnNumericData::kBoolean, 0, &status );
numericAttrFn.setDefault(0);
numericAttrFn.setKeyable(true);
addAttribute(aEnable);
aFixPanel = numericAttrFn.create( "fixPanel", "fpn", MFnNumericData::kBoolean, 0, &status);
numericAttrFn.setDefault(1);
numericAttrFn.setConnectable(true);
addAttribute(aFixPanel);
aKeepSel = numericAttrFn.create( "keepSelection", "ks", MFnNumericData::kBoolean, 0, &status);
numericAttrFn.setDefault(0);
addAttribute(aKeepSel);
// component type
aComponentType = enumAttrFn.create( "componetType", "ct", 0, &status );
CHECK_MSTATUS( status );
enumAttrFn.setDefault(0);
enumAttrFn.addField( "vertex", 0 );
enumAttrFn.addField( "edge", 1 );
enumAttrFn.addField( "face", 2 );
enumAttrFn.addField( "uv", 3 );
addAttribute( aComponentType );
// source object
aSourceObj = genericAttrFn.create( "sourceObject", "so", &status );
genericAttrFn.addAccept(MFnData::kMesh);
genericAttrFn.setStorable(false);
addAttribute( aSourceObj );
CHECK_MSTATUS( status );
// volume object
aVolumeObj = genericAttrFn.create( "volumeObject", "vo", &status );
genericAttrFn.addAccept(MFnData::kMesh);
genericAttrFn.setArray(true);
addAttribute( aVolumeObj );
CHECK_MSTATUS( status );
aClosedObj = numericAttrFn.create( "closedVolumeObject", "cvo", MFnNumericData::kBoolean, 1, &status );
numericAttrFn.setDefault(1);
addAttribute( aClosedObj );
// ouput attribute
//
aOutValue = numericAttrFn.create( "outValue", "ov", MFnNumericData::kInt, 0, &status );
CHECK_MSTATUS( status );
numericAttrFn.setReadable(false);
addAttribute( aOutValue );
aOutCompList = typeAttrFn.create( "outComponent", "ocp", MFnComponentListData::kComponentList, &status );
CHECK_MSTATUS( status );
addAttribute(aOutCompList);
aOutMesh = typeAttrFn.create( "outMesh", "om", MFnData::kMesh, &status );
CHECK_MSTATUS( status );
addAttribute(aOutMesh);
// Attribute Affects for aOutValue
attributeAffects( aEnable, aOutValue );
attributeAffects( aFixPanel, aOutValue );
attributeAffects( aComponentType, aOutValue );
attributeAffects( aKeepSel, aOutValue );
attributeAffects( aClosedObj, aOutValue );
attributeAffects( aSourceObj, aOutValue );
attributeAffects( aVolumeObj, aOutValue );
//Attribute Affects for aOutCompList
attributeAffects( aEnable, aOutCompList);
attributeAffects( aFixPanel, aOutCompList );
attributeAffects( aComponentType, aOutCompList );
attributeAffects( aKeepSel, aOutCompList );
attributeAffects( aClosedObj, aOutCompList );
attributeAffects( aSourceObj, aOutCompList );
attributeAffects( aVolumeObj, aOutCompList );
//Attribute Affects for aOutMesh
attributeAffects( aEnable, aOutMesh);
attributeAffects( aFixPanel, aOutMesh );
attributeAffects( aComponentType, aOutMesh );
attributeAffects( aKeepSel, aOutMesh );
attributeAffects( aClosedObj, aOutMesh );
attributeAffects( aSourceObj, aOutMesh );
attributeAffects( aVolumeObj, aOutMesh );
return MS::kSuccess;
}
示例15: addAttribute
MStatus
OpenSubdivPtexShader::initialize()
{
MFnTypedAttribute typedAttr;
MFnNumericAttribute numAttr;
MFnEnumAttribute enumAttr;
// level
aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3);
numAttr.setInternal(true);
numAttr.setMin(1);
numAttr.setSoftMax(5);
numAttr.setMax(10);
// tessFactor
aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2);
numAttr.setInternal(true);
numAttr.setMin(1);
numAttr.setMax(10);
// scheme
aScheme = enumAttr.create("scheme", "sc", OsdPtexMeshData::kCatmark);
enumAttr.addField("Catmull-Clark", OsdPtexMeshData::kCatmark);
enumAttr.addField("Loop", OsdPtexMeshData::kLoop);
enumAttr.addField("Bilinear", OsdPtexMeshData::kBilinear);
enumAttr.setInternal(true);
// kernel
aKernel = enumAttr.create("kernel", "kn", OsdPtexMeshData::kCPU);
enumAttr.addField("CPU", OsdPtexMeshData::kCPU);
#ifdef OPENSUBDIV_HAS_OPENMP
enumAttr.addField("OpenMP", OsdPtexMeshData::kOPENMP);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
enumAttr.addField("CL", OsdPtexMeshData::kCL);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
enumAttr.addField("CUDA", OsdPtexMeshData::kCUDA);
#endif
enumAttr.setInternal(true);
// interpolateBoundary
aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib",
OsdPtexMeshData::kInterpolateBoundaryNone);
enumAttr.addField("None", OsdPtexMeshData::kInterpolateBoundaryNone);
enumAttr.addField("Edge Only", OsdPtexMeshData::kInterpolateBoundaryEdgeOnly);
enumAttr.addField("Edge and Corner", OsdPtexMeshData::kInterpolateBoundaryEdgeAndCorner);
enumAttr.addField("Always Sharp", OsdPtexMeshData::kInterpolateBoundaryAlwaysSharp);
enumAttr.setInternal(true);
// adaptive
aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true);
numAttr.setInternal(true);
// wireframe
aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false);
// material attributes
aDiffuse = numAttr.createColor("diffuse", "d");
numAttr.setDefault(0.6f, 0.6f, 0.7f);
aAmbient = numAttr.createColor("ambient", "a");
numAttr.setDefault(0.1f, 0.1f, 0.1f);
aSpecular = numAttr.createColor("specular", "s");
numAttr.setDefault(0.3f, 0.3f, 0.3f);
// Ptex Texture Attributes
//
// diffuseEnvironmentMapFile;
aDiffuseEnvironmentMapFile = typedAttr.create("diffuseEnvironmentMap", "difenv", MFnData::kString);
typedAttr.setInternal(true);
// don't let maya hold on to string when fileNode is disconnected
typedAttr.setDisconnectBehavior(MFnAttribute::kReset);
// specularEnvironmentMapFile;
aSpecularEnvironmentMapFile = typedAttr.create("specularEnvironmentMap", "specenv", MFnData::kString);
typedAttr.setInternal(true);
// don't let maya hold on to string when fileNode is disconnected
typedAttr.setDisconnectBehavior(MFnAttribute::kReset);
// colorFile;
aColorFile = typedAttr.create("colorFile", "cf", MFnData::kString);
typedAttr.setInternal(true);
// displacementFile;
aDisplacementFile = typedAttr.create("displacementFile", "df", MFnData::kString);
typedAttr.setInternal(true);
// occlusionFile;
aOcclusionFile = typedAttr.create("occlusionFile", "of", MFnData::kString);
typedAttr.setInternal(true);
// enableDisplacement;
aEnableDisplacement = numAttr.create("enableDisplacement", "end", MFnNumericData::kBoolean, 1);
numAttr.setInternal(true);
// enableColor;
aEnableColor = numAttr.create("enableColor", "enc", MFnNumericData::kBoolean, 1);
numAttr.setInternal(true);
// enableOcclusion;
//.........这里部分代码省略.........