Beispiel #1
0
MStatus multiCurve::initialize()
{
	MStatus				stat;
	MFnNumericAttribute	nAttr;
	MFnTypedAttribute	typedAttr;
	
	numCurves = nAttr.create ("numCurves", "nc",
							  MFnNumericData::kLong, 5, &stat);
	PERRORfail(stat, "initialize create numCurves attribute");
	CHECK_MSTATUS ( nAttr.setKeyable( true ) );
	stat = addAttribute( numCurves );
	PERRORfail(stat, "addAttribute(numCurves)");
	
	curveOffset = nAttr.create ("curveOffset", "co",
							  MFnNumericData::kDouble, 1.0, &stat);
	PERRORfail(stat, "initialize create curveOffset attribute");
	CHECK_MSTATUS ( nAttr.setKeyable( true ) );
	stat = addAttribute( curveOffset );
	PERRORfail(stat, "addAttribute(curveOffset)");

	inputCurve = typedAttr.create( "inputCurve", "ic",
								   MFnNurbsCurveData::kNurbsCurve, &stat );
	PERRORfail(stat, "initialize create inputCurve attribute");
	CHECK_MSTATUS ( typedAttr.setReadable( false ) );
	CHECK_MSTATUS ( typedAttr.setWritable( true ) );
	stat = addAttribute( inputCurve );
	PERRORfail(stat, "addAttribute(inputCurve)");
	
	outputCurves = typedAttr.create( "outputCurves", "oc",
									 MFnNurbsCurveData::kNurbsCurve, &stat );
	PERRORfail(stat, "initialize create outputCurves attribute");
	CHECK_MSTATUS ( typedAttr.setArray( true ) );
	CHECK_MSTATUS ( typedAttr.setReadable( true ) );
	CHECK_MSTATUS ( typedAttr.setWritable( false ) );
	CHECK_MSTATUS ( typedAttr.setUsesArrayDataBuilder( true ) );
	stat = addAttribute( outputCurves );
	PERRORfail(stat, "addAttribute(outputCurves)");

	stat = attributeAffects( numCurves, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	stat = attributeAffects( curveOffset, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	stat = attributeAffects( inputCurve, outputCurves );
	PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");

	return stat;
}
Beispiel #2
0
MStatus nailConstraintNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;

    ia_rigidBody = fnMsgAttr.create("inRigidBody", "inrb", &status);
    MCHECKSTATUS(status, "creating inRigidBody attribute")
    status = addAttribute(ia_rigidBody);
    MCHECKSTATUS(status, "adding inRigidBody attribute")

    ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating damping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_damping);
    MCHECKSTATUS(status, "adding damping attribute")

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

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


    status = attributeAffects(ia_rigidBody, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraint)")

    status = attributeAffects(ia_rigidBody, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraintParam)")

    status = attributeAffects(ia_damping, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")

    return MS::kSuccess;
}
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus DispNode::initialize()
{
	MFnNumericAttribute nAttr; 

	// Inputs
	aColor = nAttr.createColor( "color", "c" );
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f));

	aInputValue = nAttr.create( "factor", "f", MFnNumericData::kFloat);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
    CHECK_MSTATUS(nAttr.setDefault(1.0f));

	// Outputs

    aOutColor  = nAttr.createColor( "outColor", "oc" );
    CHECK_MSTATUS(nAttr.setStorable(false));
    CHECK_MSTATUS(nAttr.setHidden(false));
    CHECK_MSTATUS(nAttr.setReadable(true));
    CHECK_MSTATUS(nAttr.setWritable(false));

    aOutTransparency  = nAttr.createColor( "outTransparency", "ot" );
    CHECK_MSTATUS(nAttr.setStorable(false));
    CHECK_MSTATUS(nAttr.setHidden(false));
    CHECK_MSTATUS(nAttr.setReadable(true));
    CHECK_MSTATUS(nAttr.setWritable(false));

    aOutDisplacement = nAttr.create( "displacement", "od", 
									 MFnNumericData::kFloat);
    CHECK_MSTATUS(nAttr.setStorable(false));
    CHECK_MSTATUS(nAttr.setHidden(false));
    CHECK_MSTATUS(nAttr.setReadable(true));
    CHECK_MSTATUS(nAttr.setWritable(false));


    CHECK_MSTATUS(addAttribute(aColor));
    CHECK_MSTATUS(addAttribute(aInputValue));
    CHECK_MSTATUS(addAttribute(aOutColor));
    CHECK_MSTATUS(addAttribute(aOutTransparency));
    CHECK_MSTATUS(addAttribute(aOutDisplacement));

    CHECK_MSTATUS(attributeAffects (aColor, aOutColor));
    CHECK_MSTATUS(attributeAffects (aColor, aOutDisplacement));

    return MS::kSuccess;
}
MStatus  sgBLocator_fromGeo::initialize()
{
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnTypedAttribute   tAttr;

	aOutputValue    = nAttr.create( "outputValue", "outputValue", MFnNumericData::kInt, 1.0 );
	nAttr.setStorable( false );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutputValue ) );
	CHECK_MSTATUS_AND_RETURN_IT( status );


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


	aLineWidth = nAttr.create( "lineWidth", "lineWidth", MFnNumericData::kInt, 1 );
	nAttr.setMin( 1 );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aLineWidth ) );

	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputCurve, aOutputValue ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aLineWidth,  aOutputValue ) );


	return MS::kSuccess;
}
Beispiel #5
0
MStatus MocapMesh::initialize()
{
	MStatus stat;

	MFnTypedAttribute tAttr;
	MFnNumericAttribute nAttr;

	in_inMesh  = tAttr.create("inMesh", "im",MFnData::kMesh);
	tAttr.setKeyable(true);
	tAttr.setStorable(true);
	tAttr.setReadable(true);
	tAttr.setWritable(true);
	stat = addAttribute(in_inMesh);
	if(!stat) { stat.perror("adding inMesh"); return stat; }

	out_message  = nAttr.create("test", "test", MFnNumericData::kDouble, 0.0);
	nAttr.setKeyable(false);
	nAttr.setStorable(false);
	nAttr.setWritable(false);
	nAttr.setReadable(true);
	stat = addAttribute(out_message);
	if(!stat) { stat.perror("adding test"); return stat; }

	stat = attributeAffects(in_inMesh,out_message);
	if(!stat) { stat.perror("attributeAffects"); return stat; }
	return MS::kSuccess;
}
Beispiel #6
0
MStatus ArrayAngleConstructorNode::initialize()
{
    MStatus status;

    MFnNumericAttribute N;
    MFnTypedAttribute T;
    MFnUnitAttribute U;

    aSize = N.create("size", "size", MFnNumericData::kInt, 8.0, &status);
    N.setKeyable(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(8);

    aInput = U.create("input", "i", MFnUnitAttribute::kAngle, 0.0, &status);
    U.setKeyable(false);
    U.setStorable(true);
    U.setWritable(true);
    U.setArray(true);

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

    addAttribute(aSize);
    addAttribute(aInput);
    addAttribute(aOutput);

    attributeAffects(aSize, aOutput);
    attributeAffects(aInput, aOutput);

    return MS::kSuccess;
}
Beispiel #7
0
MStatus weightList::initialize()
{
        MStatus status;
	MFnNumericAttribute numAtt; 

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

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

	attributeAffects(aBias, aWeightsList);
	
	return MStatus::kSuccess;
}
Beispiel #8
0
MStatus [!output CLASS_NAME]::initialize () {
	//- 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.

	//- This sample creates a single input float attribute and a single output float attribute.
	MFnNumericAttribute nAttr ;

	attr1 =nAttr.create (_T("input"), _T("in"), MFnNumericData::kFloat, 0.0) ;
	nAttr.setStorable (true) ; //- Attribute will be written to files when this type of node is stored
	nAttr.setKeyable (true) ; //- Attribute is keyable and will show up in the channel box
	MayaOk (addAttribute (attr1), _T("addAttribute")) ; //- Add the attributes we have created to the node

	attr2 =nAttr.create (_T("output"), _T("out"), MFnNumericData::kFloat, 0.0) ;
	nAttr.setWritable (false) ; //- Attribute is read-only because it is an output attribute
	nAttr.setStorable (false) ; //- Attribute will not be written to files when this type of node is stored
	MayaOk (addAttribute (attr2), _T("addAttribute")) ; //- Add the attributes we have created to the node

	//- 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.
	MayaOk (attributeAffects (attr1, attr2), _T("attributeAffects")) ;

	return (MStatus::kSuccess) ;
}
Beispiel #9
0
MStatus RippleDeformer::initialize()
{
	MStatus status;
	MFnNumericAttribute nAttr;
	
	aAmplitude = nAttr.create("amplitude","amp", MFnNumericData::kFloat, 0.0);
	nAttr.setKeyable(true);
	addAttribute(aAmplitude);
	attributeAffects(aAmplitude, outputGeom);

	aDisplace = nAttr.create("displace", "displace", MFnNumericData::kFloat, 0.0);
	nAttr.setKeyable(true);
	addAttribute(aDisplace);
	attributeAffects(aDisplace, outputGeom);

	MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer rippleDeformer weights");
	return MS::kSuccess;
}
Beispiel #10
0
MStatus meshCacheNode::initialize()
{
	MFnNumericAttribute numAttr;
	MStatus				stat;
	
	stat = zWorks::createTimeAttr(frame, "currentTime", "ct", 1.0);
	zCheckStatus(stat, "ERROR creating time");
	zCheckStatus(addAttribute(frame), "ERROR adding time");
	
	aminframe = numAttr.create( "minFrame", "mnf", MFnNumericData::kInt, 1 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aminframe );
	
	amaxframe = numAttr.create( "maxFrame", "mxf", MFnNumericData::kInt, 24 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( amaxframe );
	
	aframestep = numAttr.create( "frameStep", "fst", MFnNumericData::kInt, 1 );
	numAttr.setMin(1);
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aframestep );
	
	MFnTypedAttribute   stringAttr;
	input = stringAttr.create( "cachePath", "cp", MFnData::kString );
 	stringAttr.setStorable(true);
	addAttribute( input );
	
	MFnTypedAttribute   meshAttr;
	outMesh = meshAttr.create( "outMesh", "o", MFnData::kMesh ); 
	meshAttr.setStorable(false);
	meshAttr.setWritable(false);
	addAttribute( outMesh );
    
	attributeAffects( input, outMesh );
	attributeAffects( frame, outMesh );
	attributeAffects( aminframe, outMesh );
	attributeAffects( amaxframe, outMesh );
	attributeAffects( aframestep, outMesh );

	return MS::kSuccess;
}
Beispiel #11
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;
}
Beispiel #12
0
//
//	Node initialize method.  We configure node
//	attributes here.  Static method so
//	*this is not available.
//
MStatus rockingTransformNode::initialize()
{
	MFnNumericAttribute numFn;
	aRockInX = numFn.create("RockInX", "rockx", MFnNumericData::kDouble, 0.0);
	numFn.setKeyable(true);
	numFn.setAffectsWorldSpace(true);
	addAttribute(aRockInX);
	
	MStatus				stat;
	MFnNumericAttribute numAttr;
	
	aframe = numAttr.create( "currentTime", "ct", MFnNumericData::kDouble, 1.0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aframe );
	
	aminframe = numAttr.create( "minFrame", "mnf", MFnNumericData::kInt, 1 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aminframe );
	
	amaxframe = numAttr.create( "maxFrame", "mxf", MFnNumericData::kInt, 24 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( amaxframe );
	
	MFnTypedAttribute   stringAttr;
	acachename = stringAttr.create( "cachePath", "cp", MFnData::kString );
 	stringAttr.setStorable(true);
	stringAttr.setInternal(true);
	addAttribute( acachename );
	
	ameshname = stringAttr.create( "meshName", "mn", MFnData::kString );
 	stringAttr.setStorable(true);
	stringAttr.setInternal(true);
	addAttribute(ameshname);

	//	This is required so that the validateAndSet method is called
	//mustCallValidateAndSet(aRockInX);
	mustCallValidateAndSet(aframe);
	return MS::kSuccess;
}
MStatus sphereLightNode::initialize()
{
	MStatus stat;

	MFnNumericAttribute numAttr;

	sphereColor=numAttr.createColor("LightColor","lico");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(1.0,1.0,1.0);

	spherePower=numAttr.create("Power","pw",MFnNumericData::kFloat,1.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(10000.0); 

	sphereRadius=numAttr.create("Radius","ra",MFnNumericData::kFloat,1.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(100.0); 

	sphereSamples=numAttr.create("Samples","sam",MFnNumericData::kInt,16);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0);
	numAttr.setMax(512); 

	sphereMakeGeometry=numAttr.create("MakeGeometry","mg",MFnNumericData::kBoolean,0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	addAttribute(sphereColor);
	addAttribute(spherePower);
	addAttribute(sphereRadius);
	addAttribute(sphereSamples);
	addAttribute(sphereMakeGeometry);

	return stat;
}
Beispiel #14
0
MStatus prtAttribNode::initialize()
{
	MFnNumericAttribute numAttr;
	MStatus				stat;
	
	askipidir = numAttr.create( "skipIndirect", "skind", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( askipidir );
	
	askipepid = numAttr.create( "skipScatter", "skscat", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( askipepid );
	
	askipscat = numAttr.create( "skipBackscatter", "skbscat", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( askipscat );
	
	aaslight = numAttr.create( "asLightsource", "asl", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aaslight );
	
	aklight = numAttr.create( "lightIntensity", "li", MFnNumericData::kDouble, 2.0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aklight );
	
	anoshadow = numAttr.create( "castNoShadow", "cns", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( anoshadow );
	
	aasghost = numAttr.create( "asGhost", "asg", MFnNumericData::kBoolean, 0 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aasghost );

	output = numAttr.create( "output", "out", MFnNumericData::kFloat, 0.0 );
	numAttr.setWritable(false);
	numAttr.setStorable(false);
	stat = addAttribute( output );
		if (!stat) { stat.perror("addAttribute"); return stat;}
		
	attributeAffects( askipidir, output );
	attributeAffects( askipepid, output );
	attributeAffects( askipscat, output );
	attributeAffects( aaslight, output );
	attributeAffects( aklight, output );
	attributeAffects( aasghost, output );
	attributeAffects( anoshadow, output );

	return MS::kSuccess;
}
// Initialize the plug-in. Called once when the plug-in is loaded.
// This mostly involve creating attributes.
MStatus hwRefractReflectShader_NV20::initialize()
{
    MFnNumericAttribute nAttr; 
	MStatus status;
	MFnTypedAttribute sAttr; // For string attributes

    // Create input attributes

    colorR = nAttr.create( "colorR", "cr",MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(1.0f);

    colorG = nAttr.create( "colorG", "cg",MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0.5f);

    colorB = nAttr.create( "colorB", "cb",MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0.5f);

    color = nAttr.create( "color", "c", colorR, colorG, colorB);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(1.0f, 0.5f, 0.5f);
    nAttr.setUsedAsColor(true);

    refractionIndex = nAttr.create( "refractionIndex", "ri", MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMin(1.0f);
    nAttr.setMax(2.0f);
    nAttr.setDefault(1.1f);

    reflectivity = nAttr.create( "reflectivity", "rfl", MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setMin(0.0f);
    nAttr.setMax(1.0f);
    nAttr.setDefault(0.5f);

 // Add the attributes here

    addAttribute(color);
    addAttribute(refractionIndex);
    addAttribute(reflectivity);

    attributeAffects (colorR, outColor);
    attributeAffects (colorG, outColor);
    attributeAffects (colorB, outColor);
    attributeAffects (color,  outColor);

    attributeAffects (refractionIndex,   outColor);
    attributeAffects (reflectivity,   outColor);

    return MS::kSuccess;
}
Beispiel #16
0
MStatus ik2Bsolver::initialize()
{ 
    MFnNumericAttribute numattr;
	
	arestLength1 = numattr.create("restLength1", "rsl1", MFnNumericData::kDouble, 16.0);
	numattr.setMin(1.0);
	numattr.setKeyable(true); 
	numattr.setReadable(true);
	numattr.setConnectable(true);
	addAttribute(arestLength1);
	
	arestLength2 = numattr.create("restLength2", "rsl2", MFnNumericData::kDouble, 16.0);
	numattr.setMin(1.0);
	numattr.setKeyable(true); 
	numattr.setReadable(true);
	numattr.setConnectable(true);
	addAttribute(arestLength2);
	
	asoftDistance = numattr.create("softDistance", "sftd", MFnNumericData::kDouble, 1.0);
	numattr.setMin(0.01);
	numattr.setKeyable(true); 
	numattr.setReadable(true);
	numattr.setConnectable(true);
	numattr.setStorable(true);
	addAttribute(asoftDistance);
	
	amaxStretching = numattr.create("maxStretching", "mstc", MFnNumericData::kDouble, 4.0);
	numattr.setMin(0.0);
	numattr.setKeyable(true); 
	numattr.setReadable(true);
	numattr.setConnectable(true);
	numattr.setStorable(true);
	addAttribute(amaxStretching);
	
	attributeAffects(asoftDistance, ik2Bsolver::message);
	
	return MS::kSuccess;
}
Beispiel #17
0
MStatus vxCacheDeformer::initialize()
{
	MFnNumericAttribute	numAttr;
	MFnTypedAttribute   stringAttr;
	MStatus 		status;

	status = zWorks::createTimeAttr(frame, "currentTime", "ct", 1.0);
	zCheckStatus(status, "ERROR creating time");
	zCheckStatus(addAttribute(frame), "ERROR adding time");
	
	path = stringAttr.create( "cachePath", "cp", MFnData::kString );
 	stringAttr.setStorable(true);
	addAttribute( path );
	
	aminframe = numAttr.create( "minFrame", "mnf", MFnNumericData::kInt, 1 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aminframe );
	
	amaxframe = numAttr.create( "maxFrame", "mxf", MFnNumericData::kInt, 24 );
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( amaxframe );
	
	aframestep = numAttr.create( "frameStep", "fst", MFnNumericData::kInt, 1 );
	numAttr.setMin(1);
	numAttr.setStorable(true);
	numAttr.setKeyable(true);
	addAttribute( aframestep );
	
	attributeAffects( frame, vxCacheDeformer::outputGeom );
	attributeAffects( path, vxCacheDeformer::outputGeom );
	attributeAffects( aminframe, vxCacheDeformer::outputGeom );
	attributeAffects( amaxframe, vxCacheDeformer::outputGeom );
	attributeAffects( aframestep, vxCacheDeformer::outputGeom );

	return MStatus::kSuccess;
}
MStatus pointLightNode::initialize()
{
	MStatus stat;

	MFnNumericAttribute numAttr;

	pointLightColor=numAttr.createColor("LightColor","plico");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(1.0,1.0,1.0);

	pointPower=numAttr.create("Power","pp",MFnNumericData::kFloat,1.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(10000.0); 

	addAttribute(pointLightColor);
    addAttribute(pointPower);

	return stat=MStatus::kSuccess;

}
Beispiel #19
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;
}
Beispiel #20
0
// The initialize routine is called after the node has been created.
// It sets up the input and output attributes and adds them to the
// node. Finally the dependencies are arranged so that when the
// inputs change Maya knowns to call compute to recalculate the output
// value.
//
MStatus stringFormat::initialize()
{
	MFnNumericAttribute numAttr;
	MFnTypedAttribute	typedAttr;
	MFnStringData		stringData;
	MStatus				stat;
	MStatus				stat2;

	// Setup the input attributes
	//
	attrFormat = typedAttr.create("format", "f", MFnData::kString, 
								  stringData.create(&stat2), &stat);
	CHECK_MSTATUS( stat2 );
	CHECK_MSTATUS( stat );
 	CHECK_MSTATUS( typedAttr.setStorable( true ) );
 	CHECK_MSTATUS( typedAttr.setKeyable( true ) );

	attrValues = numAttr.create("values", "v", MFnNumericData::kDouble, 
								0, &stat);
	CHECK_MSTATUS( stat );
 	CHECK_MSTATUS( numAttr.setArray( true ) );
	CHECK_MSTATUS( numAttr.setReadable( false ) );
 	CHECK_MSTATUS( numAttr.setIndexMatters( true ) );
 	CHECK_MSTATUS( numAttr.setStorable( true ) );
 	CHECK_MSTATUS( numAttr.setKeyable( true ) );

	attrOutput = typedAttr.create( "output", "o", MFnData::kString,
								   stringData.create(&stat2), &stat);
	CHECK_MSTATUS( stat2 );
	CHECK_MSTATUS( stat );
	CHECK_MSTATUS( typedAttr.setWritable( false ) );
	CHECK_MSTATUS( typedAttr.setStorable( false ) );

	// Add the attributes to the node
	//
	CHECK_MSTATUS( addAttribute( attrFormat ) );
	CHECK_MSTATUS( addAttribute( attrValues ) );
	CHECK_MSTATUS( addAttribute( attrOutput ) );

	// Set the attribute dependencies
	//
	CHECK_MSTATUS( attributeAffects( attrFormat, attrOutput ) );
	CHECK_MSTATUS( attributeAffects( attrValues, attrOutput ) );

	return MS::kSuccess;
} 
Beispiel #21
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 );
}
MStatus BasicLocator::initialize()
{ 
MFnUnitAttribute unitFn;    
MFnNumericAttribute numFn;
MStatus stat;
    
xWidth = unitFn.create( "xWidth", "xw", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) );
unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) );
unitFn.setKeyable( true );
stat = addAttribute( xWidth );
if (!stat) 
    {
	stat.perror( "Unable to add \"xWidth\" attribute" );
	return stat;
    } 

zWidth = unitFn.create( "zWidth", "zw", MFnUnitAttribute::kDistance );
unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) );
unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) );
unitFn.setKeyable( true );
stat = addAttribute( zWidth );
if (!stat) 
    {
	stat.perror( "Unable to add \"zWidth\" attribute" );
	return stat;
    } 

dispType = numFn.create( "dispType", "att", MFnNumericData::kShort );
numFn.setDefault( 0);
numFn.setMin( 0 );
numFn.setMax( 2 );
numFn.setKeyable( true );
stat = addAttribute( dispType );
if (!stat) 
    {
	stat.perror( "Unable to add \"dispType\" attribute" );
	return stat;
    }

// Notify Maya that there is an associated manipulator for this particular type of node
MPxManipContainer::addToManipConnectTable( const_cast<MTypeId &>( typeId ) );

return MS::kSuccess;
}
//- The initialize 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 simpleNode::initialize()
{
	//- Initialize a float input attribute using the MFnNumericAttribute
	//- class. Make that attribute definition saved into Maya file (setStorable),
	//- and selectable in the channel box (setKeyable).

	//- Create a generic attribute using MFnNumericAttribute
	MFnNumericAttribute nAttr;
	simpleNode::input = nAttr.create( "input", "in", MFnNumericData::kFloat, 0.0 );
	//- 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
 	nAttr.setKeyable(true);

	//- TODO: Initialize a float output attribute using the MFnNumericAttribute
	//- class. Make that attribute definition not saved into Maya file.
	//...
	//- TODO: Attribute will not be written to files when this type of node is stored
	//...
	

	//- Now add the attribute to your node definition using the addAttribute()
	//- method.

	//- Add the attributes we have created to the node
	addAttribute( simpleNode::input );	
	//- TODO: Add the output attribute to the node type definition
	//...
	
	//- Finally tell Maya how the information should flow through your node.
	//- This will also tell Maya how the dirty flag is propagated in your node
	//- and ultimately in the Maya DG. To do this, use the attributeAffects()
	//- method to link your node' attributes together.

	//- TODO: 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.
	//...

	//- Return success to Maya
	return MS::kSuccess;
}
Beispiel #24
0
MStatus dynExprField::initialize()
//
//	Descriptions:
//		Initialize the node, attributes.
//
{
	MStatus status;
	MFnNumericAttribute numAttr;

	// create the field basic attributes.
	//
	mDirection = numAttr.createPoint("direction","dir");
	numAttr.setDefault( 0.0, 1.0, 0.0 );
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setReadable(true);
	numAttr.setWritable(true);
	status = addAttribute( mDirection );
	attributeAffects(mDirection, mOutputForce);

	return( MS::kSuccess );
}
    //---------------------------------------------------
    // Creates a typed attribute. Used for maya "notes" attributes.
    MObject DagHelper::createAttribute (
    	const MObject& node,
    	const char* attributeName,
    	const char* attributeShortName,
    	MFnNumericData::Type type,
    	const char *value )
    {
        // Before creating a new attribute: verify that an old one doesn't already exist
        MStatus status;
        MObject attribute;
        MFnDependencyNode nodeFn ( node );
        MPlug plug = nodeFn.findPlug ( attributeShortName, status );

        if ( status != MStatus::kSuccess )
        {
            MFnNumericAttribute attr;
            MStatus status;
            attribute = attr.create ( attributeName,attributeShortName,type,0,&status );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;

            attr.setStorable ( true );
            attr.setKeyable ( false );
            attr.setCached ( true );
            attr.setReadable ( true );
            attr.setWritable ( true );
            status = nodeFn.addAttribute ( attribute, MFnDependencyNode::kLocalDynamicAttr );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;

            plug = nodeFn.findPlug ( attribute, &status );
            if ( status != MStatus::kSuccess ) return MObject::kNullObj;
        }

        status = plug.setValue ( value );
        if ( status != MStatus::kSuccess ) return MObject::kNullObj;

        return attribute;
    }
MStatus asMicrofacet_brdf::initialize()
{
	MFnNumericAttribute nAttr;
	MFnLightDataAttribute lAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

    MStatus status; // Status will be used to hold the MStatus value
                    // returned by each api function call. It is important
                    // to check the status returned by a call to aid in
                    // debugging. Failed API calls can result in subtle
                    // errors that can be difficult to track down, you may
                    // wish to use the CHECK_MSTATUS macro for any API
                    // call where you do not need to provide your own
                    // error handling.
                    //

//---------------------------- automatically created attributes start ------------------------------------
	reflectance = nAttr.createColor("reflectance", "reflectance");
	nAttr.setDefault(0.5,0.5,0.5);
	CHECK_MSTATUS(addAttribute( reflectance ));

	mdf = eAttr.create("mdf", "mdf", 1, &status);
	status = eAttr.addField( "beckmann", 0 );
	status = eAttr.addField( "blinn", 1 );
	status = eAttr.addField( "ggx", 2 );
	status = eAttr.addField( "ward", 3 );
	CHECK_MSTATUS(addAttribute( mdf ));

	glossiness_multiplier = nAttr.create("glossiness_multiplier", "glossiness_multiplier",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( glossiness_multiplier ));

	glossiness = nAttr.create("glossiness", "glossiness",  MFnNumericData::kFloat, 0.5);
	CHECK_MSTATUS(addAttribute( glossiness ));

	fresnel_multiplier = nAttr.create("fresnel_multiplier", "fresnel_multiplier",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( fresnel_multiplier ));

	reflectance_multiplier = nAttr.create("reflectance_multiplier", "reflectance_multiplier",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( reflectance_multiplier ));

//---------------------------- automatically created attributes end ------------------------------------

    // Input Attributes
    //
    aTranslucenceCoeff = nAttr.create( "translucenceCoeff", "tc",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

    aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.8f ) );

    aColor = nAttr.createColor( "color", "c", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) );

    aIncandescence = nAttr.createColor( "incandescence", "ic", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );

    aInTransparency = nAttr.createColor( "transparency", "it", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );

    // Color Output
    //
    aOutColor = nAttr.createColor( "outColor", "oc", &status );
    CHECK_MSTATUS( status );

    CHECK_MSTATUS( nAttr.setHidden( false ) );
    CHECK_MSTATUS( nAttr.setReadable( true ) );
    CHECK_MSTATUS( nAttr.setWritable( false ) );

    aOutTransparency = nAttr.createColor( "outTransparency", "ot", &status );
    CHECK_MSTATUS( status );

    CHECK_MSTATUS( nAttr.setHidden( false ) );
    CHECK_MSTATUS( nAttr.setReadable( true ) );
    CHECK_MSTATUS( nAttr.setWritable( false ) );

    // Camera Normals
    //
    aNormalCameraX = nAttr.create( "normalCameraX", "nx",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCameraY = nAttr.create( "normalCameraY", "ny",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCameraZ = nAttr.create( "normalCameraZ", "nz",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX,
            aNormalCameraY, aNormalCameraZ, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );
    CHECK_MSTATUS( nAttr.setHidden( true ) );


    // Light Direction
    //
    aLightDirectionX = nAttr.create( "lightDirectionX", "ldx",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirectionY = nAttr.create( "lightDirectionY", "ldy",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirection = nAttr.create( "lightDirection", "ld",
            aLightDirectionX, aLightDirectionY, aLightDirectionZ,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );


    // Light Intensity
    //
    aLightIntensityR = nAttr.create( "lightIntensityR", "lir",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensityG = nAttr.create( "lightIntensityG", "lig",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensityB = nAttr.create( "lightIntensityB", "lib",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensity = nAttr.create( "lightIntensity", "li",
            aLightIntensityR, aLightIntensityG, aLightIntensityB,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );


    // Light
    //
    aLightAmbient = nAttr.create( "lightAmbient", "la",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( true ) );

    aLightDiffuse = nAttr.create( "lightDiffuse", "ldf",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( true ) );

    aLightSpecular = nAttr.create( "lightSpecular", "ls",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( false ) );

    aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld",
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );

    aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection,
            aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular,
            aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( lAttr.setArray( true ) );
    CHECK_MSTATUS( lAttr.setStorable( false ) );
    CHECK_MSTATUS( lAttr.setHidden( true ) );
    CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
            true, true, false, 1.0f, 1.0f, NULL ) );


    // Next we will add the attributes we have defined to the node
    //
    CHECK_MSTATUS( addAttribute( aTranslucenceCoeff ) );
    CHECK_MSTATUS( addAttribute( aDiffuseReflectivity ) );
    CHECK_MSTATUS( addAttribute( aColor ) );
    CHECK_MSTATUS( addAttribute( aIncandescence ) );
    CHECK_MSTATUS( addAttribute( aInTransparency ) );
    CHECK_MSTATUS( addAttribute( aOutColor ) );
    CHECK_MSTATUS( addAttribute( aOutTransparency ) );
    CHECK_MSTATUS( addAttribute( aNormalCamera ) );

    // Only add the parent of the compound
    CHECK_MSTATUS( addAttribute( aLightData ) );

    // The attributeAffects() method is used to indicate when the input
    // attribute affects the output attribute. This knowledge allows Maya
    // to optimize dependencies in the graph in more complex nodes where
    // there may be several inputs and outputs, but not all the inputs
    // affect all the outputs.
    //
    CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aColor, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) );
    CHECK_MSTATUS( attributeAffects( aInTransparency, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aIncandescence, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraX, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraY, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraZ, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCamera, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirection, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightAmbient, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightSpecular, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDiffuse, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightBlindData, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightData, aOutColor ) );

    return( MS::kSuccess );
}
Beispiel #27
0
/* static */
MStatus cgfxVector::initialize()
{
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnMatrixAttribute  mAttr;

	sVectorX = nAttr.create("vectorX", "vx",
							MFnNumericData::kDouble, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create vectorX");
		return status;
	}
	nAttr.setKeyable(true);

	sVectorY = nAttr.create("vectorY", "vy",
							MFnNumericData::kDouble, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create vectorY");
		return status;
	}
	nAttr.setKeyable(true);

	sVectorZ = nAttr.create("vectorZ", "vz",
							MFnNumericData::kDouble, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create vectorZ");
		return status;
	}
	nAttr.setKeyable(true);

	sVector = nAttr.create("vector", "v",
						   sVectorX, sVectorY, sVectorZ, &status);
	if (!status)
	{
		status.perror("cgfxVector: create vector");
		return status;
	}
	nAttr.setKeyable(true);

	sIsDirection = nAttr.create("isDirection", "id",
								MFnNumericData::kBoolean, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create isDirection");
		return status;
	}
	nAttr.setKeyable(true);
	nAttr.setDefault(false);

	sMatrix = mAttr.create("matrix", "m",
						   MFnMatrixAttribute::kDouble, &status);
	if (!status)
	{
		status.perror("cgfxVector: create matrix");
		return status;
	}
	mAttr.setWritable(true);
	mAttr.setStorable(true);

	sWorldVectorX = nAttr.create("worldVectorX", "wvx",
								 MFnNumericData::kFloat, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create worldVectorX");
		return status;
	}
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	sWorldVectorY = nAttr.create("worldVectorY", "wvy",
								 MFnNumericData::kFloat, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create worldVectorY");
		return status;
	}
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	sWorldVectorZ = nAttr.create("worldVectorZ", "wvz",
								 MFnNumericData::kFloat, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create worldVectorZ");
		return status;
	}
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	sWorldVectorW = nAttr.create("worldVectorW", "wvw",
								 MFnNumericData::kFloat, 0.0, &status);
	if (!status)
	{
		status.perror("cgfxVector: create worldVectorW");
		return status;
	}
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	sWorldVector = nAttr.create("worldVector", "wv",
								sWorldVectorX, sWorldVectorY, sWorldVectorZ,
								&status);
	if( !status )
	{
		status.perror("cgfxVector: create worldVector");
		return status;
	}
	nAttr.setWritable(false);
	nAttr.setStorable(false);

	status = addAttribute(sVector);
	if (!status)
	{
		status.perror("cgfxVector: addAttribute vector");
		return status;
	}

	status = addAttribute(sIsDirection);
	if (!status)
	{
		status.perror("cgfxVector: addAttribute isDirection");
		return status;
	}

	status = addAttribute(sMatrix);
	if (!status)
	{
		status.perror("cgfxVector: addAttribute matrix");
		return status;
	}

	status = addAttribute(sWorldVector);
	if (!status)
	{
		status.perror("cgfxVector: addAttribute worldVector");
		return status;
	}

	status = addAttribute(sWorldVectorW);
	if (!status)
	{
		status.perror("cgfxVector: addAttribute worldVectorW");
		return status;
	}

	status = attributeAffects(sVector, sWorldVector);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects vector -> worldVector");
		return status;
	}

	status = attributeAffects(sIsDirection, sWorldVector);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects isDirection -> worldVector");
		return status;
	}

	status = attributeAffects(sMatrix, sWorldVector);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects matrix -> worldVector");
		return status;
	}

	status = attributeAffects(sVector, sWorldVectorW);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects vector -> worldVectorW");
		return status;
	}

	status = attributeAffects(sIsDirection, sWorldVectorW);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects isDirection -> worldVectorW");
		return status;
	}

	status = attributeAffects(sMatrix, sWorldVectorW);
	if (!status)
	{
		status.perror("cgfxVector: attributeAffects matrix -> worldVectorW");
		return status;
	}

	return MS::kSuccess;
}
Beispiel #28
0
MStatus lambert::initialize()
{
	MFnNumericAttribute nAttr; 
	MFnLightDataAttribute lAttr;

	MStatus status; // Status will be used to hold the MStatus value
					// returned by each api function call. It is important
					// to check the status returned by a call to aid in
					// debugging. Failed API calls can result in subtle 
					// errors that can be difficult to track down, you may
					// wish to use the CHECK_MSTATUS macro for any API
					// call where you do not need to provide your own
					// error handling.
					//

	// Attribute Initialization:
	//
	// create      - The create function creates a new attribute for the
	//				 node, it takes a long name for the attribute, a short
	//				 name for the attribute, the type of the attribute,
	//				 and a status object to determine if the api call was
	//				 successful.
	//
	// setKeyable  - Sets whether this attribute should accept keyframe
	//				 data, Attributes are not keyable by default.
	//
	// setStorable - Sets whether this attribute should be storable. If an
	//				 attribute is storable, then it will be writen out
	//				 when the node is stored to a file. Attributes are 
	//               storable by default.
	//
	// setDefault  - Sets the default value for this attribute.
	//
	// setUsedAsColor - Sets whether this attribute should be presented as
	//				 a color in the UI.
	//
	// setHidden   - Sets whether this attribute should be hidden from the
	//				 UI. This is useful if the attribute is being used for
	//				 blind data, or if it is being used as scratch space
	//				 for a geometry calculation (should also be marked
	//				 non-connectable in that case). Attributes are not
	//				 hidden by default.
	//
	// setReadable - Sets whether this attribute should be readable. If an
	//				 attribute is readable, then it can be used as the
	//				 source in a dependency graph connection. Attributes
	//				 are readable by default.
	//
	// setWritable - Sets whether this attribute should be readable. If an
	//				 attribute is writable, then it can be used as the
	//				 destination in a dependency graph connection. If an
	//			     attribute is not writable then setAttr commands will
	//				 fail to change the attribute. If both keyable and
	//				 writable for an attribute are set to true it will be
	//				 displayed in the channel box when the node is
	//				 selected. Attributes are writable by default.
	//
	// setArray    - Sets whether this attribute should have an array of
	//				 data. This should be set to true if the attribute
	//				 needs to accept multiple incoming connections.
	//				 Attributes are single elements by default.
	//


	// Input Attributes
	//
	aTranslucenceCoeff = nAttr.create( "translucenceCoeff", "tc",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );	
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.8f ) );

	aColorR = nAttr.create( "colorR", "cr",MFnNumericData::kFloat, 0,
			&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aColorG = nAttr.create( "colorG", "cg", MFnNumericData::kFloat, 0,
			&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.58824f ) );

	aColorB = nAttr.create( "colorB", "cb",MFnNumericData::kFloat, 0,
			&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.644f ) );

	aColor = nAttr.create( "color", "c", aColorR, aColorG, aColorB,
			&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );

	aIncandescenceR = nAttr.create( "incandescenceR", "ir",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescenceG = nAttr.create( "incandescenceG", "ig",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescenceB = nAttr.create( "incandescenceB", "ib",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status);
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescence = nAttr.create( "incandescence", "ic", aIncandescenceR,
			aIncandescenceG, aIncandescenceB, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );

	aInTransR = nAttr.create( "transparencyR", "itr",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransG = nAttr.create( "transparencyG", "itg",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransB = nAttr.create( "transparencyB", "itb",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status);
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransparency = nAttr.create( "transparency", "it", aInTransR,
			aInTransG, aInTransB, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );

	
	// Output Attributes
	//

	// Color Output
	//
	aOutColorR = nAttr.create( "outColorR", "ocr", MFnNumericData::kFloat,
			0, &status );
	CHECK_MSTATUS( status );
	
	aOutColorG = nAttr.create( "outColorG", "ocg", MFnNumericData::kFloat,
			0, &status );
	CHECK_MSTATUS( status );
	
	aOutColorB = nAttr.create( "outColorB", "ocb", MFnNumericData::kFloat,
			0, &status );
	CHECK_MSTATUS( status );
	
	aOutColor = nAttr.create( "outColor", "oc", aOutColorR, aOutColorG,
			aOutColorB, &status );
	CHECK_MSTATUS( status );
	
	CHECK_MSTATUS( nAttr.setHidden( false ) );
	CHECK_MSTATUS( nAttr.setReadable( true ) );
	CHECK_MSTATUS( nAttr.setWritable( false ) );

	
	// Transparency Output
	//
	aOutTransR = nAttr.create( "outTransparencyR", "otr",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransG = nAttr.create( "outTransparencyG", "otg",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransB = nAttr.create( "outTransparencyB", "otb",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransparency = nAttr.create( "outTransparency", "ot",
			aOutTransR,aOutTransG,aOutTransB, &status );
	CHECK_MSTATUS( status );

	CHECK_MSTATUS( nAttr.setHidden( false ) );
	CHECK_MSTATUS( nAttr.setReadable( true ) );
	CHECK_MSTATUS( nAttr.setWritable( false ) );


	// Camera Normals
	//
	aNormalCameraX = nAttr.create( "normalCameraX", "nx",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setStorable( false ) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aNormalCameraY = nAttr.create( "normalCameraY", "ny",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setStorable( false ) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aNormalCameraZ = nAttr.create( "normalCameraZ", "nz",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setStorable( false ) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX,
			aNormalCameraY, aNormalCameraZ, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setStorable( false ) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );
	CHECK_MSTATUS( nAttr.setHidden( true ) );


	// Light Direction
	//
	aLightDirectionX = nAttr.create( "lightDirectionX", "ldx",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightDirectionY = nAttr.create( "lightDirectionY", "ldy",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightDirection = nAttr.create( "lightDirection", "ld",
			aLightDirectionX, aLightDirectionY, aLightDirectionZ,
			&status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );


	// Light Intensity
	//
	aLightIntensityR = nAttr.create( "lightIntensityR", "lir",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightIntensityG = nAttr.create( "lightIntensityG", "lig",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightIntensityB = nAttr.create( "lightIntensityB", "lib",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightIntensity = nAttr.create( "lightIntensity", "li", 
			aLightIntensityR, aLightIntensityG, aLightIntensityB,
			&status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );

   
	// Light
	//
	aLightAmbient = nAttr.create( "lightAmbient", "la",
			MFnNumericData::kBoolean, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( true ) );

	aLightDiffuse = nAttr.create( "lightDiffuse", "ldf",
			MFnNumericData::kBoolean, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( true ) );

	aLightSpecular = nAttr.create( "lightSpecular", "ls",
			MFnNumericData::kBoolean, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( false ) );

	aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi",
			MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
	CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

	aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld",
            &status );
	CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );

	aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection,
			aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, 
			aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
			&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( lAttr.setArray( true ) );
	CHECK_MSTATUS( lAttr.setStorable( false ) );
	CHECK_MSTATUS( lAttr.setHidden( true ) );
	CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
			true, true, false, 1.0f, 1.0f, NULL ) );


	// Next we will add the attributes we have defined to the node
	//
	CHECK_MSTATUS( addAttribute( aTranslucenceCoeff ) );
	CHECK_MSTATUS( addAttribute( aDiffuseReflectivity ) );
	CHECK_MSTATUS( addAttribute( aColor ) );
	CHECK_MSTATUS( addAttribute( aIncandescence ) );
	CHECK_MSTATUS( addAttribute( aInTransparency ) );
	CHECK_MSTATUS( addAttribute( aOutColor ) );
	CHECK_MSTATUS( addAttribute( aOutTransparency ) );
	CHECK_MSTATUS( addAttribute( aNormalCamera ) );

	// Only add the parent of the compound
	CHECK_MSTATUS( addAttribute( aLightData ) );

	// The attributeAffects() method is used to indicate when the input
	// attribute affects the output attribute. This knowledge allows Maya
	// to optimize dependencies in the graph in more complex nodes where
	// there may be several inputs and outputs, but not all the inputs
	// affect all the outputs.
	//
	CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aColorR, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aColorG, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aColorB, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aColor, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aInTransR, aOutTransparency ) );
	CHECK_MSTATUS( attributeAffects( aInTransG, aOutTransparency ) );
	CHECK_MSTATUS( attributeAffects( aInTransB, aOutTransparency ) );
	CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) );
	CHECK_MSTATUS( attributeAffects( aInTransparency, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aIncandescenceR, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aIncandescenceG, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aIncandescenceB, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aIncandescence, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightIntensity, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aNormalCameraX, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aNormalCameraY, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aNormalCameraZ, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aNormalCamera, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightDirection, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightAmbient, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightSpecular, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightDiffuse, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightBlindData, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aLightData, aOutColor ) );

	return( MS::kSuccess );
}
Beispiel #29
0
MStatus MG_softIk::initialize()
	{ 		
	  
	  //This is the nurbs input attribute
	  MFnTypedAttribute typedFn;
	  MFnCompoundAttribute compund;
	  MFnNumericAttribute numFn;
	  MFnMatrixAttribute    matrixFn;
	  
	  
	  
	  startMatrix =matrixFn.create("startMatrix","stm");
	  addAttribute(startMatrix); 
		
	  endMatrix =matrixFn.create("endMatrix","enm");
	  addAttribute(endMatrix); 
	  
	  
	  upInitLength = numFn.create("upInitLength","uil",MFnNumericData::kDouble,0);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  addAttribute(upInitLength);
	  

	  
	  
	  downInitLength = numFn.create("downInitLength","dil",MFnNumericData::kDouble,0);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  addAttribute(downInitLength);
	  

	  globalScale = numFn.create("globalScale","gb",MFnNumericData::kDouble,0);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  numFn.setMin(0.001);
	  addAttribute(globalScale);

	  softDistance = numFn.create("softDistance","sd",MFnNumericData::kDouble,0);
	  numFn.setMin(0.001);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  addAttribute(softDistance);

	  stretch = numFn.create("stretch","str",MFnNumericData::kDouble,0);
	  numFn.setMin(0.0);
	  numFn.setMax(1.0);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  addAttribute(stretch);
	  
	  slide = numFn.create("slide","sld",MFnNumericData::kDouble,0.5);
	  numFn.setMin(0.0);
	  numFn.setMax(1.0);
	  numFn.setStorable(true);
	  numFn.setKeyable(true);
	  addAttribute(slide);
	  
	  upScale = numFn.create("upScale","ups",MFnNumericData::kDouble,1);
	  numFn.setStorable(false);
	  numFn.setKeyable(false);
	  numFn.setWritable(false);
	  addAttribute(upScale);
	  
	  

	  
	  downScale = numFn.create("downScale","dws",MFnNumericData::kDouble,1);
	  numFn.setStorable(false);
	  numFn.setKeyable(false);
	  numFn.setWritable(false);
	  addAttribute(downScale);
	
	  
	  outputTranslateX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0);
	  numFn.setStorable(false);
	  numFn.setKeyable(false);
	  numFn.setWritable(false);
	  addAttribute(outputTranslateX);

	  outputTranslateY = numFn.create("outputTranslateY","oty",MFnNumericData::kDouble,0);
	  numFn.setStorable(false);
	  numFn.setWritable(false);
	  numFn.setKeyable(false);
	  addAttribute(outputTranslateY);
	  

	  outputTranslateZ = numFn.create("outputTranslateZ","otz",MFnNumericData::kDouble,0);
	  numFn.setStorable(false);
	  numFn.setKeyable(false);
	  numFn.setWritable(false);
	  addAttribute(outputTranslateZ);

	  
	  outputTranslate= compund.create("outputTranslate","ot");
	  compund.addChild(outputTranslateX);
	  compund.addChild(outputTranslateY); 
	  compund.addChild(outputTranslateZ);
	  compund.setStorable(false);
	  compund.setKeyable(false);
	  compund.setWritable(false);
	  addAttribute(outputTranslate);
	  
	  
	  attributeAffects( startMatrix ,outputTranslate) ;
	  attributeAffects( endMatrix ,outputTranslate) ;
	  attributeAffects( softDistance ,outputTranslate) ;
	  attributeAffects( stretch ,outputTranslate) ;
	  attributeAffects( slide ,outputTranslate) ;
	  attributeAffects( globalScale ,outputTranslate) ;
	  
	  attributeAffects( startMatrix ,upScale) ;
	  attributeAffects( endMatrix ,upScale) ;
	  attributeAffects( stretch ,upScale) ;
	  attributeAffects( softDistance ,upScale) ;
	  attributeAffects( slide ,upScale) ;
	  attributeAffects( globalScale ,upScale) ;

	  attributeAffects( startMatrix ,downScale) ;
	  attributeAffects( endMatrix ,downScale) ;
	  attributeAffects( softDistance ,downScale) ;
	  attributeAffects( stretch ,downScale) ;
	  attributeAffects( slide ,downScale) ;
	  attributeAffects( globalScale ,downScale) ;

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

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

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

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

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

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

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

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

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

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

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

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

    return MStatus::kSuccess;
}