Exemple #1
0
MStatus ModifyArrayNode::initialize()
{
    MStatus status;

    MFnTypedAttribute T;
    MFnNumericAttribute N;
    MFnEnumAttribute E;

    aInput = T.create("input", "i", MFnData::kDoubleArray);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setStorable(true);
    T.setWritable(true);

    aOperation = E.create("operation", "operation");
    E.addField("No Operation", kNO_OP);
    E.addField("Sort", kSORT);
    E.addField("Absolute Value", kABS);
    E.addField("Reflect Left", kREFLECT_LEFT);
    E.addField("Reflect Right", kREFLECT_RIGHT);
    E.setDefault(kNO_OP);
    E.setKeyable(true);
    E.setStorable(true);
    E.setWritable(true);

    aReverse = N.create("reverse", "rev", MFnNumericData::kBoolean);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);

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

    addAttribute(aOperation);
    addAttribute(aInput);
    addAttribute(aReverse);
    addAttribute(aOutput);

    attributeAffects(aOperation, aOutput);
    attributeAffects(aInput, aOutput);
    attributeAffects(aReverse, aOutput);

    return MS::kSuccess;
}
Exemple #2
0
//
//  Initialize the node
//
MStatus jhMeshBlur::initialize()
{
    // attribute types
    MFnUnitAttribute    unitAttr;
    MFnNumericAttribute	nAttr;
    MFnTypedAttribute   tAttr;

    aOldMeshData = tAttr.create("oldMesh","om",MFnData::kPointArray);
    tAttr.setArray(true);
    tAttr.setHidden(true);
    tAttr.setIndexMatters(true);

    // create the attributes
    aStrength = nAttr.create( "Strength", "str", MFnNumericData::kFloat,1.0);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTreshhold = nAttr.create( "Treshold", "tres", MFnNumericData::kFloat,0.0);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMin(0.0);

    aShapeFactor = nAttr.create( "ShapeFactor", "shapef", MFnNumericData::kFloat,0.5);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTweakBlur = nAttr.create( "TweakBlur", "tweak", MFnNumericData::kBoolean,false);
    nAttr.setKeyable(false);
    nAttr.setChannelBox(true);

    aQuadInterp = nAttr.create( "QuadInterpolation", "qi", MFnNumericData::kBoolean,true);
    nAttr.setKeyable(false);
    nAttr.setChannelBox(true);

    aInterpPower = nAttr.create( "InterpolationPower", "interp", MFnNumericData::kDouble, 0.75);
    nAttr.setKeyable(true);
    nAttr.setMax(1.0);
    nAttr.setMin(0.0);

    aTime = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 1.0 );
    unitAttr.setStorable(true);
    unitAttr.setCached(true);
	unitAttr.setReadable(true);
	unitAttr.setWritable(true);
	unitAttr.setAffectsAppearance(true);
	unitAttr.setAffectsWorldSpace(true);

    // Make the attributes visible to the user
    addAttribute( aStrength);
    addAttribute( aTreshhold);
    addAttribute( aTime);
    addAttribute( aTweakBlur);
    addAttribute( aQuadInterp);
    addAttribute( aInterpPower);
    addAttribute( aOldMeshData);

    // Make sure when an attribute changes, the node updates
    attributeAffects( aTime, outputGeom );
	attributeAffects( aStrength, outputGeom );
    attributeAffects( aTreshhold, outputGeom );
    attributeAffects( aQuadInterp, outputGeom );
    attributeAffects( aInterpPower, outputGeom );

    // Not implented yet, but make the weights paintable :)
    MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer jhMeshBlur weights;");

    return MStatus::kSuccess;
}
Exemple #3
0
MStatus retargetLocator::initialize()
{
    MFnNumericAttribute nAttr;
	MFnMatrixAttribute mAttr;
	MFnEnumAttribute eAttr;
	MFnUnitAttribute uAttr;
	MFnCompoundAttribute cAttr;
	MFnTypedAttribute tAttr;
	
	aOutput = nAttr.create( "output", "output", MFnNumericData::kDouble );
	nAttr.setStorable( false );
	CHECK_MSTATUS( addAttribute( aOutput ) );

	aDiscMatrix = mAttr.create( "discMatrix", "discMatrix" );
	mAttr.setStorable( true );
	CHECK_MSTATUS( addAttribute( aDiscMatrix ) );
	CHECK_MSTATUS( attributeAffects( aDiscMatrix, aOutput ) );

	aDiscAxis = eAttr.create( "discAxis", "discAxis", 0 );
	eAttr.addField( "X", 0 );
	eAttr.addField( "Y", 1 );
	eAttr.addField( "Z", 2 );
	eAttr.setStorable( true );
	eAttr.setChannelBox( true );
	eAttr.setReadable( true );
	CHECK_MSTATUS( addAttribute( aDiscAxis ) );
	CHECK_MSTATUS( attributeAffects( aDiscAxis, aOutput ) );


	aDiscDivision = nAttr.create( "discDivision", "discDivision", MFnNumericData::kInt, 32 );
	nAttr.setMin( 1 );
	nAttr.setMax( 32 );
	nAttr.setStorable( true );
	nAttr.setChannelBox( true );
	CHECK_MSTATUS( addAttribute( aDiscDivision ) );
	CHECK_MSTATUS( attributeAffects( aDiscDivision, aOutput ) );


	aDiscAngle = uAttr.create( "discAngle", "discAngle", MFnUnitAttribute::kAngle, 0.0 );
	uAttr.setStorable( true );
	uAttr.setChannelBox( true );
	CHECK_MSTATUS( addAttribute( aDiscAngle ) );
	CHECK_MSTATUS( attributeAffects( aDiscAngle, aOutput ) );


	aDiscOffsetX = nAttr.create( "discOffsetX", "discOffsetX", MFnNumericData::kDouble, 0.0 );
	aDiscOffsetY = nAttr.create( "discOffsetY", "discOffsetY", MFnNumericData::kDouble, 0.0 );
	aDiscOffsetZ = nAttr.create( "discOffsetZ", "discOffsetZ", MFnNumericData::kDouble, 0.0 );
	aDiscOffset  = nAttr.create( "discOffset", "discOffset", aDiscOffsetX, aDiscOffsetY, aDiscOffsetZ );
	uAttr.setStorable( true );
	uAttr.setChannelBox( true );
	CHECK_MSTATUS( addAttribute( aDiscOffset ) );
	CHECK_MSTATUS( attributeAffects( aDiscOffset, aOutput ) );

	aDiscSizeX = nAttr.create( "discSizeX", "discSizeX", MFnNumericData::kDouble, 1.0 );
	aDiscSizeY = nAttr.create( "discSizeY", "discSizeY", MFnNumericData::kDouble, 1.0 );
	aDiscSizeZ = nAttr.create( "discSizeZ", "discSizeZ", MFnNumericData::kDouble, 1.0 );
	aDiscSize  = nAttr.create( "discSize", "discSize", aDiscSizeX, aDiscSizeY, aDiscSizeZ );
	uAttr.setStorable( true );
	uAttr.setChannelBox( true );
	CHECK_MSTATUS( addAttribute( aDiscSize ) );
	CHECK_MSTATUS( attributeAffects( aDiscSize, aOutput ) );


	aDiscActiveColor = nAttr.createColor( "discActiveColor", "discActiveColor" );
	nAttr.setStorable( true );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(1.0f, 1.0f, 1.0f);
	CHECK_MSTATUS( addAttribute( aDiscActiveColor ) );
	CHECK_MSTATUS( attributeAffects( aDiscActiveColor, aOutput ) );


	aDiscLeadColor = nAttr.createColor( "discLeadColor", "discLeadColor" );
	nAttr.setStorable( true );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(.263f, 1.0f, .639f);
	CHECK_MSTATUS( addAttribute( aDiscLeadColor ) );
	CHECK_MSTATUS( attributeAffects( aDiscLeadColor, aOutput ) );


	aDiscDefaultColor = nAttr.createColor( "discDefaultColor", "discDefaultColor" );
	nAttr.setStorable( true );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(.0f, .016f, .376f);
	CHECK_MSTATUS( addAttribute( aDiscDefaultColor ) );
	CHECK_MSTATUS( attributeAffects( aDiscDefaultColor, aOutput ) );

	aDiscFillAlpha = nAttr.create( "discFillAlpha", "discFillAlpha", MFnNumericData::kFloat, 0.1f );
	nAttr.setStorable( true );
	nAttr.setMin( 0.0f );
	nAttr.setMax( 1.0f );
	CHECK_MSTATUS( addAttribute( aDiscFillAlpha ) );
	CHECK_MSTATUS( attributeAffects( aDiscFillAlpha, aOutput ) );

	aDiscLineAlpha = nAttr.create( "discLineAlpha", "discLineAlpha", MFnNumericData::kFloat, 1.0f );
	nAttr.setStorable( true );
	nAttr.setMin( 0.0f );
	nAttr.setMax( 1.0f );
	CHECK_MSTATUS( addAttribute( aDiscLineAlpha ) );
	CHECK_MSTATUS( attributeAffects( aDiscLineAlpha, aOutput ) );

	aArrow = cAttr.create( "arrow", "arrow" );

	aInheritMatrix = nAttr.create( "inheritMatrix", "inheritMatrix", MFnNumericData::kBoolean, false );

	aInputMesh = tAttr.create( "inputMesh", "inputMesh", MFnData::kMesh );

	aAimMatrix = mAttr.create( "aimMatrix", "aimMatrix" );

	aStartSize = nAttr.create( "startSize", "startSize", MFnNumericData::kFloat, 0.5f );

	aSize = nAttr.create( "size", "size", MFnNumericData::kFloat, 1.0f );

	aActiveColor = nAttr.createColor( "activeColor", "activeColor" );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(1.0f, 1.0f, 1.0f);
	aLeadColor = nAttr.createColor( "leadColor", "leadColor" );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(.263f, 1.0f, .639f);
	aDefaultColor = nAttr.createColor( "defaultColor", "defaultColor" );
	nAttr.setUsedAsColor(true);
	nAttr.setDefault(.0f, .016f, .376f);

	aFillAlpha = nAttr.create( "fillAlpha", "fillAlpha", MFnNumericData::kFloat, 0.1f );
	aLineAlpha = nAttr.create( "lineAlpha", "lineAlpha", MFnNumericData::kFloat, 1.0f );

	aOffsetX = nAttr.create( "offsetX", "offsetX", MFnNumericData::kDouble, 0.0 );
	aOffsetY = nAttr.create( "offsetY", "offsetY", MFnNumericData::kDouble, 0.0 );
	aOffsetZ = nAttr.create( "offsetZ", "offsetZ", MFnNumericData::kDouble, 0.0 );
	aOffset = nAttr.create( "offset", "offset", aOffsetX, aOffsetY, aOffsetZ );

	cAttr.addChild( aInheritMatrix );
	cAttr.addChild( aAimMatrix );
	cAttr.addChild( aInputMesh );
	cAttr.addChild( aStartSize );
	cAttr.addChild( aSize );
	cAttr.addChild( aActiveColor );
	cAttr.addChild( aLeadColor );
	cAttr.addChild( aDefaultColor );
	cAttr.addChild( aFillAlpha );
	cAttr.addChild( aLineAlpha );
	cAttr.addChild( aOffset );
	cAttr.setArray( true );
	cAttr.setStorable( true );
	CHECK_MSTATUS( addAttribute( aArrow ) );
	CHECK_MSTATUS( attributeAffects( aArrow, aOutput ) );

	return MS::kSuccess;
}
//----------------------------------------------------------------------------------------------------------------------
// 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");

    // this links the different elements together forcing a re-compute each time the values are changed
    attributeAffects(m_resolution, m_output);
    attributeAffects(m_amplitude,m_output);
    attributeAffects(m_windDirectionX, m_output);
    attributeAffects(m_windDirectionZ, m_output);
    attributeAffects(m_windSpeed, m_output);
    attributeAffects(m_choppiness, m_output);
    attributeAffects(m_time, m_output);

    // report all was good
    return MStatus::kSuccess;
}
// Attributes initialisation
MStatus DA_GridGenerator::initialize()
{
    MStatus stat;
    MFnCompoundAttribute cAttr;
    MFnNumericAttribute nAttr;
    MFnEnumAttribute eAttr;
    MFnTypedAttribute tAttr;

    //
    // Controls
    //
    aWidth = nAttr.create("width", "w", MFnNumericData::kDouble, 1.0);
    nAttr.setMin(0.001);
    nAttr.setChannelBox(true);
    nAttr.setKeyable(true);
    stat = addAttribute(aWidth);
    CHECK_MSTATUS(stat);

    aHeight = nAttr.create("height", "h", MFnNumericData::kDouble, 1.0);
    nAttr.setMin(0.001);
    nAttr.setChannelBox(true);
    nAttr.setKeyable(true);
    stat = addAttribute(aHeight);
    CHECK_MSTATUS(stat);

    aResolutionX = nAttr.create("resolutionX", "resx", MFnNumericData::kInt, 10);
    nAttr.setMin(2);
    nAttr.setChannelBox(true);
    nAttr.setKeyable(true);
    aResolutionY = nAttr.create("resolutionY", "resy", MFnNumericData::kInt, 10);
    nAttr.setMin(2);
    nAttr.setChannelBox(true);
    nAttr.setKeyable(true);
    aResolution = cAttr.create("resolution", "res");

    stat = cAttr.addChild(aResolutionX);
    CHECK_MSTATUS(stat);
    stat = cAttr.addChild(aResolutionY);
    CHECK_MSTATUS(stat);
    stat = addAttribute(aResolution);
    CHECK_MSTATUS(stat);


    aPattern = eAttr.create("pattern","pat",0);
    eAttr.addField(DA_GridGeneratorPatterns::NONE, 0);
    eAttr.addField(DA_GridGeneratorPatterns::BRICK_U, 1);
    eAttr.addField(DA_GridGeneratorPatterns::BRICK_V, 2);
    eAttr.setChannelBox(true);
    eAttr.setKeyable(true);

    stat = addAttribute(aPattern);
    CHECK_MSTATUS(stat);

    //
    // Outputs
    //

    aOutDynamicArray = tAttr.create("outDynamicArray", "oda", MFnData::kDynArrayAttrs);
    tAttr.setWritable(false); // Just output
    stat = addAttribute(aOutDynamicArray);
    CHECK_MSTATUS(stat);

    //
    // Attributes affects
    //

    attributeAffects(aWidth, aOutDynamicArray);
    attributeAffects(aHeight, aOutDynamicArray);

    attributeAffects(aResolutionX, aOutDynamicArray);
    attributeAffects(aResolutionY, aOutDynamicArray);

    attributeAffects(aPattern, aOutDynamicArray);

    // Done
    return stat;
}
Exemple #6
0
MStatus RemapArrayValuesNode::initialize()
{
    MStatus status;

    MFnCompoundAttribute C;
    MFnTypedAttribute T;
    MFnNumericAttribute N;
    MFnEnumAttribute E;

    aInput = T.create("input", "i", MFnData::kDoubleArray, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setStorable(true);
    T.setWritable(true);

    aInputMin = N.create("inputMin", "imn", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);

    aInputMax = N.create("inputMax", "imx", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(1.0);

    aOutputMin = N.create("outputMin", "omn", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);

    aOutputMax = N.create("outputMax", "omx", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(1.0);

    aRamp = MRampAttribute::createCurveRamp("values", "vl", &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

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

    addAttribute(aInput);
    addAttribute(aInputMin);
    addAttribute(aInputMax);
    addAttribute(aOutputMin);
    addAttribute(aOutputMax);
    addAttribute(aRamp);
    addAttribute(aOutput);

    attributeAffects(aInput, aOutput);
    attributeAffects(aInputMin, aOutput);
    attributeAffects(aInputMax, aOutput);
    attributeAffects(aOutputMin, aOutput);
    attributeAffects(aOutputMax, aOutput);
    attributeAffects(aRamp, aOutput);

    return MS::kSuccess;
}