Example #1
0
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;
}
MStatus sphericalBlendShapeVisualizer::initialize()
		
{
	MStatus status;

	MFnMatrixAttribute mAttr;
	MFnEnumAttribute   eAttr;

	aSpaceMatrix = mAttr.create("spaceMatrix", "spaceMatrix", MFnMatrixAttribute::kDouble, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);

	aPoleAxis = eAttr.create("poleAxis", "poleAxis", 1, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	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.setDefault(1);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	eAttr.setWritable(true);

	aSeamAxis = eAttr.create("seamAxis", "seamAxis", 0, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	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.setDefault(0);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	eAttr.setWritable(true);

	addAttribute(aSpaceMatrix);
	addAttribute(aPoleAxis);
	addAttribute(aSeamAxis);

	return MS::kSuccess;
}
Example #3
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;
}
//-----------------------------------------------------------------------------
// 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;
}
Example #5
0
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 );
}
Example #6
0
MStatus ReduceArrayNode::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);

    aOutput = N.create("output", "o", MFnNumericData::kDouble, 0.0);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setWritable(true);
    T.setStorable(true);

    aOperation = E.create("operation", "operation");
    E.addField("No Operation", kNO_OP);
    E.addField("Sum", kSUM);
    E.addField("Difference", kDIFFERENCE);
    E.addField("Average", kAVERAGE);
    E.addField("Product", kPRODUCT);
    E.addField("Quotient", kQUOTIENT);
    E.addField("Exponent", kEXPONENT);
    E.addField("Minimum", kMIN);
    E.addField("Maximum", kMAX);
    E.addField("Length", kLENGTH);
    E.setKeyable(true);
    E.setStorable(true);
    E.setWritable(true);

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

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

    return MS::kSuccess;
}
Example #7
0
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;
}
Example #8
0
MStatus snapDeformer::initialize() {
	MStatus stat;

    MFnNumericAttribute FnNumeric;
    MFnNumericAttribute FnNumericA;
    MFnTypedAttribute FnTyped;
    MFnEnumAttribute FnEnum;

	//weight
	weight = FnNumeric.create("weight", "we", MFnNumericData::kFloat);
	FnNumeric.setKeyable(true);
	FnNumeric.setStorable(true);
	FnNumeric.setReadable(true);
	FnNumeric.setWritable(true);
    FnNumeric.setDefault( 1.0 );
	addAttribute( weight );


    ///space target
	space = FnEnum.create("space", "sp", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(space);

    ///space source
	spaceSource = FnEnum.create("spaceSource", "sps", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(spaceSource);


	//pointlist
	pointList = FnNumericA.create("pointList", "pl", MFnNumericData::kInt);
	FnNumericA.setArray( true );
	FnNumericA.setKeyable(false);
	FnNumericA.setStorable(true);
	FnNumericA.setReadable(true);
	FnNumericA.setWritable(true);
    FnNumericA.setIndexMatters(true);
	addAttribute( pointList );


	//snapMesh
	snapMesh = FnTyped.create("snapMesh", "sm", MFnData::kMesh);
	FnTyped.setArray( false );
	FnTyped.setReadable(true);
	FnTyped.setWritable(true);
	addAttribute( snapMesh );



	attributeAffects(snapMesh, outputGeom);
	attributeAffects(pointList, outputGeom);
	attributeAffects(space, outputGeom);
    attributeAffects(spaceSource, outputGeom);
	attributeAffects(weight, outputGeom);

    return stat;
}
// create attributes
MStatus probeDeformerARAPNode::initialize(){
    MFnTypedAttribute tAttr;
    MFnNumericAttribute nAttr;
    MFnEnumAttribute eAttr;
    MFnMatrixAttribute mAttr;
   	MRampAttribute rAttr;

    // this attr will be dirtied when ARAP recomputation is needed
    aARAP = nAttr.create( "arap", "arap", MFnNumericData::kBoolean, true );
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setHidden(true);
    addAttribute( aARAP );

    // this attr will be dirtied when weight recomputation is needed
    aComputeWeight = nAttr.create( "computeWeight", "computeWeight", MFnNumericData::kBoolean, true );
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setHidden(true);
    addAttribute( aComputeWeight );

    aMatrix = mAttr.create("probeMatrix", "pm");
    mAttr.setStorable(false);
    mAttr.setHidden(true);
    mAttr.setArray(true);
    mAttr.setUsesArrayDataBuilder(true);
    mAttr.setDisconnectBehavior(MFnMatrixAttribute::kDelete);
    addAttribute(aMatrix);
    attributeAffects( aMatrix, outputGeom );

    aInitMatrix = mAttr.create("initProbeMatrix", "ipm");
    mAttr.setHidden(true);
    mAttr.setArray(true);
    mAttr.setStorable(true);
    mAttr.setUsesArrayDataBuilder(true);
    addAttribute(aInitMatrix);
    attributeAffects( aInitMatrix, outputGeom );

    aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL );
    eAttr.addField( "expSO+expSym", BM_SRL );
    eAttr.addField( "expSE+expSym", BM_SSE );
    eAttr.addField( "logmatrix3", BM_LOG3 );
    eAttr.addField( "logmatrix4", BM_LOG4 );
    eAttr.addField( "quat+linear", BM_SQL );
    eAttr.addField( "linear", BM_AFF );
    eAttr.addField( "off", BM_OFF );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aBlendMode );
    attributeAffects( aBlendMode, outputGeom );

	aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false );
    nAttr.setKeyable(false);
    nAttr.setStorable(true);
    addAttribute( aRotationConsistency );
    attributeAffects( aRotationConsistency, outputGeom );

	aFrechetSum = nAttr.create( "frechetSum", "fs", MFnNumericData::kBoolean, false );
    nAttr.setKeyable(false);
    nAttr.setStorable(true);
    addAttribute( aFrechetSum );
    attributeAffects( aFrechetSum, outputGeom );
    
    aNormaliseWeight = eAttr.create( "normaliseWeight", "nw", NM_LINEAR );
    eAttr.addField( "NONE", NM_NONE );
    eAttr.addField( "Linear",  NM_LINEAR );
    eAttr.addField( "Softmax", NM_SOFTMAX );
    eAttr.setStorable(true);
    addAttribute( aNormaliseWeight );
    attributeAffects( aNormaliseWeight, outputGeom );
    attributeAffects( aNormaliseWeight, aComputeWeight );

    aWeightMode = eAttr.create( "weightMode", "wtm", WM_HARMONIC_COTAN );
    eAttr.addField( "inverse", WM_INV_DISTANCE );
    eAttr.addField( "cut-off", WM_CUTOFF_DISTANCE );
    eAttr.addField( "draw", WM_DRAW );
//    eAttr.addField( "harmonic-arap", WM_HARMONIC_ARAP);
    eAttr.addField( "harmonic-cotan", WM_HARMONIC_COTAN);
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aWeightMode );
    attributeAffects( aWeightMode, outputGeom );
    attributeAffects( aWeightMode, aComputeWeight );
    
    aConstraintMode = eAttr.create( "constraintMode", "ctm", CONSTRAINT_CLOSEST );
    eAttr.addField( "neighbour",  CONSTRAINT_NEIGHBOUR);
    eAttr.addField( "closestFace", CONSTRAINT_CLOSEST );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aConstraintMode );
    attributeAffects( aConstraintMode, outputGeom );
    attributeAffects( aConstraintMode, aARAP);

    aTetMode = eAttr.create( "tetMode", "tm", TM_FACE );
    eAttr.addField( "face", TM_FACE );
    eAttr.addField( "edge", TM_EDGE );
    eAttr.addField( "vertex", TM_VERTEX );
    eAttr.addField( "vface", TM_VFACE );
    eAttr.setStorable(true);
    eAttr.setKeyable(false);
    addAttribute( aTetMode );
    attributeAffects( aTetMode, outputGeom );
    attributeAffects( aTetMode, aARAP );
    attributeAffects( aTetMode, aComputeWeight );

	aWorldMode = nAttr.create( "worldMode", "wrldmd", MFnNumericData::kBoolean, true );
    nAttr.setStorable(true);
    nAttr.setKeyable(false);
    addAttribute( aWorldMode );
    attributeAffects( aWorldMode, outputGeom );
    attributeAffects( aWorldMode, aARAP );
    
	aEffectRadius = nAttr.create("effectRadius", "er", MFnNumericData::kDouble, 8.0);
    nAttr.setMin( EPSILON );
    nAttr.setStorable(true);
	addAttribute( aEffectRadius );
	attributeAffects( aEffectRadius, outputGeom );
	attributeAffects( aEffectRadius, aComputeWeight );
    
	aTransWeight = nAttr.create("translationWeight", "tw", MFnNumericData::kDouble, 1e-20);
    nAttr.setStorable(true);
	addAttribute( aTransWeight );
	attributeAffects( aTransWeight, outputGeom );
	attributeAffects( aTransWeight, aARAP );

    aAreaWeighted = nAttr.create( "areaWeighted", "aw", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aAreaWeighted );
    attributeAffects( aAreaWeighted, outputGeom );
    attributeAffects( aAreaWeighted, aARAP );

    aNeighbourWeighting = nAttr.create( "neighbourWeighting", "nghbrw", MFnNumericData::kBoolean, false );
    nAttr.setStorable(true);
    addAttribute( aNeighbourWeighting );
    attributeAffects( aNeighbourWeighting, outputGeom );
    attributeAffects( aNeighbourWeighting, aComputeWeight );
    attributeAffects( aNeighbourWeighting, aARAP );

	aConstraintWeight = nAttr.create("constraintWeight", "cw", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aConstraintWeight );
	attributeAffects( aConstraintWeight, outputGeom );
	attributeAffects( aConstraintWeight, aARAP );
    
	aNormExponent = nAttr.create("normExponent", "ne", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aNormExponent );
	attributeAffects( aNormExponent, outputGeom );
	attributeAffects( aNormExponent, aARAP );
	attributeAffects( aNormExponent, aComputeWeight );
    
	aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1);
    nAttr.setStorable(true);
    addAttribute(aIteration);
    attributeAffects(aIteration, outputGeom);
    
	aConstraintRadius = nAttr.create("constraintRadius", "cr", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aConstraintRadius );
	attributeAffects( aConstraintRadius, outputGeom );
	attributeAffects( aConstraintRadius, aARAP );

    aVisualisationMode = eAttr.create( "visualisationMode", "vm", VM_OFF );
    eAttr.addField( "off", VM_OFF );
    eAttr.addField( "energy", VM_ENERGY );
    eAttr.addField( "effect", VM_EFFECT );
    eAttr.addField( "constraint", VM_CONSTRAINT );
    eAttr.addField( "stiffness", VM_STIFFNESS );
    eAttr.setStorable(true);
    addAttribute( aVisualisationMode );
    attributeAffects( aVisualisationMode, outputGeom );
    
	aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0);
    nAttr.setStorable(true);
	addAttribute( aVisualisationMultiplier );
	attributeAffects( aVisualisationMultiplier, outputGeom );
    
    aStiffness = eAttr.create( "stiffnessMode", "stfm", SM_NONE );
    eAttr.addField( "off", SM_NONE );
    eAttr.addField( "painted weight", SM_PAINT );
    eAttr.addField( "learn", SM_LEARN );
    eAttr.setStorable(true);
    addAttribute( aStiffness );
    attributeAffects( aStiffness, outputGeom );
    attributeAffects( aStiffness, aARAP );
    
	aSupervisedMesh = tAttr.create("supervisedMesh", "svmesh", MFnData::kMesh);
    tAttr.setStorable(true);
    tAttr.setArray(true);
    tAttr.setUsesArrayDataBuilder(true);
    addAttribute(aSupervisedMesh);
	attributeAffects( aSupervisedMesh, outputGeom );
	attributeAffects( aSupervisedMesh, aARAP );
    
    aProbeWeight = nAttr.create("probeWeight", "prw", MFnNumericData::kDouble, 1.0);
    nAttr.setArray(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aProbeWeight);
	attributeAffects( aProbeWeight, outputGeom );
	attributeAffects( aProbeWeight, aComputeWeight );

    aProbeConstraintRadius = nAttr.create("probeConstraintRadius", "prcr", MFnNumericData::kDouble, 1.0);
    nAttr.setArray(true);
    nAttr.setStorable(true);
    nAttr.setUsesArrayDataBuilder(true);
    addAttribute(aProbeConstraintRadius);
	attributeAffects( aProbeConstraintRadius, outputGeom );
	attributeAffects( aProbeConstraintRadius, aARAP );

	//ramp
    aWeightCurveR = rAttr.createCurveRamp( "weightCurveRotation", "wcr" );
    addAttribute( aWeightCurveR );
	attributeAffects( aWeightCurveR, outputGeom );
	attributeAffects( aWeightCurveR, aComputeWeight );
    aWeightCurveS = rAttr.createCurveRamp( "weightCurveShear", "wcs" );
    addAttribute( aWeightCurveS );
	attributeAffects( aWeightCurveS, outputGeom );
	attributeAffects( aWeightCurveS, aComputeWeight );
    aWeightCurveL = rAttr.createCurveRamp( "weightCurveTranslation", "wcl" );
    addAttribute( aWeightCurveL );
	attributeAffects( aWeightCurveL, outputGeom );
	attributeAffects( aWeightCurveL, aComputeWeight );
    
    // Make the deformer weights paintable
    MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer probeDeformerARAP weights;" );

    return MS::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;
}
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 #12
0
MStatus meshOpNode::initialize()
//
//	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				status;

	MFnTypedAttribute attrFn;
	MFnEnumAttribute enumFn;

	cpList = attrFn.create("inputComponents", "ics",
		MFnComponentListData::kComponentList);
	attrFn.setStorable(true);	// To be stored during file-save

	opType = enumFn.create("operationType", "oprt", 0, &status);
	enumFn.addField("subd_edges", 0);
	enumFn.addField("subd_faces", 1);
	enumFn.setHidden(false);
	enumFn.setKeyable(true);
	enumFn.setStorable(true);	// To be stored during file-save

	inMesh = attrFn.create("inMesh", "im", MFnMeshData::kMesh);
	attrFn.setStorable(true);	// To be stored during file-save

	// Attribute is read-only because it is an output attribute
	//
	outMesh = attrFn.create("outMesh", "om", MFnMeshData::kMesh);
	attrFn.setStorable(false);
	attrFn.setWritable(false);

	// Add the attributes we have created to the node
	//
	status = addAttribute( cpList );
		if (!status)
		{
			status.perror("addAttribute");
			return status;
		}
	status = addAttribute( opType );
		if (!status)
		{
			status.perror("addAttribute");
			return status;
		}
	status = addAttribute( inMesh );
		if (!status)
		{
			status.perror("addAttribute");
			return status;
		}
	status = addAttribute( outMesh);
		if (!status)
		{
			status.perror("addAttribute");
			return status;
		}

	// Set up a dependency between the input and the output.  This will cause
	// the output to be marked dirty when the input changes.  The output will
	// then be recomputed the next time the value of the output is requested.
	//
	status = attributeAffects( inMesh, outMesh );
		if (!status)
		{
			status.perror("attributeAffects");
			return status;
		}

	status = attributeAffects( cpList, outMesh );
		if (!status)
		{
			status.perror("attributeAffects");
			return status;
		}

	status = attributeAffects( opType, outMesh );
		if (!status)
		{
			status.perror("attributeAffects");
			return status;
		}

	return MS::kSuccess;

}
Example #13
0
MStatus VmIslandNode::initialize()
{
    fprintf( stderr, "VmIslandNode::initialize()...\n" );
    
    MStatus status;
    
    //Seed attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_seed = numericAttrFn.create( "seed", "sD", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 1000 );
        numericAttrFn.setDefault ( 0 );
        status = addAttribute( ia_seed );
        CHECK_MSTATUS( status );
    }
    
    //Roughness attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_roughness = numericAttrFn.create( "roughness", "rG", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 1 );
        numericAttrFn.setDefault ( 0.75 );
        status = addAttribute( ia_roughness );
        CHECK_MSTATUS( status );
    }
    
    //Plane Height attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_planeHeight = numericAttrFn.create( "planeHeight", "pH", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 2000 );
        numericAttrFn.setDefault ( 5 );
        status = addAttribute( ia_planeHeight );
        CHECK_MSTATUS( status );
    }

     //Plane smoothing attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_smooth = numericAttrFn.create( "smoothingStrength", "sS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 6 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_smooth );
        CHECK_MSTATUS( status );
    }
    
     //Plane resolution attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_resolution = numericAttrFn.create( "mayaResolution", "mR", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_resolution );
        CHECK_MSTATUS( status );
    }

    //Renderman resolution attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_rmanResolution = numericAttrFn.create( "rendermanResolution", "rR", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 6 );
        status = addAttribute( ia_rmanResolution );
        CHECK_MSTATUS( status );
    }

    //Plane size attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_planeSize = numericAttrFn.create( "planeSizeScale", "pS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 200 );
        numericAttrFn.setDefault ( 20 );
        status = addAttribute( ia_planeSize );
        CHECK_MSTATUS( status );
    }


     //Plane size attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_gridSize = numericAttrFn.create( "gridSize", "gS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_gridSize );
        CHECK_MSTATUS( status );
    }

     //Grass multiplier - Affects how many instances are spawned
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassMultiplier = numericAttrFn.create( "grassInstanceMultiplier", "gM", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 100 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_grassMultiplier );
        CHECK_MSTATUS( status );
    }


        //Grass multiplier - Affects how many instances are spawned
    {
        MFnNumericAttribute numericAttrFn;
        ia_baseWidth = numericAttrFn.create( "grassBaseWidth", "bW", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.01f );
        numericAttrFn.setMax( 2.0f ); 
        numericAttrFn.setDefault ( 0.6f );
        status = addAttribute( ia_baseWidth );
        CHECK_MSTATUS( status );
    }



    //Grass segment length - Length of segment pieces
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassSegmentLength = numericAttrFn.create( "grassSegmentLength", "gSL", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.001f );
        numericAttrFn.setMax( 10.0f );
        numericAttrFn.setDefault ( 1.0f );
        status = addAttribute( ia_grassSegmentLength );
        CHECK_MSTATUS( status );
    }

     //Number of segments per piece of grass
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassNumSegments = numericAttrFn.create( "numberOfGrassSegments", "nGS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 3 );
        numericAttrFn.setMax( 20 );
        numericAttrFn.setDefault ( 5 );
        status = addAttribute( ia_grassNumSegments );
        CHECK_MSTATUS( status );
    }

    //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_windDirection = numericAttrFn.createPoint( "windDirection", "wDir");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(1.0f, 0.0f, 1.0f);
        status = addAttribute( ia_windDirection );
        CHECK_MSTATUS( status );
    }

    //Grass bend factor
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBendAmount = numericAttrFn.create( "grassBendFactor", "gBF", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.0f );
        numericAttrFn.setMax( 1.0f );
        numericAttrFn.setDefault ( 0.0f );
        status = addAttribute( ia_grassBendAmount );
        CHECK_MSTATUS( status );
    }

    //Wind strength
    {
        MFnNumericAttribute numericAttrFn;
        ia_windSpread = numericAttrFn.create( "windSpread", "wS", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.01f );
        numericAttrFn.setMax( 10.0f );
        numericAttrFn.setDefault ( 5.0f );
        status = addAttribute( ia_windSpread );
        CHECK_MSTATUS( status );
    }



        //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBaseColour1 = numericAttrFn.createColor( "grassBaseColour1", "bCol1");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.0f,0.251f,0.167f);
        status = addAttribute( ia_grassBaseColour1 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassTipColour1 = numericAttrFn.createColor( "grassTipColour1", "tCol1");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.395f,0.551f,0.257f);
        status = addAttribute( ia_grassTipColour1 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBaseColour2 = numericAttrFn.createColor( "grassBaseColour2", "bCol2");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.275f,0.243f,0.043f);
        status = addAttribute( ia_grassBaseColour2 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassTipColour2 = numericAttrFn.createColor( "grassTipColour2", "tCol2");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.611f,0.587f,0.257f);
        status = addAttribute( ia_grassTipColour2 );
        CHECK_MSTATUS( status );
    }





     //Clock attribute. Passes maya frame counter into node
    {
        MFnNumericAttribute numericAttrFn;
        ia_clock = numericAttrFn.create( "clock", "clk", MFnNumericData::kLong, false, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( false );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setDefault( 0 );
        status = addAttribute( ia_clock );
        CHECK_MSTATUS( status );
    }

    
    // "drawStyle"
    //
    // How we should draw in Maya.
    //
    // We will use this value in our Maya plug-in, but we
    // will NOT use it in Renderman. Note elsewhere that
    // this value will not be sent to Renderman, nor will
    // it have any effect on RIB generation.
    //
    // We think of this as an input attribute - hence the
    // prefix "ia_" for "input attribute". 
    {
        MFnEnumAttribute enumAttrFn;
        ia_drawStyle = enumAttrFn.create( "drawStyle", "ds", 1, & status );
        CHECK_MSTATUS( status );
        enumAttrFn.setReadable( true );
        enumAttrFn.setWritable( true );
        enumAttrFn.setStorable( true );
        enumAttrFn.setKeyable( true );
        enumAttrFn.setConnectable( true );
        enumAttrFn.setHidden( false );
        enumAttrFn.addField( "Bounds", 0 );
        enumAttrFn.addField( "Sub bounds", 1 );
        enumAttrFn.addField( "Geometry", 2 );
        enumAttrFn.addField( "Terrain slope normals", 3 );
        enumAttrFn.addField( "Point instances", 4 );
        enumAttrFn.addField( "Wind Velocity", 5 );
        enumAttrFn.addField( "All", 6 );
        enumAttrFn.setDefault(3);
        status = addAttribute( ia_drawStyle );
        CHECK_MSTATUS( status );
    }
    
    // "update"
    //
    // A 'dummy' attribute, and a powerful one. Although
    // the value of this attribute is actually meaningless,
    // when we ask for it we trigger an important computation
    // processs.
    //
    // We think of this as an input attribute - hence the
    // prefix "oa_" for "computation attribute". This signifies
    // that we don't really care about it's final value, but
    // that we know it's going to compute a lot of stuff. 
    {
        MFnNumericAttribute numericAttrFn;
        oa_update = numericAttrFn.create( "update", "upd", MFnNumericData::kBoolean, false, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( false );
        numericAttrFn.setKeyable( false );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( true );
        status = addAttribute( oa_update );
        CHECK_MSTATUS( status );
    }


   
    
    
    // "rib"
    //
    // A string which contains all the attributes, and that
    //  we need to have (and indeed will see again) on the 
    // Renderman side of things.
    //
    // We think of this as an output attribute - hence the
    // prefix "oa_" for "output attribute". The value
    // computed for this attribute (the string) is important,
    // an is used by whatever is asking for it.
    {
        MFnTypedAttribute typedAttrFn;
        oa_rib = typedAttrFn.create( "rib", "rb", MFnData::kString, MObject::kNullObj, & status );
        CHECK_MSTATUS( status );
        typedAttrFn.setReadable( true );
        typedAttrFn.setWritable( true );
        typedAttrFn.setStorable( false );
        typedAttrFn.setKeyable( false );
        typedAttrFn.setConnectable( true );
        typedAttrFn.setHidden( true );
        status = addAttribute( oa_rib );
        CHECK_MSTATUS( status );
    }


    
    // This section tells Maya what attribute effects
    // which attribute. When input attributes change, 
    // make the attributes they effect "dirty". That 
    // means that, when Maya asks for a dirty attribute, 
    // it will need to be computed and "cleaned".
    //
    // Changing an effecting "input" attribute does not
    // trigger a computation of it's effected "output"
    // attribute. It just tells Maya that - if the effected
    // attribute is ever asked for, it will have to call
    // the compute method to calculate it.
    //
    // For complex relationships between attributes,
    // an attributeEffects() call must exist for each
    // relationship. If A effects B, and B effects C,
    // then we will need to make two attributeEffects()
    // calls - one for A effecting B and one for B 
    // effecting C. Maya will not figure out that, if A
    // effects B, and B effets C, then A must effect C.
    //
    // Below we see that most "input" attributes effect
    // both our internal update and the rib generation
    // the same way in each case. But it's not always 
    // exactly the same like this.
    //
    // Notice also that ia_drawStyle does not effect
    // any of the attributes. It's something that's just
    // used in the draw method.
    
    attributeAffects( ia_seed, oa_update );
    attributeAffects( ia_seed, oa_rib );
    
    attributeAffects( ia_roughness, oa_update );
    attributeAffects( ia_roughness, oa_rib );

    attributeAffects( ia_smooth, oa_update );
    attributeAffects( ia_smooth, oa_rib );

    attributeAffects( ia_planeHeight, oa_update );
    attributeAffects( ia_planeHeight, oa_rib );

    attributeAffects( ia_resolution, oa_update );
    attributeAffects( ia_rmanResolution, oa_rib );
    
    attributeAffects( ia_planeSize, oa_update );
    attributeAffects( ia_planeSize, oa_rib );

    attributeAffects( ia_gridSize, oa_update );
    attributeAffects( ia_gridSize, oa_rib );

    attributeAffects( ia_grassMultiplier, oa_update );
    attributeAffects( ia_grassMultiplier, oa_rib );

    attributeAffects( ia_baseWidth, oa_update );
    attributeAffects( ia_baseWidth, oa_rib );

    attributeAffects( ia_grassSegmentLength, oa_update );
    attributeAffects( ia_grassSegmentLength, oa_rib );

    attributeAffects( ia_grassNumSegments, oa_update );
    attributeAffects( ia_grassNumSegments, oa_rib );

    attributeAffects( ia_grassBendAmount, oa_update );
    attributeAffects( ia_grassBendAmount, oa_rib );

    attributeAffects( ia_windDirection, oa_update );
    attributeAffects( ia_windDirection, oa_rib );

    attributeAffects( ia_windSpread, oa_update );
    attributeAffects( ia_windSpread, oa_rib );

    attributeAffects( ia_clock, oa_update );
    attributeAffects( ia_clock, oa_rib );

    attributeAffects( ia_grassBaseColour1, oa_update);
    attributeAffects( ia_grassBaseColour1, oa_rib);

    attributeAffects( ia_grassTipColour1, oa_update);
    attributeAffects( ia_grassTipColour1, oa_rib);

    attributeAffects( ia_grassBaseColour2, oa_update);
    attributeAffects( ia_grassBaseColour2, oa_rib);

    attributeAffects( ia_grassTipColour2, oa_update);
    attributeAffects( ia_grassTipColour2, oa_rib);


    
    
    fprintf( stderr, "VmIslandNode::initialize() done\n" );

    return MStatus::kSuccess;
}
MStatus worldSettingNode::initialize()
{
	MStatus stat;
	MFnNumericAttribute numAttr;
	MFnEnumAttribute enumAttr;

	backgroundTypes=enumAttr.create("BackgroundTypes","wbaty",0);
	enumAttr.addField("Single Color",0);
	enumAttr.addField("Gradient",1);
	enumAttr.addField("Texture",2);
	enumAttr.addField("Sunsky",3);
	enumAttr.addField("DarkTide's Sunsky",4);
	//MCHECKERROR(stat, "create background types");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);
	enumAttr.setHidden(true);

	volumeInitTypes=enumAttr.create("VolumeTypes","wvoty",0);
	enumAttr.addField("None",0);
	enumAttr.addField("Single Scatter",1);
    enumAttr.addField("Sky",2);
	//MCHECKERROR(stat, "create volume types");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);

	DSSkyColorSpaces=enumAttr.create("DarkTideSunskyColorSpaces","wdasu",0);
	enumAttr.addField("CIEE",0);
	enumAttr.addField("CIED50",1);
	enumAttr.addField("sRBGD65",2);
	enumAttr.addField("sRGBD50",3);
	//MCHECKERROR(stat, "create DarkTide's sunsky color spaces");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);

	backgroundColor=numAttr.createColor("BackgroundColor","wbaco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.0,0.0,0.0);

	//gradient attribute
	horizonColor=numAttr.createColor("HorizonColor","whoco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.1,0.8,0.5);

	zenithColor=numAttr.createColor("ZenithColor","wzeco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.4,0.5,0.1);

	horGroundColor=numAttr.createColor("HorGroundColor","whgco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.4,0.5,0.6);

	zenGroundColor=numAttr.createColor("ZenGroundColor","wzgco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.9,0.5,0.2);

	//texture attribute
	texRotation=numAttr.create("TextureRotation","wtero",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(360.0f);

	//sunsky attribute
	turbidity=numAttr.create("Turbidity","wtu",MFnNumericData::kFloat,1.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(1.0f);
	numAttr.setMax(20.0f);

	AHorBrght=numAttr.create("AHorBrght","wahb",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	BHorSprd=numAttr.create("BHorSprd","wbhs",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	CSunBrght=numAttr.create("CSunBrght","wcsb",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	DSunSize=numAttr.create("DSunsize","wdss",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	EBacklight=numAttr.create("EBacklight","webl",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	xDirection=numAttr.create("xDirection","wxd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);


	yDirection=numAttr.create("yDirection","wyd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);

	zDirection=numAttr.create("zDirection","wzd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);

	realSun=numAttr.create("AddRealSun","wads",MFnNumericData::kBoolean,0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	sunPower=numAttr.create("SunPower","wsupo",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(10.0);

	skyLight=numAttr.create("Skylight","wsk",MFnNumericData::kBoolean,1);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	skySamples=numAttr.create("SkySamples","wsksa",MFnNumericData::kInt,1);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(1);
	numAttr.setMax(128);

	//DarkTide's sunsky attribute
	DSTurbidity=numAttr.create("DarkTideTurbidity","wdatu",MFnNumericData::kFloat,2.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(2.0);
	numAttr.setMax(12.0);

	renderDSA=numAttr.create("BrightnessOfHorizonGradient","wbhg",MFnNumericData::kFloat,-10.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	renderDSB=numAttr.create("LuminanceOfHorizon","wloh",MFnNumericData::kFloat,-10.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	renderDSC=numAttr.create("SolarRegionIntensity","wsri",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(50.0);

	renderDSD=numAttr.create("WidthOfCircumsolarRegion","wwocr",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(50.0);

	renderDSE=numAttr.create("BackgroundLight","wbl",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-30.0);
	numAttr.setMax(30.0);

	//sun direction shared with sunsky
	 DSAltitude=numAttr.create("Altitude","wal",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.0);
	numAttr.setMax(2.0);

	DSNight=numAttr.create("Night","wni",MFnNumericData::kBoolean,0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	 DSRealSun=numAttr.create("AddDSRealSun","wadrs",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 DSSunPower=numAttr.create("DSSunPower","wdsp",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSSkyLight=numAttr.create("AddDSSkyLight","wadsl",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 DSSkyPower=numAttr.create("DSSkyPower","wdssp",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10000.0);

	 DSSkySamples=numAttr.create("DSSkySamples","wdsss",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(256);

	 DSSkyBright=numAttr.create("Brightness","wbr",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSExposure=numAttr.create("Exposure","wex",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSGammaEncoding=numAttr.create("GammaEncoding","wgaen",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	//these  appear in each type of background
	 useIBL=numAttr.create("UseIBL","wibl",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 IBLSamples=numAttr.create("IBLSamples","wibls",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(512);

	 backgroundDiffuse=numAttr.create("DiffusePhotons","wdiph",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 backgoundCaustic=numAttr.create("CausticPhotons","wcaph",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 backgoundPower=numAttr.create("BackgroundPower","wbapo",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10000.0);

	volumeStepSize=numAttr.create("StepSize","wvstsi",MFnNumericData::kInt,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0);
	 numAttr.setMax(100);

	volumeAdaptive=numAttr.create("Adaptive","wvad",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	volumeOptimize=numAttr.create("Optimize","wvop",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	volumeAttMapScale=numAttr.create("AttGridResolution","wvagr",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(50);

	 volumeSkyST=numAttr.create("Scale","wvsc",MFnNumericData::kDouble,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0001);
	 numAttr.setMax(10.000);

	volumeAlpha=numAttr.create("Alpha","wval",MFnNumericData::kDouble,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0001);
	 numAttr.setMax(10.000);

	//the node needs an output, even we dont need it...
	worldOutput=numAttr.create("WorldSettingOutput","wwso",MFnNumericData::kBoolean);
	numAttr.setDefault(true);
	numAttr.setHidden(true);

	setAttribute();


	return stat;
}
MStatus sphericalBlendShape::initialize()
{
	MStatus status;

	MFnMatrixAttribute mAttr;
	MFnEnumAttribute   eAttr;

	aSpaceMatrix = mAttr.create("spaceMatrix", "spaceMatrix", MFnMatrixAttribute::kDouble, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);

	aPoleAxis = eAttr.create("poleAxis", "poleAxis", 1, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	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.setDefault(1);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	eAttr.setWritable(true);

	aSeamAxis = eAttr.create("seamAxis", "seamAxis", 0, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	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.setDefault(0);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	eAttr.setWritable(true);

	aWarpMatrix = mAttr.create("warpMatrix", "warpMatrix", MFnMatrixAttribute::kDouble, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);

	aMethod = eAttr.create("conversionMethod", "conversionMethod", 0, &status);
	CHECK_MSTATUS_AND_RETURN_IT(status);
	eAttr.addField("xyzToSpherical", 0);
	eAttr.addField("sphericalToXyz", 1);
	eAttr.setDefault(0);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	eAttr.setWritable(true);

	addAttribute(aSpaceMatrix);
	addAttribute(aPoleAxis);
	addAttribute(aSeamAxis);
	addAttribute(aWarpMatrix);
	addAttribute(aMethod);

	attributeAffects(aSpaceMatrix, outputGeom);
	attributeAffects(aPoleAxis, outputGeom);
	attributeAffects(aSeamAxis, outputGeom);
	attributeAffects(aWarpMatrix, outputGeom);
	attributeAffects(aMethod, outputGeom);

	return MS::kSuccess;
}
Example #16
0
MStatus collisionShapeNode::initialize()
{
	MStatus status;
	MFnMessageAttribute fnMsgAttr;
	MFnNumericAttribute fnNumericAttr;
	MFnEnumAttribute fnEnumAttr;

	ia_type = fnEnumAttr.create("type", "tp", 7, &status);
	MCHECKSTATUS(status, "creating type attribute")
		fnEnumAttr.addField("Convex Hull", 0);
	fnEnumAttr.addField("Mesh", 1);
	fnEnumAttr.addField("Cylinder", 2);
	fnEnumAttr.addField("Capsule", 3);
	fnEnumAttr.addField("Box", 4);
	fnEnumAttr.addField("Sphere", 5);
	fnEnumAttr.addField("Plane", 6);
	fnEnumAttr.addField("BvhMesh", 7);
	fnEnumAttr.addField("HACD", 8);
	fnEnumAttr.setKeyable(true);
	status = addAttribute(ia_type);
	MCHECKSTATUS(status, "adding type attribute")

		ia_scale = fnNumericAttr.createPoint("scale", "sc", &status);
	MCHECKSTATUS(status, "creating ia_scale attribute")
		fnNumericAttr.setDefault(1.0, 1.0, 1.0);
	fnNumericAttr.setKeyable(true);
	status = addAttribute(ia_scale);
	MCHECKSTATUS(status, "adding ia_scale attribute")

		oa_collisionShape = fnMsgAttr.create("outCollisionShape", "oucs", &status);
	MCHECKSTATUS(status, "creating outCollisionShape attribute")
		status = addAttribute(oa_collisionShape);
	MCHECKSTATUS(status, "adding outCollisionShape attribute")

		ia_shape = fnMsgAttr.create("inShape", "insh", &status);
	MCHECKSTATUS(status, "creating inShape attribute")
		status = addAttribute(ia_shape);
	MCHECKSTATUS(status, "adding inShape attribute")

		ca_collisionShape = fnNumericAttr.create("ca_collisionShape", "ccs", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_collisionShape attribute")
		fnNumericAttr.setWorldSpace(true);
	fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_collisionShape);
	MCHECKSTATUS(status, "adding ca_collisionShape attribute")

		ca_collisionShapeParam = fnNumericAttr.create("collisionShapeParam", "cspm", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_collisionShapeParam attribute")
		fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding ca_collisionShapeParam attribute")

		//
		status = attributeAffects(ia_shape, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShape)")

		status = attributeAffects(ia_type, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShape)")

		status = attributeAffects(ia_scale, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShape)")

		//
		status = attributeAffects(ia_shape, ca_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")

		status = attributeAffects(ia_type, ca_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")

		//
		status = attributeAffects(ia_shape, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShapeParam)")

		status = attributeAffects(ia_scale, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShapeParam)")

		status = attributeAffects(ia_type, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShapeParam)")

		return MS::kSuccess;
}
Example #17
0
MStatus puttyNode::initialize()
{
	MStatus status;
	MFnNumericAttribute		nAttr;
  	MFnEnumAttribute		eAttr;
    MFnTypedAttribute       tAttr;
    MFnMatrixAttribute       mAttr;

    // the script


    aScript = tAttr.create( "script", "scr", MFnData::kString);
    tAttr.setStorable(true);
    tAttr.setKeyable(false);
	SYS_ERROR_CHECK( addAttribute( aScript ), "adding aScript" );  

	aCmdBaseName = tAttr.create( "cmdBaseName", "cbn", MFnData::kString);
    tAttr.setStorable(true);
    tAttr.setKeyable(false);
    tAttr.setHidden(true);    
	SYS_ERROR_CHECK( addAttribute( aCmdBaseName ), "adding aCmdBaseName" );  

    // refresh
    
    aSource = nAttr.create( "source", "src", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aSource ), "adding aSource" ); 
    
	// it is important that script sourced is initialised false and not storable
    // so this way the function gets sourced on maya startup    
    aScriptSourced = nAttr.create( "scriptSourced", "ssrc", MFnNumericData::kBoolean, 0 );
    nAttr.setStorable(false);
    nAttr.setHidden(true);        
    SYS_ERROR_CHECK( addAttribute( aScriptSourced ), "adding aScriptSourced" ); 


    aNodeReady = nAttr.create( "nodeReady", "nr", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aNodeReady ), "adding aNodeReady" ); 

    aDynDirty = nAttr.create( "dynDirty", "dd", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aDynDirty ), "adding aDynDirty" ); 

  
    // space
   	aDefSpace = eAttr.create("deformerSpace", "dsp", MSD_SPACE_OBJECT, &status);
	eAttr.addField("object (default)", MSD_SPACE_OBJECT);
	eAttr.addField("world (automatic conversion)", MSD_SPACE_WORLD);
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefSpace ), "adding aDefSpace" );

    // envelope
   	aDefEnvelope = eAttr.create("deformerEnvelope", "de", MSD_ENVELOPE_AUTO, &status);
	eAttr.addField("auto", MSD_ENVELOPE_AUTO);
    eAttr.addField("user", MSD_ENVELOPE_USER);    
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefEnvelope ), "adding aDefEnvelope" );

    // weights
   	aDefWeights = eAttr.create("deformerWeights", "dw", MSD_WEIGHTS_AUTO, &status);
	eAttr.addField("auto", MSD_WEIGHTS_AUTO);
    eAttr.addField("user", MSD_WEIGHTS_USER);    
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefWeights ), "adding aDefWeights" );

    /////////////////////////////////////////////////////////////////////////////    
    // current values
    aCurrPosition = tAttr.create( "currentPosition", "cpos", MFnData::kVectorArray);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrPosition ), "adding aCurrPos" );          

    aCurrWeight = tAttr.create( "currentWeight", "cwgh", MFnData::kDoubleArray);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrWeight ), "adding aCurrWeight" );          
    
    aCurrMultiIndex = nAttr.create("currentMultiIndex","cmi",MFnNumericData::kInt);
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setConnectable(false);
    nAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrMultiIndex ), "adding aCurrMultiIndex" );          

    aCurrWorldMatrix = mAttr.create("currentWorldMatrix","cwm"); 
    mAttr.setStorable(false);
    mAttr.setKeyable(false);
    mAttr.setConnectable(false);
    mAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrWorldMatrix ), "adding aCurrObjectName" );          

/*
    aCurrGeometryName= tAttr.create( "currentGeometryName", "con", MFnData::kString);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrGeometryName ), "adding aCurrObjectName" );          
*/       
    aCurrGeometryType= tAttr.create( "currentGeometryType", "cot", MFnData::kString);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrGeometryType ), "adding aCurrGeometryType" );


    /////////////////////////////////////////////////////////////////////////////    
    // affects
    attributeAffects( aScript ,aNodeReady);          
    attributeAffects( aSource, aNodeReady  );
    attributeAffects( aScriptSourced, aNodeReady  );
    
	attributeAffects( aScript,aScriptSourced);
	attributeAffects( aSource,aScriptSourced);
	
    attributeAffects( aScriptSourced, outputGeom  );    
	attributeAffects( aDynDirty,outputGeom ); 
	attributeAffects( aNodeReady,outputGeom ); 
    attributeAffects( aScript ,outputGeom); 
	attributeAffects(  aCmdBaseName  ,outputGeom);   
    attributeAffects( aSource ,outputGeom );        
    attributeAffects( aDefSpace, outputGeom  );
    attributeAffects( aDefWeights,outputGeom);
    attributeAffects( aDefEnvelope,outputGeom ); 
	return MS::kSuccess;
}
Example #18
0
MStatus MG_poseReader::initialize()
	{ 
		//Declaring all the needed attribute function sets
		MFnEnumAttribute enumFn;
		MFnMatrixAttribute matrixFn;
		MFnNumericAttribute numFn;
		MFnCompoundAttribute compA;


		//Aim axis input attribute

		aimAxis = enumFn.create("aimAxis","aa",0);
		enumFn.addField("x",0);
		enumFn.addField("y",1);
		enumFn.addField("z",2);
		enumFn.setKeyable(true);
		enumFn.setStorable(true);
		addAttribute(aimAxis); 

		//Pose matrix input attribute

		
		poseMatrix =matrixFn.create("poseMatrix","psm");
		matrixFn.setKeyable(true);
		matrixFn.setStorable(true);
		addAttribute(poseMatrix); 

		//Reader matrix input attribute

		readerMatrix =matrixFn.create("readerMatrix","rm");
		matrixFn.setKeyable(true);
		matrixFn.setStorable(true);
		addAttribute(readerMatrix); 

		//Aim axis input attribute

		//Arrow size
		size =numFn.create("size","siz",MFnNumericData::kDouble,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(size);

		readerOnOff =numFn.create("readerOnOff","rof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(readerOnOff);
		

		axisOnOff =numFn.create("axisOnOff","aof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(axisOnOff);


		poseOnOff =numFn.create("poseOnOff","pof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(poseOnOff);



		xPositive = numFn.create("xPositive","xp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(xPositive);

		xNegative = numFn.create("xNegative","xn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(xNegative);

		yPositive = numFn.create("yPositive","yp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(yPositive);

		yNegative = numFn.create("yNegative","yn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(yNegative);

		zPositive = numFn.create("zPositive","zp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(zPositive);

		zNegative = numFn.create("zNegative","zn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(zNegative);



		attributeAffects (aimAxis,xPositive);
		attributeAffects (poseMatrix,xPositive);
		attributeAffects (readerMatrix,xPositive);
		attributeAffects (size,xPositive);

		attributeAffects (aimAxis,xNegative);
		attributeAffects (poseMatrix,xNegative);
		attributeAffects (readerMatrix,xNegative);
		attributeAffects (size,xNegative);

		attributeAffects (aimAxis,yPositive);
		attributeAffects (poseMatrix,yPositive);
		attributeAffects (readerMatrix,yPositive);
		attributeAffects (size,yPositive);

		attributeAffects (aimAxis,yNegative);
		attributeAffects (poseMatrix,yNegative);
		attributeAffects (readerMatrix,yNegative);
		attributeAffects (size,yNegative);


		attributeAffects (aimAxis,zPositive);
		attributeAffects (poseMatrix,zPositive);
		attributeAffects (readerMatrix,zPositive);
		attributeAffects (size,zPositive);

		attributeAffects (aimAxis,zNegative);
		attributeAffects (poseMatrix,zNegative);
		attributeAffects (readerMatrix,zNegative);
		attributeAffects (size,zNegative);

		return MS::kSuccess;
	

}
Example #19
0
//----------------------------------------------------------------------------------------------------------------------
// 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;
}
Example #20
0
MStatus Point::initialize() {
	MFnNumericAttribute nAttr;

	input_display = nAttr.create("display", "display", MFnNumericData::kInt, 1);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
	addAttribute(input_display);

	input_box = nAttr.create("box", "box", MFnNumericData::kInt, 0);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
	addAttribute(input_box);
	
	input_cross = nAttr.create("cross", "cross", MFnNumericData::kInt, 1);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
	addAttribute(input_cross);

	input_tick = nAttr.create("tick", "tick", MFnNumericData::kInt, 0);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
	addAttribute(input_tick);

	input_axis = nAttr.create("axis", "axis", MFnNumericData::kInt, 0);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
	addAttribute(input_axis);
	
	MFnEnumAttribute eAttr;

	input_color = eAttr.create("color", "color", MFnData::kNumeric);
	
	eAttr.addField("Black", 0);
	eAttr.addField("Grey", 1);
	eAttr.addField("White", 2);
	eAttr.addField("Red", 3);
	eAttr.addField("Light red", 4);
	eAttr.addField("Dark red", 5);
	eAttr.addField("Green", 6);
	eAttr.addField("Light green", 7);
	eAttr.addField("Dark green", 8);
	eAttr.addField("Blue", 9);
	eAttr.addField("Light blue", 10);
	eAttr.addField("Dark blue", 11);
	eAttr.addField("Purple", 12);
	eAttr.addField("Magenta", 13);
	eAttr.addField("Brown", 14);
	eAttr.addField("Yellow", 15);
	eAttr.addField("Dark yellow", 16);
	eAttr.addField("Orange", 17);

	eAttr.setDefault(8);
	eAttr.setKeyable(true);
	eAttr.setStorable(true);
	addAttribute(input_color);

	colors.append(MColor(0.0f, 0.0f, 0.0f)); // black
	colors.append(MColor(0.5f, 0.5f, 0.5f)); // grey
	colors.append(MColor(1.0f, 1.0f, 1.0f)); // white
	colors.append(MColor(1.0f, 0.0f, 0.0f)); // red
	colors.append(MColor(1.0f, 0.6899999976158142f, 0.6899999976158142f)); // light_red
	colors.append(MColor(0.5f, 0.0f, 0.0f)); // dark_red
	colors.append(MColor(0.0f, 1.0f, 0.0f)); // green
	colors.append(MColor(0.5f, 1.0f, 0.5f)); // light_green
	colors.append(MColor(0.0f, 0.25f, 0.0f)); // dark_green
	colors.append(MColor(0.1889999955892563f, 0.6299999952316284f, 0.6299999952316284f)); // blue
	colors.append(MColor(0.3919999897480011f, 0.8629999756813049f, 1.0f)); // light_blue
	colors.append(MColor(0.0f, 0.01600000075995922f, 0.37599998712539673f)); // dark_blue
	colors.append(MColor(0.25f, 0.0f, 0.25f)); // purple
	colors.append(MColor(1.0f, 0.0f, 1.0f)); // magenta
	colors.append(MColor(0.75f, 0.2f, 0.0f)); // brown
	colors.append(MColor(1.0f, 1.0f, 0.0f)); // yellow
	colors.append(MColor(0.62117999792099f, 0.6299999952316284f, 0.1889999955892563f)); // dark_yellow
	colors.append(MColor(1.0f, 0.5f, 0.0f)); // orange

	return MS::kSuccess;
}
Example #21
0
MStatus AlembicNode::initialize()
{
    MStatus status;

    MFnUnitAttribute    uAttr;
    MFnTypedAttribute   tAttr;
    MFnNumericAttribute nAttr;
    MFnGenericAttribute gAttr;
    MFnEnumAttribute    eAttr;

    // add the input attributes: time, file, sequence time
    mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0);
    status = uAttr.setStorable(true);
    status = addAttribute(mTimeAttr);

    // input file name
    MFnStringData fileFnStringData;
    MObject fileNameDefaultObject = fileFnStringData.create("");
    mAbcFileNameAttr = tAttr.create("abc_File", "fn",
        MFnData::kString, fileNameDefaultObject);
    status = tAttr.setStorable(true);
    status = tAttr.setUsedAsFilename(true);
    status = addAttribute(mAbcFileNameAttr);

    // playback speed
    mSpeedAttr = nAttr.create("speed", "sp",
        MFnNumericData::kDouble, 1.0, &status);
    status = nAttr.setWritable(true);
    status = nAttr.setStorable(true);
    status = nAttr.setKeyable(true);
    status = addAttribute(mSpeedAttr);

    // frame offset
    mOffsetAttr = nAttr.create("offset", "of",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(true);
    status = nAttr.setStorable(true);
    status = nAttr.setKeyable(true);
    status = addAttribute(mOffsetAttr);

    // cycle type
    mCycleTypeAttr = eAttr.create("cycleType", "ct", 0,  &status );
    status = eAttr.addField("Hold", PLAYTYPE_HOLD);
    status = eAttr.addField("Loop", PLAYTYPE_LOOP);
    status = eAttr.addField("Reverse", PLAYTYPE_REVERSE);
    status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE);
    status = eAttr.setWritable(true);
    status = eAttr.setStorable(true);
    status = eAttr.setKeyable(true);
    status = addAttribute(mCycleTypeAttr);

    // Regex Filter
    // This is a hidden variable to preserve a regexIncludefilter string
    // into a .ma file.
    mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift",
        MFnData::kString);
    status = tAttr.setStorable(true);
    status = tAttr.setHidden(true);
    status = addAttribute(mIncludeFilterAttr);

    // Regex Filter
    // This is a hidden variable to preserve a regexExcludefilter string
    // into a .ma file.
    mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft",
        MFnData::kString);
    status = tAttr.setStorable(true);
    status = tAttr.setHidden(true);
    status = addAttribute(mExcludeFilterAttr);

    // sequence min and max in frames
    mStartFrameAttr = nAttr.create("startFrame", "sf",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(false);
    status = nAttr.setStorable(true);
    status = addAttribute(mStartFrameAttr);

    mEndFrameAttr = nAttr.create("endFrame", "ef",
        MFnNumericData::kDouble, 0, &status);
    status = nAttr.setWritable(false);
    status = nAttr.setStorable(true);
    status = addAttribute(mEndFrameAttr);

    // add the output attributes
    // sampled subD mesh
    MFnMeshData fnMeshData;
    MObject meshDefaultObject = fnMeshData.create(&status);
    mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd",
        MFnData::kMesh, meshDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutSubDArrayAttr);

    // sampled poly mesh
    mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly",
        MFnData::kMesh, meshDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutPolyArrayAttr);

    // sampled nurbs surface
    MFnNurbsSurfaceData fnNSData;
    MObject nsDefaultObject = fnNSData.create(&status);
    mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons",
        MFnData::kNurbsSurface, nsDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutNurbsSurfaceArrayAttr);

    // sampled nurbs curve group
    MFnNurbsCurveData fnNCData;
    MObject ncDefaultObject = fnNCData.create(&status);
    mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc",
        MFnData::kNurbsCurve, ncDefaultObject);
    status = tAttr.setStorable(false);
    status = tAttr.setWritable(false);
    status = tAttr.setKeyable(false);
    status = tAttr.setArray(true);
    status = tAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutNurbsCurveGrpArrayAttr);

    // sampled locator
    mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutLocatorPosScaleArrayAttr);

    // sampled transform operations
    mOutTransOpArrayAttr = nAttr.create("transOp", "to",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutTransOpArrayAttr);

    // sampled camera
    // assume the boolean variables cannot be keyed
    mOutCameraArrayAttr = nAttr.create("outCamera", "ocam",
        MFnNumericData::kDouble, 0.0, &status);
    status = nAttr.setStorable(false);
    status = nAttr.setWritable(false);
    status = nAttr.setArray(true);
    status = nAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutCameraArrayAttr);

    // sampled custom-attributes
    mOutPropArrayAttr = gAttr.create("prop", "pr", &status);
    status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean);
    status = gAttr.addNumericDataAccept(MFnNumericData::kByte);
    status = gAttr.addNumericDataAccept(MFnNumericData::kShort);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Short);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Short);
    status = gAttr.addNumericDataAccept(MFnNumericData::kInt);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Int);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Int);
    status = gAttr.addNumericDataAccept(MFnNumericData::kFloat);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Float);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Float);
    status = gAttr.addNumericDataAccept(MFnNumericData::kDouble);
    status = gAttr.addNumericDataAccept(MFnNumericData::k2Double);
    status = gAttr.addNumericDataAccept(MFnNumericData::k3Double);
    status = gAttr.addNumericDataAccept(MFnNumericData::k4Double);
    status = gAttr.addDataAccept(MFnData::kString);
    status = gAttr.addDataAccept(MFnData::kIntArray);
    status = gAttr.addDataAccept(MFnData::kDoubleArray);
    status = gAttr.addDataAccept(MFnData::kVectorArray);
    status = gAttr.addDataAccept(MFnData::kPointArray);

    status = gAttr.setWritable(false);
    status = gAttr.setKeyable(false);
    status = gAttr.setArray(true);
    status = gAttr.setUsesArrayDataBuilder(true);
    status = addAttribute(mOutPropArrayAttr);

    // set up affection relationships
    status = attributeAffects(mTimeAttr, mOutSubDArrayAttr);
    status = attributeAffects(mTimeAttr, mOutPolyArrayAttr);
    status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mTimeAttr, mOutCameraArrayAttr);
    status = attributeAffects(mTimeAttr, mOutPropArrayAttr);
    status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutPropArrayAttr);
    status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutPropArrayAttr);
    status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr);

    status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr);
    status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr);

    MGlobal::executeCommand( UITemplateMELScriptStr );

    return status;
}
MStatus NuiMayaDeviceGrabber::initialize()
//
//	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
//
{
	// This sample creates a single input float attribute and a single
	// output float attribute.
	//
	MFnNumericAttribute nAttr;
	MFnTypedAttribute	typedAttr;
	MFnUnitAttribute	unitAttr;
	MFnEnumAttribute	enumAttr;
	MStatus				stat;

	aTime = unitAttr.create( "time", "tm",
		MFnUnitAttribute::kTime,
		0.0, &stat );
	stat = addAttribute( aTime );
	if (!stat) { stat.perror("addAttribute time"); return stat;}

	aUseCache = nAttr.create( "useCache", "uc", MFnNumericData::kBoolean, false );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aUseCache );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aDeviceOn = nAttr.create( "deviceOn", "do", MFnNumericData::kBoolean, false );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aDeviceOn );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aDeviceMode = enumAttr.create( "deviceMode", "dm", NuiRGBDDeviceController::EDeviceMode_VertexColorCamera, &stat );
	if (!stat) { stat.perror("create DeviceMode attribute"); return stat;}
	stat = enumAttr.addField( "Depth,Color", NuiRGBDDeviceController::EDeviceMode_DepthColor );
	if (!stat) { stat.perror("add enum type DepthColor"); return stat;}
	stat = enumAttr.addField( "Depth,Color,Player", NuiRGBDDeviceController::EDeviceMode_VertexColorCamera );
	if (!stat) { stat.perror("add enum type DepthColorPlayer"); return stat;}
	stat = enumAttr.addField( "Depth,Color,Skeleton", NuiRGBDDeviceController::EDeviceMode_VertexColorSkeleton );
	if (!stat) { stat.perror("add enum type DepthColorSkeleton"); return stat;}
	stat = enumAttr.addField( "Depth,Color,Skeleton,Face", NuiRGBDDeviceController::EDeviceMode_VertexColorSkeletonFace );
	if (!stat) { stat.perror("add enum type DepthColorSkeletonFace"); return stat;}
	stat = enumAttr.addField( "Depth,Color,Skeleton,Gesture", NuiRGBDDeviceController::EDeviceMode_VertexColorSkeletonGesture );
	if (!stat) { stat.perror("add enum type DepthColorSkeletonGesture"); return stat;}
	stat = enumAttr.addField( "Color", NuiRGBDDeviceController::EDeviceMode_Color );
	if (!stat) { stat.perror("add enum type Color"); return stat;}
	stat = enumAttr.addField( "Depth", NuiRGBDDeviceController::EDeviceMode_Vertex );
	if (!stat) { stat.perror("add enum type Depth"); return stat;}
	stat = enumAttr.addField( "Skeleton", NuiRGBDDeviceController::EDeviceMode_Skeleton );
	if (!stat) { stat.perror("add enum type Skeleton"); return stat;}
	stat = enumAttr.addField( "Fusion", NuiRGBDDeviceController::EDeviceMode_Fusion );
	if (!stat) { stat.perror("add enum type fusion"); return stat;}
	CHECK_MSTATUS( enumAttr.setHidden( false ) );
	CHECK_MSTATUS( enumAttr.setKeyable( false ) );
	stat = addAttribute( aDeviceMode );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aNearMode = nAttr.create( "nearMode", "ne", MFnNumericData::kBoolean, false );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aNearMode );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aElevationAngle = nAttr.create( "elevationAngle", "ea", MFnNumericData::kInt, 0 );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(-27);
	nAttr.setMax(27);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aElevationAngle );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aPreviewerOn = nAttr.create( "previewerOn", "po", MFnNumericData::kBoolean, false );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aPreviewerOn );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aKinFuOn = nAttr.create( "fusionOn", "fo", MFnNumericData::kBoolean, false );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aKinFuOn );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aVolumeVoxelSize = nAttr.create( "volumeVoxelSize", "vvs", MFnNumericData::kFloat, 0.01f );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(0.005f);
	nAttr.setMax(0.02f);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aVolumeVoxelSize );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aShowInvalid = nAttr.create("showInvalid", "siv", MFnNumericData::kBoolean, false, &stat);
	MCHECKERROR( stat, "create showInvalid attribute" )
	nAttr.setKeyable(true);
	ADD_ATTRIBUTE( aShowInvalid );

	aShowOnlyBody = nAttr.create("showOnlyBody", "sc", MFnNumericData::kBoolean, false, &stat);
	MCHECKERROR( stat, "create showOnlyBody attribute" )
	nAttr.setKeyable(true);
	ADD_ATTRIBUTE( aShowOnlyBody );

	aShowMesh = nAttr.create("showMesh", "sm", MFnNumericData::kBoolean, false, &stat);
	MCHECKERROR( stat, "create showMesh attribute" )
	nAttr.setKeyable(true);
	ADD_ATTRIBUTE( aShowMesh );

	aMinDepth = nAttr.create( "nearPlane", "np", MFnNumericData::kShort, 400 );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(400);
	nAttr.setMax(4500);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aMinDepth );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aMaxDepth = nAttr.create( "farPlane", "fp", MFnNumericData::kShort, 4200 );
	// Attribute will be written to files when this type of node is stored
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(400);
	nAttr.setMax(4500);
	// Attribute is keyable and will show up in the channel box
	stat = addAttribute( aMaxDepth );
	if (!stat) { stat.perror("addAttribute"); return stat;}


	// ----------------------- OUTPUTS -------------------------
	aOutputMappable = typedAttr.create( "outputPointCloud", "opc",
		NuiMayaMappableData::id,
		MObject::kNullObj, &stat );
	if (!stat) { stat.perror("create outputPointCloud attribute"); return stat;}
	typedAttr.setWritable( false );
	typedAttr.setStorable(false);
	stat = addAttribute( aOutputMappable );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aOutputSkeleton = typedAttr.create( "outputSkeleton", "osk",
		NuiMayaSkeletonData::id,
		MObject::kNullObj, &stat );
	if (!stat) { stat.perror("create outputSkeleton attribute"); return stat;}
	typedAttr.setWritable( false );
	typedAttr.setStorable(false);
	stat = addAttribute( aOutputSkeleton );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aOutputMesh = typedAttr.create( "outputMesh", "om",
		MFnData::kMesh,
		MObject::kNullObj, &stat );
	MCHECKERROR( stat, "create outputSurface attribute" )
		typedAttr.setWritable( false );
	ADD_ATTRIBUTE( aOutputMesh );

	aOutputGesture = typedAttr.create( "outputGesture", "ogs",
		NuiMayaGestureData::id,
		MObject::kNullObj, &stat );
	if (!stat) { stat.perror("create outputGesture attribute"); return stat;}
	typedAttr.setWritable( false );
	typedAttr.setStorable(false);
	stat = addAttribute( aOutputGesture );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aOutputFacialModel = typedAttr.create( "outputFacialModel", "ofm",
		NuiMayaFacialModelData::id,
		MObject::kNullObj, &stat );
	if (!stat) { stat.perror("create outputFacialModel attribute"); return stat;}
	typedAttr.setWritable( false );
	stat = addAttribute( aOutputFacialModel );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aFaceRotateX = nAttr.create( "faceRotateX", "frX", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create face rotateX attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aFaceRotateY = nAttr.create( "faceRotateY", "frY", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create face rotateY attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aFaceRotateZ = nAttr.create( "faceRotateZ", "frZ", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create rotateZ attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aFaceRotate = nAttr.create( "faceRotate", "fr", aFaceRotateX, aFaceRotateY, aFaceRotateZ, &stat );
	if (!stat) { stat.perror("create face rotate attribute"); return stat;}
	nAttr.setDefault(0.0f, 0.0f, 0.0f);
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	stat = addAttribute( aFaceRotate );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aCameraRotateX = nAttr.create( "cameraRotateX", "crX", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create cameraRotateX attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraRotateY = nAttr.create( "cameraRotateY", "crY", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create rotateY attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraRotateZ = nAttr.create( "cameraRotateZ", "crZ", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create rotateZ attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraRotate = nAttr.create( "cameraRotate", "cr", aCameraRotateX, aCameraRotateY, aCameraRotateZ, &stat );
	if (!stat) { stat.perror("create cameraRotate attribute"); return stat;}
	nAttr.setDefault(0.0f, 0.0f, 0.0f);
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	stat = addAttribute( aCameraRotate );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	aCameraTranslateX = nAttr.create( "cameraTranslateX", "ctX", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create cameraTranslateX attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraTranslateY = nAttr.create( "cameraTranslateY", "ctY", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create cameraTranslateY attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraTranslateZ = nAttr.create( "cameraTranslateZ", "ctZ", MFnNumericData::kDouble, 0.0, &stat );
	if (!stat) { stat.perror("create cameraTranslateZ attribute"); return stat;}
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	aCameraTranslate = nAttr.create( "cameraTranslate", "ct", aCameraTranslateX, aCameraTranslateY, aCameraTranslateZ, &stat );
	if (!stat) { stat.perror("create cameraTranslate attribute"); return stat;}
	nAttr.setDefault(0.0f, 0.0f, 0.0f);
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	nAttr.setStorable(true);
	stat = addAttribute( aCameraTranslate );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	// Set up a dependency between the input and the output.  This will cause
	// the output to be marked dirty when the input changes.  The output will
	// then be recomputed the next time the value of the output is requested.
	//
	stat = attributeAffects( aTime, aOutputMappable );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aOutputSkeleton );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aOutputFacialModel );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aFaceRotateX );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aFaceRotateY );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aFaceRotateZ );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aFaceRotate );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraRotateX );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraRotateY );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraRotateZ );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraRotate );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraTranslateX );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraTranslateY );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraTranslateZ );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( aTime, aCameraTranslate );
	if (!stat) { stat.perror("attributeAffects"); return stat;}

	return MS::kSuccess;
}