Example #1
0
MStatus weightList::initialize()
{
        MStatus status;
	MFnNumericAttribute numAtt; 

	aBias = numAtt.create( "bias", "b", MFnNumericData::kFloat);
	addAttribute(aBias);

	aWeights = numAtt.create("weights", "w", MFnNumericData::kFloat, -1000.0, &status); 
	numAtt.setKeyable(true); 
	numAtt.setArray(true); 
	numAtt.setReadable(true); 
	numAtt.setUsesArrayDataBuilder(true); 
	// setIndexMatters() will only affect array attributes with setReadable set to false, 
	// i.e. destination attributes. We have set the default value to an unlikely value 
	// to guarantee an entry is created regardless of its value. 
	// numAtt.setIndexMatters(true);
	addAttribute(aWeights); 
	
	MFnCompoundAttribute cmpAttr; 
	aWeightsList = cmpAttr.create("weightsList", "wl", &status); 
	cmpAttr.setArray(true); 
	cmpAttr.addChild(aWeights); 
	cmpAttr.setReadable(true); 
	cmpAttr.setUsesArrayDataBuilder(true); 
	// cmpAttr.setIndexMatters(true);
	addAttribute(aWeightsList); 

	attributeAffects(aBias, aWeightsList);
	
	return MStatus::kSuccess;
}
MStatus SurfaceAttach::initialize() {
    MFnTypedAttribute fnTypeAttr;
    MFnNumericAttribute fnNumAttr;
    MFnUnitAttribute fnUnitAttr;
    MFnCompoundAttribute fnCompoundAttr;
    MFnEnumAttribute fnEnumAttr;
    MFnMatrixAttribute fnMatAttr;

    MStatus stat;

    // Input Attributes
    direction = fnEnumAttr.create("direction", "dire", 0);
    fnEnumAttr.addField("U", 0);
    fnEnumAttr.addField("V", 1);

    surface = fnTypeAttr.create("surface", "surface", MFnData::kNurbsSurface);

    parentInverse = fnMatAttr.create("parentInverse", "ps", MFnMatrixAttribute::kDouble);
    fnMatAttr.setKeyable(true);

    samples = fnNumAttr.create("samples", "samples", MFnNumericData::kInt, 1000);
    fnNumAttr.setKeyable(true);
    fnNumAttr.setMin(1.0);

    staticLength = fnNumAttr.create("staticLength", "staticLength", MFnNumericData::kDouble, 0.0001);
    fnNumAttr.setKeyable(true);
    fnNumAttr.setMin(0.0001);

    offset = fnNumAttr.create("offset", "offset", MFnNumericData::kDouble, 0.0);
    fnNumAttr.setKeyable(true);

    genus = fnEnumAttr.create("type", "type", 0);
    fnEnumAttr.addField("Parametric", 0);

    fnEnumAttr.addField("Percentage", 1);
    fnEnumAttr.addField("FixedLength", 2);
    fnEnumAttr.setKeyable(true);

    reverse = fnNumAttr.create("reverse", "reverse", MFnNumericData::kBoolean, false);
    fnNumAttr.setKeyable(true);

    inU = fnNumAttr.create("inU", "U", MFnNumericData::kDouble, 0.5);
    fnNumAttr.setKeyable(true);

    inV = fnNumAttr.create("inV", "V", MFnNumericData::kDouble, 0.5);
    fnNumAttr.setKeyable(true);

    inUV = fnCompoundAttr.create("inUV", "inUV");
    fnCompoundAttr.setKeyable(true);
    fnCompoundAttr.setArray(true);
    fnCompoundAttr.addChild(inU);
    fnCompoundAttr.addChild(inV);
    fnCompoundAttr.setUsesArrayDataBuilder(true);

    // Output Attributes
    translateX = fnNumAttr.create("translateX", "translateX", MFnNumericData::kDouble);
    fnNumAttr.setWritable(false);
    fnNumAttr.setStorable(false);

    translateY = fnNumAttr.create("translateY", "translateY", MFnNumericData::kDouble);
    fnNumAttr.setWritable(false);
    fnNumAttr.setStorable(false);

    translateZ = fnNumAttr.create("translateZ", "translateZ", MFnNumericData::kDouble);
    fnNumAttr.setWritable(false);
    fnNumAttr.setStorable(false);

    translate = fnNumAttr.create("translate", "translate", translateX, translateY, translateZ);
    fnNumAttr.setWritable(false);
    fnNumAttr.setStorable(false);

    rotateX = fnUnitAttr.create("rotateX", "rotateX", MFnUnitAttribute::kAngle);
    fnUnitAttr.setWritable(false);
    fnUnitAttr.setStorable(false);

    rotateY = fnUnitAttr.create("rotateY", "rotateY", MFnUnitAttribute::kAngle);
    fnUnitAttr.setWritable(false);
    fnUnitAttr.setStorable(false);

    rotateZ = fnUnitAttr.create("rotateZ", "rotateZ", MFnUnitAttribute::kAngle);
    fnUnitAttr.setWritable(false);
    fnUnitAttr.setStorable(false);

    rotate = fnNumAttr.create("rotate", "rotate", rotateX, rotateY, rotateZ);
    fnNumAttr.setWritable(false);

    out = fnCompoundAttr.create("out", "out");
    fnCompoundAttr.setWritable(false);
    fnCompoundAttr.setArray(true);
    fnCompoundAttr.addChild(translate);
    fnCompoundAttr.addChild(rotate);
    fnCompoundAttr.setUsesArrayDataBuilder(true);

    // These aren't going to fail, give me a break :)
    // Add Attributes
    SurfaceAttach::addAttribute(direction);
    SurfaceAttach::addAttribute(surface);
    SurfaceAttach::addAttribute(parentInverse);
    SurfaceAttach::addAttribute(samples);
    SurfaceAttach::addAttribute(staticLength);
    SurfaceAttach::addAttribute(offset);
    SurfaceAttach::addAttribute(genus);
    SurfaceAttach::addAttribute(reverse);
    SurfaceAttach::addAttribute(inUV);
    SurfaceAttach::addAttribute(out);

    // Attribute Affects
    SurfaceAttach::attributeAffects(direction, translate);
    SurfaceAttach::attributeAffects(surface, translate);
    SurfaceAttach::attributeAffects(parentInverse, translate);
    SurfaceAttach::attributeAffects(staticLength, translate);
    SurfaceAttach::attributeAffects(samples, translate);
    SurfaceAttach::attributeAffects(offset, translate);
    SurfaceAttach::attributeAffects(genus, translate);
    SurfaceAttach::attributeAffects(reverse, translate);
    SurfaceAttach::attributeAffects(inU, translate);
    SurfaceAttach::attributeAffects(inV, translate);

    SurfaceAttach::attributeAffects(direction, rotate);
    SurfaceAttach::attributeAffects(surface, rotate);
    SurfaceAttach::attributeAffects(parentInverse, rotate);
    SurfaceAttach::attributeAffects(staticLength, rotate);
    SurfaceAttach::attributeAffects(samples, rotate);
    SurfaceAttach::attributeAffects(offset, rotate);
    SurfaceAttach::attributeAffects(genus, rotate);
    SurfaceAttach::attributeAffects(reverse, rotate);
    SurfaceAttach::attributeAffects(inU, rotate);
    SurfaceAttach::attributeAffects(inV, rotate);

    return MS::kSuccess;
}
Example #3
0
MStatus sgHair_controlJoint::initialize()
{
	MStatus status;

	MFnTypedAttribute tAttr;
	MFnMatrixAttribute mAttr;
	MFnMessageAttribute msgAttr;
	MFnNumericAttribute nAttr;
	MFnUnitAttribute uAttr;
	MFnCompoundAttribute cAttr;

	aInputBaseCurve = tAttr.create( "inputBaseCurve", "inputBaseCurve", MFnData::kNurbsCurve );
	tAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputBaseCurve ) );

	aInputBaseCurveMatrix = mAttr.create( "inputBaseCurveMatrix", "inputBaseCurveMatrix" );
	mAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputBaseCurveMatrix ) );

	aJointParentBaseMatrix = mAttr.create( "jointParentBaseMatrix", "jointParentBaseMatrix" );
	mAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aJointParentBaseMatrix ) );

	aGravityParam  = nAttr.create( "gravityParam", "gravityParam", MFnNumericData::kDouble, 0.0 );
	nAttr.setMin( 0.0 );
	nAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityParam ) );
	aGravityRange  = nAttr.create( "gravityRange", "gravityRange", MFnNumericData::kDouble, 0.0 );
	nAttr.setMin( 0.0 );
	nAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityRange ) );
	aGravityWeight  = nAttr.create( "gravityWeight", "gravityWeight", MFnNumericData::kDouble, 0.0 );
	nAttr.setMin( 0.0 );
	nAttr.setMax( 1.0 );
	nAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityWeight ) );
	aGravityOffsetMatrix = mAttr.create( "gravityOffsetMatrix", "gravityOffsetMatrix" );
	mAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityOffsetMatrix ) );

	aStaticRotation = nAttr.create( "staticRotation", "staticRotation", MFnNumericData::kBoolean, false );
	nAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aStaticRotation ) );

	aOutput  = cAttr.create( "output", "output" );

	aOutTransX = nAttr.create( "outTransX", "otx", MFnNumericData::kDouble );
	aOutTransY = nAttr.create( "outTransY", "oty", MFnNumericData::kDouble );
	aOutTransZ = nAttr.create( "outTransZ", "otz", MFnNumericData::kDouble );
	aOutTrans  = nAttr.create( "outTrans", "ot", aOutTransX, aOutTransY, aOutTransZ );

	aOutOrientX = uAttr.create( "outRotateX", "orx", MFnUnitAttribute::kAngle, 0.0 );
	aOutOrientY = uAttr.create( "outRotateY", "ory", MFnUnitAttribute::kAngle, 0.0 );
	aOutOrientZ = uAttr.create( "outRotateZ", "orz", MFnUnitAttribute::kAngle, 0.0 );
	aOutOrient  = nAttr.create( "outRotate", "outRotate", aOutOrientX, aOutOrientY, aOutOrientZ );

	cAttr.addChild( aOutTrans );
	cAttr.addChild( aOutOrient );
	cAttr.setStorable( false );
	cAttr.setArray( true );
	cAttr.setUsesArrayDataBuilder( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutput ) );

	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityParam,  aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityRange,  aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityWeight, aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aJointParentBaseMatrix, aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityOffsetMatrix, aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputBaseCurve, aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputBaseCurveMatrix, aOutput ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aStaticRotation, aOutput ) );

	return MS::kSuccess;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVstWeldNode::Initialize()
{
	MFnCompoundAttribute cFn;
	MFnEnumAttribute eFn;
	MFnGenericAttribute gFn;
	MFnMatrixAttribute mFn;
	MFnNumericAttribute nFn;
	MFnTypedAttribute tFn;
	MFnUnitAttribute uFn;

	m_iaWorldGeometry = gFn.create( "worldGeometry", "wgeo" );
	gFn.setHidden( true );
	gFn.setStorable( false );
	gFn.addAccept( MFnData::kMesh );
	gFn.addAccept( MFnData::kNurbsCurve );
	gFn.addAccept( MFnData::kNurbsSurface );

	m_iaType = eFn.create( "type", "typ", kMeshFace );
	eFn.addField( "meshFace", kMeshFace );

	m_iaInt = nFn.create( "int", "i", MFnNumericData::kInt );

	m_iaFloat0 = nFn.create( "float0", "f0", MFnNumericData::kDouble );

	m_iaFloat1 = nFn.create( "float1", "f1", MFnNumericData::kDouble );

    m_iaOffsetMatrix = mFn.create( "offsetMatrix", "omat" );

    m_iaInverseParentSpace = mFn.create( "inverseParentSpace", "ips" );

	m_iaRotateOrder = eFn.create( "rotateOrder", "ro", 0 );
	eFn.addField( "xyz", 0 );
	eFn.addField( "yzx", 1 );
	eFn.addField( "zxy", 2 );
	eFn.addField( "xzy", 3 );
	eFn.addField( "yxz", 4 );
	eFn.addField( "zyx", 5 );

	m_iaWeldInput = cFn.create( "weldInput", "wi" );
	cFn.setArray( true );
	cFn.addChild( m_iaType );
	cFn.addChild( m_iaInt );
	cFn.addChild( m_iaFloat0 );
	cFn.addChild( m_iaFloat1 );
	cFn.addChild( m_iaOffsetMatrix );
	cFn.addChild( m_iaInverseParentSpace );
	cFn.addChild( m_iaRotateOrder );

	m_oaTranslateX = uFn.create( "translateX", "tx", MFnUnitAttribute::kDistance );
	m_oaTranslateY = uFn.create( "translateY", "ty", MFnUnitAttribute::kDistance );
	m_oaTranslateZ = uFn.create( "translateZ", "tz", MFnUnitAttribute::kDistance );
	m_oaTranslate = nFn.create( "translate", "t", m_oaTranslateX, m_oaTranslateY, m_oaTranslateZ );

	m_oaRotateX = uFn.create( "rotateX", "rx", MFnUnitAttribute::kAngle );
	m_oaRotateY = uFn.create( "rotateY", "ry", MFnUnitAttribute::kAngle );
	m_oaRotateZ = uFn.create( "rotateZ", "rz", MFnUnitAttribute::kAngle );
	m_oaRotate = nFn.create( "rotate", "r", m_oaRotateX, m_oaRotateY, m_oaRotateZ );

	m_oaWeldOutput = cFn.create( "weldOutput", "wo" );
	cFn.setArray( true );
	cFn.addChild( m_oaTranslate );
	cFn.addChild( m_oaRotate );
	cFn.setUsesArrayDataBuilder( true );

	addAttribute( m_iaWorldGeometry );
	addAttribute( m_iaWeldInput );
	addAttribute( m_oaWeldOutput );

	attributeAffects( m_iaWorldGeometry, m_oaWeldOutput );
	attributeAffects( m_iaWeldInput, m_oaWeldOutput );

	return MS::kSuccess;
}