Ejemplo n.º 1
0
MStatus MG_nurbsRivet::initialize()
	{ 

		//This is the nurbs input attribute
		MFnTypedAttribute typedFn;
		MFnCompoundAttribute compund;
		MFnNumericAttribute numFn;
		MFnMatrixAttribute    matrixFn;

		inputNurbSurface  = typedFn.create("inputNurbSurface","in",MFnData::kNurbsSurface);
		typedFn.setStorable(true);
		addAttribute(inputNurbSurface);
		

		//This is the input point   attribute
		
		
		inputPointX = numFn.create("inputPointX","ipx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(inputPointX);

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

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




		
		inputPoint= compund.create("inputPoint","ip");
		compund.addChild(inputPointX);
		compund.addChild(inputPointY);
		compund.addChild(inputPointZ);
		addAttribute(inputPoint);
	

		//This is the recompute point checkbox
	
		recompute = numFn.create("recompute","r",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(recompute);

		//This is U attribute
	
		uValue = numFn.create("uValue","u",MFnNumericData::kFloat , 0);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(uValue);


		//This is V attribute
	
		vValue = numFn.create("vValue","v",MFnNumericData::kFloat , 0 );
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(vValue);



		//This is the output translate attribute 

		outputX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputX);

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

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




		
		output= compund.create("outputTranslate","ot");
		compund.addChild(outputX);
		compund.addChild(outputY);
		compund.addChild(outputZ);
		compund.setKeyable(false);
		compund.setStorable(false);
		compund.setWritable(false);
		addAttribute(output);


		//output = numFn.createPoint("outputTranslate","ot");
		//numFn.setKeyable(false);
		//numFn.setStorable(false);
		//numFn.setWritable(false);
		//addAttribute(output);


		//This is the output rotate attribute 
		outputRotateX = numFn.create("outputRotateX","orx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputRotateX);

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

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


		outputRotate= compund.create("outputRotate","oro");
		compund.addChild(outputRotateX);
		compund.addChild(outputRotateY);
		compund.addChild(outputRotateZ);
		compund.setKeyable(false);
		compund.setStorable(false);
		compund.setWritable(false);
		addAttribute(outputRotate);

 
		//Those are all the matrix input 

		
		outputMatrix =matrixFn.create("outputMatrix","om");
		matrixFn.setKeyable(false);
		matrixFn.setStorable(false);
		matrixFn.setWritable(false);
		addAttribute(outputMatrix); 


		//offset matrix 

		offsetMatrix =matrixFn.create("offsetMatrix","ofm");
		MMatrix defMatrix;
		defMatrix.setToIdentity();
		matrixFn.setDefault(defMatrix);
		matrixFn.setKeyable(false);
		matrixFn.setStorable(true);
		matrixFn.setWritable(true);
		addAttribute(offsetMatrix); 

		//all the attr affects

		attributeAffects (recompute,output);
		attributeAffects (inputPoint,output);
		attributeAffects (inputNurbSurface,output);
		attributeAffects (uValue,output);
		attributeAffects (vValue,output);
		attributeAffects (offsetMatrix,output);

		attributeAffects (recompute,outputRotate);
		attributeAffects (inputPoint,outputRotate);
		attributeAffects (inputNurbSurface,outputRotate);
		attributeAffects (uValue,outputRotate);
		attributeAffects (vValue,outputRotate);
		attributeAffects (offsetMatrix,outputRotate);

		attributeAffects (recompute,outputMatrix);
		attributeAffects (inputPoint,outputMatrix);
		attributeAffects (inputNurbSurface,outputMatrix);
		attributeAffects (uValue,outputMatrix);
		attributeAffects (vValue,outputMatrix);
		attributeAffects (offsetMatrix,outputMatrix);

		return MS::kSuccess;
	}
Ejemplo n.º 2
0
MStatus	MayaRenderGlobalsNode::initialize()
{
	
	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat = MStatus::kSuccess;

	filtertype = eAttr.create("filtertype", "filtertype", 0, &stat);
	CHECK_MSTATUS(addAttribute( filtertype ));

	imageFormat = eAttr.create("imageFormat", "imageFormat", 0, &stat);
	CHECK_MSTATUS(addAttribute( imageFormat ));

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

	useSunLightConnection = nAttr.create("useSunLightConnection", "useSunLightConnection",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( useSunLightConnection ));

	exportSceneFile = nAttr.create("exportSceneFile", "exportSceneFile",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( exportSceneFile ));

	exportSceneFileName = tAttr.create("exportSceneFileName", "exportSceneFileName",  MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	CHECK_MSTATUS(addAttribute( exportSceneFileName ));

	// sampling adaptive
	minSamples = nAttr.create("minSamples", "minSamples", MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( minSamples ));
	maxSamples = nAttr.create("maxSamples", "maxSamples", MFnNumericData::kInt, 16);
	CHECK_MSTATUS(addAttribute( maxSamples ));
	
	// sampling raster based
	samplesX = nAttr.create("samplesX", "samplesX", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( samplesX ));
	samplesY = nAttr.create("samplesY", "samplesY", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( samplesY ));

	doMotionBlur = nAttr.create("doMotionBlur", "doMotionBlur", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( doMotionBlur ));
	motionBlurRange = nAttr.create("motionBlurRange", "motionBlurRange", MFnNumericData::kFloat, 0.4);
	CHECK_MSTATUS(addAttribute( motionBlurRange ));
	
	motionBlurType = eAttr.create("motionBlurType", "motionBlurType", 0, &stat);
	stat = eAttr.addField( "Center", 0 );
	stat = eAttr.addField( "FrameStart", 1 );
	stat = eAttr.addField( "FrameEnd", 2 );
	CHECK_MSTATUS(addAttribute( motionBlurType ));
	
	doDof = nAttr.create("doDof", "doDof", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( doDof ));

	xftimesamples = nAttr.create("xftimesamples", "xftimesamples", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute(xftimesamples));
	geotimesamples = nAttr.create("geotimesamples", "geotimesamples", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute(geotimesamples));


	MString numCpu = getenv("NUMBER_OF_PROCESSORS");
	int numberOfProcessors = numCpu.asInt();
	threads = nAttr.create("threads", "threads", MFnNumericData::kInt, numberOfProcessors);
	nAttr.setMin(1);
	CHECK_MSTATUS(addAttribute( threads ));

	translatorVerbosity = eAttr.create("translatorVerbosity", "translatorVerbosity", 2, &stat);
	stat = eAttr.addField( "Info", 0 );
	stat = eAttr.addField( "Error", 1 );
	stat = eAttr.addField( "Warning", 2 );
	stat = eAttr.addField( "Progress", 3 );
	stat = eAttr.addField( "Debug", 4 );
	stat = eAttr.addField( "None", 5 );
	CHECK_MSTATUS(addAttribute( translatorVerbosity ));

	rendererVerbosity = nAttr.create("rendererVerbosity", "rendererVerbosity", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute( rendererVerbosity ));

	detectShapeDeform = nAttr.create("detectShapeDeform", "detectShapeDeform", MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( detectShapeDeform ));

	filtersize = nAttr.create("filtersize", "filtersize", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( filtersize ));

	tilesize = nAttr.create("tilesize", "tilesize", MFnNumericData::kInt, 64);
	CHECK_MSTATUS(addAttribute( tilesize ));

	basePath = tAttr.create("basePath", "basePath", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( basePath ));

	imagePath = tAttr.create("imagePath", "imagePath", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( imagePath ));

	imageName = tAttr.create("imageName", "imageName", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( imageName ));

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

	maxTraceDepth = nAttr.create("maxTraceDepth", "maxTraceDepth", MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( maxTraceDepth ));

	sunLightConnection = mAttr.create("sunLightConnection", "sunLightConnection");
	CHECK_MSTATUS(addAttribute( sunLightConnection ));

	adaptiveSampling = nAttr.create("adaptiveSampling", "adaptiveSampling", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( adaptiveSampling ));

	optimizedTexturePath = tAttr.create("optimizedTexturePath", "optimizedTexturePath",  MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	CHECK_MSTATUS(addAttribute( optimizedTexturePath ));

	useOptimizedTextures = nAttr.create("useOptimizedTextures", "useOptimizedTextures", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( useOptimizedTextures ));

	exrDataTypeHalf = nAttr.create("exrDataTypeHalf", "exrDataTypeHalf", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute(exrDataTypeHalf));

	exrMergeChannels = nAttr.create("exrMergeChannels", "exrMergeChannels", MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute(exrMergeChannels));
	
	return MStatus::kSuccess;
}
Ejemplo n.º 3
0
MStatus pnTriangles::initialize()
//
//	Description:
//		Initialize class
//	Return Values:
//		MS::kSuccess
//		MS::kFailure
//		
{
	MFnNumericAttribute nAttr;
	MStatus				stat;

	// Subivision attribute
	attrSubdivisions = nAttr.create( "subdivisions", "sd", MFnNumericData::kInt, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
	nAttr.setMin(0);
    nAttr.setMax(10);
    nAttr.setDefault(1);
	nAttr.setKeyable(true);

	attrColored = nAttr.create( "colored", "cl", MFnNumericData::kBoolean, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
    nAttr.setDefault( false );
	nAttr.setKeyable(true);

	attrTextured = nAttr.create( "textured", "tx", MFnNumericData::kBoolean, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
    nAttr.setDefault( false );
	nAttr.setKeyable(true);

	attrWireframe = nAttr.create( "wireframe", "wf", MFnNumericData::kBoolean, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
    nAttr.setDefault( false );
	nAttr.setKeyable(true);
	
	// Normal mode attribute
	attrNormalMode = nAttr.create( "quadraticNormals", "qn", MFnNumericData::kInt, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
	nAttr.setMin(0); // Linear
    nAttr.setMax(1); // Quadratic
    nAttr.setDefault(1);
	nAttr.setKeyable(true);

	// Point mode attribute
	attrPointMode= nAttr.create( "cubicPoints", "cp", MFnNumericData::kInt, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
	nAttr.setMin(0); // Linear
    nAttr.setMax(1); // Cubic
    nAttr.setDefault(1);
	nAttr.setKeyable(true);

	// Enable vertex program
	attrEnableVertexProgram = nAttr.create( "vertexProgram", "vp", MFnNumericData::kBoolean, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
    nAttr.setDefault( false );
	nAttr.setKeyable(true);
		
	// Enable pixel program
	attrEnablePixelProgram = nAttr.create( "pixelProgram", "pp", MFnNumericData::kBoolean, 1 );
 	nAttr.setStorable(true);
	nAttr.setInternal(true);
    nAttr.setDefault( false );
	nAttr.setKeyable(true);

	// Add the attributes we have created to the node
	//
	stat = addAttribute( attrSubdivisions );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrColored );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrWireframe );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrTextured );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrNormalMode );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrPointMode );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrEnableVertexProgram );
	if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( attrEnablePixelProgram );
	if (!stat) { stat.perror("addAttribute"); return stat;}

	return MS::kSuccess;
}
Ejemplo n.º 4
0
// INIT =========================================
MStatus gear_slideCurve2::initialize()
{
	MFnTypedAttribute tAttr;
	MFnMatrixAttribute mAttr;
	MFnNumericAttribute nAttr;
	MStatus stat;

	// INPUTS MESH
	
    master_crv = tAttr.create("master_crv", "mcrv", MFnData::kNurbsCurve);
    stat = addAttribute( master_crv );
		if (!stat) {stat.perror("addAttribute"); return stat;}

	master_mat = mAttr.create( "master_mat", "mmat" );
	mAttr.setStorable(true);
    mAttr.setReadable(false);
	stat = addAttribute( master_mat );
		if (!stat) {stat.perror("addAttribute"); return stat;}

	// SLIDERS
	slave_length = nAttr.create("slave_length", "sl", MFnNumericData::kFloat, 1);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
    stat = addAttribute( slave_length );
		if (!stat) {stat.perror("addAttribute"); return stat;}

	master_length = nAttr.create("master_length", "ml", MFnNumericData::kFloat, 1);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
    stat = addAttribute( master_length );
		if (!stat) {stat.perror("addAttribute"); return stat;}

	position = nAttr.create("position", "p", MFnNumericData::kFloat, 0.0);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
    stat = addAttribute( position );
		if (!stat) {stat.perror("addAttribute"); return stat;}

	maxstretch = nAttr.create("maxstretch", "mst", MFnNumericData::kFloat, 1.5);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(1);
    stat = addAttribute( maxstretch );
		if (!stat) {stat.perror("addAttribute"); return stat;}
		
	maxsquash = nAttr.create("maxsquash", "msq", MFnNumericData::kFloat, .5);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
    stat = addAttribute( maxsquash );
		if (!stat) {stat.perror("addAttribute"); return stat;}
		
	softness = nAttr.create("softness", "s", MFnNumericData::kFloat, 0.5);
	nAttr.setStorable(true);
	nAttr.setKeyable(true);
	nAttr.setMin(0);
	nAttr.setMax(1);
    stat = addAttribute( softness );
		if (!stat) {stat.perror("addAttribute"); return stat;}
		
	// CONNECTIONS
	stat = attributeAffects( master_crv, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( master_mat, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}

	stat = attributeAffects( master_length, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( slave_length, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( position, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( maxstretch, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( maxsquash, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( softness, outputGeom );
		if (!stat) { stat.perror("attributeAffects"); return stat;}

    return MS::kSuccess;
}
Ejemplo n.º 5
0
MStatus NBuddyEMPSaverNode::initialize()

{
    MStatus status;

    MFnTypedAttribute typedAttr; //Typed attributes
    MFnUnitAttribute unitAttr;
    MFnStringData stringData; //String Attributes
    MFnNumericAttribute numFn; //Numerics
    MFnPluginData dataFn;

    //Create the body input array attribute
    _inBodies = typedAttr.create("inBodies","inb" , naiadBodyData::id , MObject::kNullObj , &status);
    NM_CheckMStatus(status, "ERROR creating inBodies attribute.\n");
    typedAttr.setStorable( false );
    typedAttr.setKeyable( false );
    typedAttr.setWritable(true);
    typedAttr.setReadable(false);
    typedAttr.setArray( true );
    status = addAttribute( _inBodies );
    NM_CheckMStatus(status, "ERROR adding inBodies attribute.\n");

    //Attribute for the folder in which to put the emp files
    _empOutputPath = typedAttr.create( "empOutputPath", "ef", MFnData::kString ,stringData.create(MString("/home/jimmi/dev/naiad/emopen/maya/naiadForMaya/test.#.emp")), &status);
    NM_CheckMStatus( status, "Failed to create empOutputPath attribute");
    typedAttr.setStorable( true );
    status = addAttribute( _empOutputPath );
    NM_CheckMStatus( status, "Failed to add empOutputPath plug");

    //Time input
    _time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &status );
    NM_CheckMStatus( status, "Failed to create time attribute");
    unitAttr.setStorable(true);
    unitAttr.setWritable(true);
    status = addAttribute( _time );
    NM_CheckMStatus( status, "Failed to add time plug");

    _framePadding = numFn.create( "framePadding", "fp", MFnNumericData::kInt, 4 , &status );
    NM_CheckMStatus( status, "Failed to create framePadding attribute");
    numFn.setStorable(true);
    numFn.setWritable(true);
    status = addAttribute( _framePadding );
    NM_CheckMStatus( status, "Failed to add framePadding plug");
 
    _timeStep = numFn.create( "timeStep", "ts", MFnNumericData::kInt, 0 , &status );
    NM_CheckMStatus( status, "Failed to create timeStep attribute");
    numFn.setStorable(true);
    numFn.setWritable(true);
    status = addAttribute( _timeStep );
    NM_CheckMStatus( status, "Failed to add timeStep plug");

    // an dummy output trigger to force evaluation of the node
    _outTrigger = numFn.create("outTrigger", "ot", MFnNumericData::kBoolean);
    NM_CheckMStatus( status, "Failed to create outTrigger attribute");
    numFn.setStorable(false);
    numFn.setWritable(false);
    status = addAttribute( _outTrigger );
    NM_CheckMStatus( status, "Failed to add outTrigger plug");

    //Attribute Affects
    attributeAffects( _inBodies, _outTrigger );
    attributeAffects( _time, _outTrigger );
    attributeAffects( _framePadding, _outTrigger );
    attributeAffects( _timeStep, _outTrigger );
    attributeAffects( _empOutputPath, _outTrigger );

    return MS::kSuccess;
}
Ejemplo n.º 6
0
MStatus ProxyViz::initialize()
{ 
	MFnNumericAttribute numFn;
	MStatus			 stat;
	
	alodgatehigh = numFn.create( "lodGateMax", "ldmx", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	numFn.setMax(2.f);
	addAttribute(alodgatehigh);
	
	alodgatelow = numFn.create( "lodGateMin", "ldmin", MFnNumericData::kFloat, 0.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.f);
	numFn.setMax(0.999f);
	addAttribute(alodgatelow);

	abboxminx = numFn.create( "bBoxMinX", "bbmnx", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminx);
	
	abboxminy = numFn.create( "bBoxMinY", "bbmny", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminy);
	
	abboxminz = numFn.create( "bBoxMinZ", "bbmnz", MFnNumericData::kFloat, -1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxminz);
	
	abboxmaxx = numFn.create( "bBoxMaxX", "bbmxx", MFnNumericData::kFloat, 1.f );
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxx);
	
	abboxmaxy = numFn.create( "bBoxMaxY", "bbmxy", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxy);
	
	abboxmaxz = numFn.create( "bBoxMaxZ", "bbmxz", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	addAttribute(abboxmaxz);
	
	aradiusMult = numFn.create( "radiusMultiplier", "rml", MFnNumericData::kFloat);
	numFn.setStorable(true);
	numFn.setKeyable(true);
	numFn.setDefault(1.f);
	numFn.setMin(.05f);
	addAttribute(aradiusMult);
	
	axmultiplier = numFn.create( "visualMultiplierX", "vmx", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(axmultiplier);	
	aymultiplier = numFn.create( "visualMultiplierY", "vmy", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(aymultiplier);
	
	azmultiplier = numFn.create( "visualMultiplierZ", "vmz", MFnNumericData::kFloat, 1.f);
	numFn.setKeyable(true);
	numFn.setStorable(true);
	numFn.setMin(0.001f);
	addAttribute(azmultiplier);
	
	agroupcount = numFn.create( "numberInstances", "nis", MFnNumericData::kInt, 1);
	numFn.setKeyable(false);
	numFn.setStorable(true);
	numFn.setMin(1);
	addAttribute(agroupcount);
	
	ainstanceId = numFn.create( "instanceId", "iis", MFnNumericData::kInt, 0);
	numFn.setKeyable(false);
	numFn.setStorable(true);
	numFn.setMin(0);
	addAttribute(ainstanceId);

	MFnTypedAttribute typedAttrFn;
	MVectorArray defaultVectArray;
	MFnVectorArrayData vectArrayDataFn;
	vectArrayDataFn.create( defaultVectArray );
	outPositionPP = typedAttrFn.create( "outPosition",
											"opos",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create pospp");

	typedAttrFn.setStorable(false);
	if(addAttribute( outPositionPP ) != MS::kSuccess) MGlobal::displayWarning("failed add pospp");
	
	outScalePP = typedAttrFn.create( "outScale",
											"oscl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create sclpp");

        typedAttrFn.setStorable(false);
        if(addAttribute(outScalePP) != MS::kSuccess) MGlobal::displayWarning("failed add sclpp");
		
	outRotationPP = typedAttrFn.create( "outRotation",
											"orot",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
												
												if(!stat) MGlobal::displayWarning("failed create rotpp");

        typedAttrFn.setStorable(false);
        if(addAttribute(outRotationPP) != MS::kSuccess) MGlobal::displayWarning("failed add rotpp");
		
	MDoubleArray defaultDArray;
	MFnDoubleArrayData dArrayDataFn;
	dArrayDataFn.create( defaultDArray );
	
	outReplacePP = typedAttrFn.create( "outReplace", "orpl",
									MFnData::kDoubleArray, dArrayDataFn.object(),
									&stat );
											
	if(stat != MS::kSuccess) {
		MGlobal::displayWarning("failed create outReplace");
	}
	
	typedAttrFn.setStorable(false);
	
	stat = addAttribute(outReplacePP);
	if(stat != MS::kSuccess) {
		MGlobal::displayWarning("failed add outReplace");
	}
	
    outValue = numFn.create( "outValue", "ov", MFnNumericData::kFloat );
	numFn.setStorable(false);
	numFn.setWritable(false);
	addAttribute(outValue);
	
	outValue1 = numFn.create( "outValue1", "ov1", MFnNumericData::kFloat );
	numFn.setStorable(false);
	numFn.setWritable(false);
	addAttribute(outValue1);
	
	MFnTypedAttribute   stringAttr;
	acachename = stringAttr.create( "cachePath", "cp", MFnData::kString );
 	stringAttr.setStorable(true);
	addAttribute( acachename );
	
	astandinNames = stringAttr.create( "standinNames", "sdn", MFnData::kString );
 	stringAttr.setStorable(true);
	stringAttr.setArray(true);
	addAttribute(astandinNames);
	
	MFnMatrixAttribute matAttr;
	acameraspace = matAttr.create( "cameraSpace", "cspc", MFnMatrixAttribute::kDouble );
 	matAttr.setStorable(false);
	matAttr.setWritable(true);
	matAttr.setConnectable(true);
	addAttribute(acameraspace);
	
	ahapeture = numFn.create( "horizontalFilmAperture", "hfa", MFnNumericData::kDouble, 1.0 );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( ahapeture );
	
	avapeture = numFn.create( "verticalFilmAperture", "vfa", MFnNumericData::kDouble, 1.0 );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( avapeture );
	
	afocallength = numFn.create( "focalLength", "fl", MFnNumericData::kDouble );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	addAttribute( afocallength );
	
	aconvertPercentage = numFn.create( "convertPercentage", "cvp", MFnNumericData::kDouble );
	numFn.setStorable(false);
	numFn.setConnectable(true);
	numFn.setDefault(1.0);
	numFn.setMax(1.0);
	numFn.setMin(0.01);
	addAttribute(aconvertPercentage);
    
    agroundMesh = typedAttrFn.create("groundMesh", "grdm", MFnMeshData::kMesh);
	typedAttrFn.setStorable(false);
	typedAttrFn.setWritable(true);
	typedAttrFn.setConnectable(true);
    typedAttrFn.setArray(true);
    typedAttrFn.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( agroundMesh );
	attributeAffects(agroundMesh, outValue);
	
	agroundSpace = matAttr.create("groundSpace", "grdsp", MFnMatrixAttribute::kDouble);
	matAttr.setStorable(false);
	matAttr.setWritable(true);
	matAttr.setConnectable(true);
    matAttr.setArray(true);
    matAttr.setDisconnectBehavior(MFnAttribute::kDelete);
	addAttribute( agroundSpace );
	attributeAffects(agroundSpace, outValue);
	
	MPointArray defaultPntArray;
	MFnPointArrayData pntArrayDataFn;
	pntArrayDataFn.create( defaultPntArray );
	aplantTransformCache = typedAttrFn.create( "transformCachePlant",
											"tmcpl",
											MFnData::kPointArray,
											pntArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTransformCache);
	
	MIntArray defaultIntArray;
	MFnIntArrayData intArrayDataFn;
	
	intArrayDataFn.create( defaultIntArray );
	aplantIdCache = typedAttrFn.create( "idCachePlant",
											"idcpl",
											MFnData::kIntArray,
											intArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantIdCache);
	
	aplantTriangleIdCache = typedAttrFn.create( "triCachePlant",
											"trcpl",
											MFnData::kIntArray,
											intArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTriangleIdCache);
	
	aplantTriangleCoordCache = typedAttrFn.create( "coordCachePlant",
											"crcpl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantTriangleCoordCache);
	
	aplantOffsetCache = typedAttrFn.create( "offsetCachePlant",
											"otcpl",
											MFnData::kVectorArray,
											vectArrayDataFn.object(),
											&stat );
    typedAttrFn.setStorable(true);
	addAttribute(aplantOffsetCache);
	
	ainexamp = typedAttrFn.create("inExample", "ixmp", MFnData::kPlugin);
	typedAttrFn.setStorable(false);
	typedAttrFn.setConnectable(true);
	typedAttrFn.setArray(true);
	addAttribute(ainexamp);
    
    adisplayVox = numFn.create( "showVoxelThreshold", "svt", MFnNumericData::kFloat );
	numFn.setDefault(1.0);
    numFn.setMin(.7);
    numFn.setMax(1.0);
    numFn.setStorable(true);
	numFn.setKeyable(true);
    addAttribute(adisplayVox);
	
	acheckDepth = numFn.create( "checkDepth", "cdp", MFnNumericData::kBoolean );
	numFn.setDefault(0);
	numFn.setStorable(false);
	addAttribute(acheckDepth);
	
	ainoverscan = numFn.create( "cameraOverscan", "cos", MFnNumericData::kDouble );
	numFn.setDefault(1.33);
	numFn.setStorable(false);
	addAttribute(ainoverscan);
    
    aactivated = numFn.create( "activated", "act", MFnNumericData::kBoolean );
	numFn.setDefault(0);
	numFn.setStorable(false);
	addAttribute(aactivated);
    
	attributeAffects(ainexamp, outValue1);
	attributeAffects(aradiusMult, outValue1);
	attributeAffects(abboxminx, outValue);
	attributeAffects(abboxmaxx, outValue);
	attributeAffects(abboxminy, outValue);
	attributeAffects(abboxmaxy, outValue);
	attributeAffects(abboxminz, outValue);
	attributeAffects(abboxmaxz, outValue);
	attributeAffects(outPositionPP, outValue);
	
	return MS::kSuccess;
}
Ejemplo n.º 7
0
MStatus slopeShaderNode::initialize()
//
//	Description:
//		Initializes the attributes for this node.
//
{
     MFnNumericAttribute nAttr; 
	 MFnMatrixAttribute nMAttr;
	 MFnTypedAttribute nTAttr;
	 MFnGenericAttribute nGAttr;


	// Input Attributes
	//
    aAngle = nAttr.create( "angle", "ang", MFnNumericData::kFloat);
    nAttr.setDefault(30.0f);
    nAttr.setMin(0.0f);
    nAttr.setMax(100.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

    aColor1 = nAttr.createColor( "walkableColor", "w" );
    nAttr.setDefault(0.0f, 1.0f, 0.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsedAsColor(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

    aColor2 = nAttr.createColor( "nonWalkableColor", "nw" );
    nAttr.setDefault(1.0f, 0.0f, 0.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsedAsColor(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);


	// Surface Normal supplied by the render sampler
	//
    aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "n" );
    nAttr.setStorable(false);
    nAttr.setHidden(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

	//View matrix from the camera into world space
	//
	aMatrixEyeToWorld = nMAttr.create( "matrixEyeToWorld", "mew",
									   MFnMatrixAttribute::kFloat );
	nAttr.setHidden(true);
	nMAttr.setWritable(true);

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

	//dummy plug for forcing evaluation
	//
	aDirtyShaderAttr = nGAttr.create( "dirtyShaderPlug", "dsp");
	nGAttr.setArray(true);
	nGAttr.setHidden(false);
	nGAttr.setUsesArrayDataBuilder(true);
	nGAttr.setReadable(false);
	nGAttr.setStorable(true);
	nGAttr.setIndexMatters(false);
	nGAttr.addAccept(MFnData::kMesh);

	//Add attribues
    addAttribute(aAngle);
    addAttribute(aColor1);
    addAttribute(aColor2);
    addAttribute(aTriangleNormalCamera);
    addAttribute(aOutColor);
	addAttribute(aMatrixEyeToWorld);
	addAttribute(aDirtyShaderAttr);

    attributeAffects (aAngle,  aOutColor);
    attributeAffects (aColor1, aOutColor);
    attributeAffects (aColor2, aOutColor);
    attributeAffects (aTriangleNormalCamera,  aOutColor);
	attributeAffects (aDirtyShaderAttr, aOutColor);

    return MS::kSuccess;
}
Ejemplo n.º 8
0
MStatus liqVolumeNode::initialize()
{
  MFnTypedAttribute   tAttr;
  MFnNumericAttribute nAttr;
  MFnEnumAttribute    eAttr;
  MStatus status;

  // Create input attributes
  aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderType = tAttr.create( MString("rmanShaderType"), MString("rst"), MFnData::kString, aRmanShaderType, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLif = tAttr.create(  MString("rmanShaderLif"),  MString("lif"), MFnData::kString, aRmanShaderLif, &status );
  MAKE_INPUT(tAttr);

  aRmanParams = tAttr.create(  MString("rmanParams"),  MString("rpr"), MFnData::kStringArray, aRmanParams, &status );
  MAKE_INPUT(tAttr);

  aRmanDetails = tAttr.create(  MString("rmanDetails"),  MString("rdt"), MFnData::kStringArray, aRmanDetails, &status );
  MAKE_INPUT(tAttr);

  aRmanTypes = tAttr.create(  MString("rmanTypes"),  MString("rty"), MFnData::kStringArray, aRmanTypes, &status );
  MAKE_INPUT(tAttr);

  aRmanDefaults = tAttr.create(  MString("rmanDefaults"),  MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status );
  MAKE_INPUT(tAttr);

  aRmanArraySizes = tAttr.create(  MString("rmanArraySizes"),  MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status );
  MAKE_INPUT(tAttr);

  aRmanLifCmds = tAttr.create(  MString("rmanLifCmds"),  MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status );
  MAKE_INPUT(tAttr);

  aRmanMethods = tAttr.create(  MString("rmanMethods"),  MString("rmt"), MFnData::kStringArray, aRmanMethods, &status );
  MAKE_INPUT(tAttr);

  aRmanIsOutput = tAttr.create(  MString("rmanIsOutput"),  MString("rio"), MFnData::kIntArray, aRmanIsOutput, &status );
  MAKE_INPUT(tAttr);
  
  aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status );
  eAttr.addField( "Sphere",   0 );
  eAttr.addField( "Cube",     1 );
  eAttr.addField( "Cylinder", 2 );
  eAttr.addField( "Torus",    3 );
  eAttr.addField( "Plane",    4 );
  eAttr.addField( "Teapot",   5 );
  eAttr.addField( "Custom",   6 );
  eAttr.addField( "(globals)",7 );
  MAKE_NONKEYABLE_INPUT(eAttr);
  CHECK_MSTATUS(eAttr.setConnectable(false));

  aPreviewCustomPrimitive = tAttr.create(  MString("previewCustomPrimitive"),  MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status );
  MAKE_INPUT(tAttr);

  aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status );
  MAKE_INPUT(tAttr);

  aOutputInShadow = nAttr.create("outputInShadow", "ois",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);

  // refreshPreview must be true to allow refresh
  aRefreshPreview = nAttr.create("refreshPreview", "rfp",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setHidden(true));

  // Create output attributes
  aOutColor = nAttr.createColor("outColor", "oc");
  MAKE_OUTPUT(nAttr);

  CHECK_MSTATUS(addAttribute(aRmanShader));
  CHECK_MSTATUS(addAttribute(aRmanShaderType));
  CHECK_MSTATUS(addAttribute(aRmanShaderLong));
  CHECK_MSTATUS(addAttribute(aRmanShaderLif));
  CHECK_MSTATUS(addAttribute(aRmanParams));
  CHECK_MSTATUS(addAttribute(aRmanDetails));
  CHECK_MSTATUS(addAttribute(aRmanTypes));
  CHECK_MSTATUS(addAttribute(aRmanDefaults));
  CHECK_MSTATUS(addAttribute(aRmanArraySizes));
  CHECK_MSTATUS(addAttribute(aRmanLifCmds));
  CHECK_MSTATUS(addAttribute(aRmanMethods));
  CHECK_MSTATUS(addAttribute(aRmanIsOutput));

  CHECK_MSTATUS(addAttribute(aPreviewPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewCustomPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewObjectSize));
  CHECK_MSTATUS(addAttribute(aPreviewShadingRate));
  CHECK_MSTATUS(addAttribute(aPreviewBackplane));
  CHECK_MSTATUS(addAttribute(aShaderSpace));
  CHECK_MSTATUS(addAttribute(aOutputInShadow));
  CHECK_MSTATUS(addAttribute(aRefreshPreview));

  CHECK_MSTATUS(addAttribute(aOutColor));

  return MS::kSuccess;
}
Ejemplo n.º 9
0
MStatus collisionShapeNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnEnumAttribute fnEnumAttr;

    ia_type = fnEnumAttr.create("type", "tp", 5, &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.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.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;
}
MObject createPoly(double iFrame, Alembic::AbcGeom::IPolyMesh & iNode,
    MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
    Alembic::AbcGeom::IPolyMeshSchema schema = iNode.getSchema();
    MString name(iNode.getName().c_str());

    MStatus status = MS::kSuccess;

    MFnMesh fnMesh;
    MObject obj;

    // add other properties
    if (schema.getNumSamples() > 1)
    {
        MFloatPointArray emptyPt;
        MIntArray emptyInt;
        obj = fnMesh.create(0, 0, emptyPt, emptyInt, emptyInt, iParent);
        fnMesh.setName(name);
    }
    else
    {
        int64_t index, ceilIndex;
        double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
            schema.getNumSamples(), index, ceilIndex);

        Alembic::AbcGeom::IPolyMeshSchema::Sample samp;
        schema.get(samp, Alembic::Abc::ISampleSelector(index));

        MFloatPointArray ptArray;
        Alembic::Abc::V3fArraySamplePtr ceilPoints;
        if (index != ceilIndex)
        {
            Alembic::AbcGeom::IPolyMeshSchema::Sample ceilSamp;
            schema.get(ceilSamp, Alembic::Abc::ISampleSelector(ceilIndex));
            ceilPoints = ceilSamp.getPositions();
        }

        fillPoints(ptArray, samp.getPositions(), ceilPoints, alpha);
        fillTopology(fnMesh, iParent, ptArray, samp.getIndices(),
            samp.getCounts());
        fnMesh.setName(iNode.getName().c_str());
        setPolyNormals(iFrame, fnMesh, schema.getNormals());
        setUVs(iFrame, fnMesh, schema.getUVs());
        obj = fnMesh.object();
    }

    MString pathName = fnMesh.partialPathName();
    setInitialShadingGroup(pathName);

    if ( !schema.getNormals().valid() )
    {
        MFnNumericAttribute attr;
        MString attrName("noNormals");
        MObject attrObj = attr.create(attrName, attrName,
        MFnNumericData::kBoolean, true, &status);
        attr.setKeyable(true);
        attr.setHidden(false);
        MFnMesh fnMesh(obj);
        fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
    }

    return obj;
}
MObject createSubD(double iFrame, Alembic::AbcGeom::ISubD & iNode,
    MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
    Alembic::AbcGeom::ISubDSchema schema = iNode.getSchema();

    int64_t index, ceilIndex;
    double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
        schema.getNumSamples(), index, ceilIndex);

    Alembic::AbcGeom::ISubDSchema::Sample samp;
    schema.get(samp, Alembic::Abc::ISampleSelector(index));

    MString name(iNode.getName().c_str());

    MFnMesh fnMesh;

    MFloatPointArray pointArray;
    Alembic::Abc::V3fArraySamplePtr emptyPtr;
    fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0);

    fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(),
        samp.getFaceCounts());
    fnMesh.setName(iNode.getName().c_str());

    setInitialShadingGroup(fnMesh.partialPathName());

    MObject obj = fnMesh.object();
    //addProperties(iFrame, iNode, obj, oSampledPropNameList);

    setUVs(iFrame, fnMesh, schema.getUVs());

    // add the mFn-specific attributes to fnMesh node
    MFnNumericAttribute numAttr;
    MString attrName("SubDivisionMesh");
    MObject attrObj = numAttr.create(attrName, attrName,
        MFnNumericData::kBoolean, 1);
    numAttr.setKeyable(true);
    numAttr.setHidden(false);
    fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);

    if (samp.getInterpolateBoundary() > 0)
    {
        attrName = MString("interpolateBoundary");
        attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
            samp.getInterpolateBoundary());

        numAttr.setKeyable(true);
        numAttr.setHidden(false);
        fnMesh.addAttribute(attrObj,  MFnDependencyNode::kLocalDynamicAttr);
    }

    if (samp.getFaceVaryingInterpolateBoundary() > 0)
    {
        attrName = MString("faceVaryingInterpolateBoundary");
        attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
            samp.getFaceVaryingInterpolateBoundary());

        numAttr.setKeyable(true);
        numAttr.setHidden(false);
        fnMesh.addAttribute(attrObj,  MFnDependencyNode::kLocalDynamicAttr);
    }

    if (samp.getFaceVaryingPropagateCorners() > 0)
    {
        attrName = MString("faceVaryingPropagateCorners");
        attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean,
            samp.getFaceVaryingPropagateCorners());

        numAttr.setKeyable(true);
        numAttr.setHidden(false);
        fnMesh.addAttribute(attrObj,  MFnDependencyNode::kLocalDynamicAttr);
    }

    if (samp.getHoles() && !samp.getHoles()->size() == 0)
    {
        printWarning("Hole Poly Indices not yet supported.");
    }

    if (samp.getCreaseSharpnesses() && 
        !samp.getCreaseSharpnesses()->size() == 0)
    {
        printWarning("Creases not yet supported.");
    }

    if (samp.getCornerSharpnesses() && 
        !samp.getCornerSharpnesses()->size() == 0)
    {
        printWarning("Corners not yet supported.");
    }

    return obj;
}
Ejemplo n.º 12
0
MStatus
OpenSubdivPtexShader::initialize() 
{
    MFnTypedAttribute typedAttr;
    MFnNumericAttribute numAttr;
    MFnEnumAttribute enumAttr;

    // level
    aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setSoftMax(5);
    numAttr.setMax(10);

    // tessFactor
    aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setMax(10);

    // scheme
    aScheme = enumAttr.create("scheme", "sc", OsdPtexMeshData::kCatmark);
    enumAttr.addField("Catmull-Clark",  OsdPtexMeshData::kCatmark);
    enumAttr.addField("Loop",           OsdPtexMeshData::kLoop);
    enumAttr.addField("Bilinear",       OsdPtexMeshData::kBilinear);
    enumAttr.setInternal(true);

    // kernel
    aKernel = enumAttr.create("kernel", "kn", OsdPtexMeshData::kCPU);
    enumAttr.addField("CPU",    OsdPtexMeshData::kCPU);
#ifdef OPENSUBDIV_HAS_OPENMP
    enumAttr.addField("OpenMP", OsdPtexMeshData::kOPENMP);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
    enumAttr.addField("CL",     OsdPtexMeshData::kCL);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
    enumAttr.addField("CUDA",   OsdPtexMeshData::kCUDA);
#endif
    enumAttr.setInternal(true);

    // interpolateBoundary
    aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib", 
                    OsdPtexMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("None",            OsdPtexMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("Edge Only",       OsdPtexMeshData::kInterpolateBoundaryEdgeOnly);
    enumAttr.addField("Edge and Corner", OsdPtexMeshData::kInterpolateBoundaryEdgeAndCorner);
    enumAttr.addField("Always Sharp",    OsdPtexMeshData::kInterpolateBoundaryAlwaysSharp);
    enumAttr.setInternal(true);

    // adaptive
    aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true);
    numAttr.setInternal(true);

    // wireframe
    aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false);

    // material attributes
    aDiffuse = numAttr.createColor("diffuse",   "d");
    numAttr.setDefault(0.6f, 0.6f, 0.7f);
    aAmbient = numAttr.createColor("ambient",   "a");
    numAttr.setDefault(0.1f, 0.1f, 0.1f);
    aSpecular = numAttr.createColor("specular", "s");
    numAttr.setDefault(0.3f, 0.3f, 0.3f);

    // Ptex Texture Attributes
    //
    // diffuseEnvironmentMapFile;
    aDiffuseEnvironmentMapFile = typedAttr.create("diffuseEnvironmentMap", "difenv", MFnData::kString);
    typedAttr.setInternal(true);
    // don't let maya hold on to string when fileNode is disconnected
    typedAttr.setDisconnectBehavior(MFnAttribute::kReset);

    // specularEnvironmentMapFile;
    aSpecularEnvironmentMapFile = typedAttr.create("specularEnvironmentMap", "specenv", MFnData::kString);
    typedAttr.setInternal(true);
    // don't let maya hold on to string when fileNode is disconnected
    typedAttr.setDisconnectBehavior(MFnAttribute::kReset);

    // colorFile;
    aColorFile = typedAttr.create("colorFile", "cf", MFnData::kString);
    typedAttr.setInternal(true);

    // displacementFile;
    aDisplacementFile = typedAttr.create("displacementFile", "df", MFnData::kString);
    typedAttr.setInternal(true);

    // occlusionFile;
    aOcclusionFile = typedAttr.create("occlusionFile", "of", MFnData::kString);
    typedAttr.setInternal(true);

    // enableDisplacement;
    aEnableDisplacement = numAttr.create("enableDisplacement", "end", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableColor;
    aEnableColor = numAttr.create("enableColor", "enc", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableOcclusion;
    aEnableOcclusion = numAttr.create("enableOcclusion", "eno", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableNormal;
    aEnableNormal = numAttr.create("enableNormal", "enn", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // fresnelBias;
    aFresnelBias = numAttr.create("fresnelBias", "fb", MFnNumericData::kFloat, 0.2f);
    numAttr.setMin(0);
    numAttr.setMax(1);

    // fresnelScale;
    aFresnelScale = numAttr.create("fresnelScale", "fs", MFnNumericData::kFloat, 1.0f);
    numAttr.setMin(0);
    numAttr.setSoftMax(1);

    // fresnelPower;
    aFresnelPower = numAttr.create("fresnelPower", "fp", MFnNumericData::kFloat, 5.0f);
    numAttr.setMin(0);
    numAttr.setSoftMax(10);

    // shaderSource;
    aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString);
    typedAttr.setInternal(true);


    // add attributes
    addAttribute(aLevel);
    addAttribute(aTessFactor);
    addAttribute(aScheme);
    addAttribute(aKernel);
    addAttribute(aInterpolateBoundary);
    addAttribute(aAdaptive);
    addAttribute(aWireframe);

    addAttribute(aDiffuse);
    addAttribute(aAmbient);
    addAttribute(aSpecular);

    addAttribute(aShaderSource);

    addAttribute(aDiffuseEnvironmentMapFile);
    addAttribute(aSpecularEnvironmentMapFile);
    addAttribute(aColorFile);
    addAttribute(aDisplacementFile);
    addAttribute(aOcclusionFile);

    addAttribute(aEnableDisplacement);
    addAttribute(aEnableColor);
    addAttribute(aEnableOcclusion);
    addAttribute(aEnableNormal);

    addAttribute(aFresnelBias);
    addAttribute(aFresnelScale);
    addAttribute(aFresnelPower);

    return MS::kSuccess;
}
MStatus areaLightNode::initialize()
{
	MStatus stat;
	MFnNumericAttribute numAttr;

	areaLightColor=numAttr.createColor("LightColor","lico");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.5,0.5,0.5);

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

	areaSamples=numAttr.create("Samples","as",MFnNumericData::kInt,1);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0);
	numAttr.setMax(512); 

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

	addAttribute(areaLightColor);
	addAttribute(areaPower);
	addAttribute(areaSamples);
	addAttribute(areaMakeGeo);

	return stat;
}
Ejemplo n.º 14
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 values.
// The inputs are: input, scale, frames
// The outputs are: sineOutput, cosineOutput
//
MStatus circle::initialize()
{
	MFnNumericAttribute nAttr;
	MStatus				stat;

	// Setup the input attributes
	//
	input = nAttr.create( "input", "in", MFnNumericData::kFloat, 0.0,
			&stat );
	CHECK_MSTATUS( stat );
 	CHECK_MSTATUS( nAttr.setStorable( true ) );

	scale = nAttr.create( "scale", "sc", MFnNumericData::kFloat, 10.0,
			&stat );
	CHECK_MSTATUS( stat );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	frames = nAttr.create( "frames", "fr", MFnNumericData::kFloat, 48.0,
			&stat );
	CHECK_MSTATUS( stat );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	// Setup the output attributes
	//
	sOutput = nAttr.create( "sineOutput", "so", MFnNumericData::kFloat,
			0.0, &stat );
	CHECK_MSTATUS( stat );
	CHECK_MSTATUS( nAttr.setWritable( false ) );
	CHECK_MSTATUS( nAttr.setStorable( false ) );

	cOutput = nAttr.create( "cosineOutput", "co", MFnNumericData::kFloat,
			0.0, &stat );
	CHECK_MSTATUS( stat );
	CHECK_MSTATUS( nAttr.setWritable( false ) );
	CHECK_MSTATUS( nAttr.setStorable( false ) );

	// Add the attributes to the node
	//
	CHECK_MSTATUS( addAttribute( input ) );
	CHECK_MSTATUS( addAttribute( scale ) );
	CHECK_MSTATUS( addAttribute( frames ) );
	CHECK_MSTATUS( addAttribute( sOutput ) );
	CHECK_MSTATUS( addAttribute( cOutput ) );

	// Set the attribute dependencies
	//
	CHECK_MSTATUS( attributeAffects( input, sOutput ) );
	CHECK_MSTATUS( attributeAffects( input, cOutput ) );
	CHECK_MSTATUS( attributeAffects( scale, sOutput ) );
	CHECK_MSTATUS( attributeAffects( scale, cOutput ) );
	CHECK_MSTATUS( attributeAffects( frames, sOutput ) );
	CHECK_MSTATUS( attributeAffects( frames, cOutput ) );

	return MS::kSuccess;
} 
Ejemplo n.º 15
0
MStatus hwUnlitShader::initialize()
{
    MFnNumericAttribute nAttr; 
	MStatus status;
	MFnTypedAttribute sAttr; // For string attributes

    // Create COLOR 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);	// ugly pink-salmon color. You can't miss it.
    nAttr.setUsedAsColor(true);

    // Create TRANSPARENCY input attributes
	transparencyR = nAttr.create( "transparencyR", "itr",MFnNumericData::kFloat);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(1.0f);

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

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

    transparency = nAttr.create( "transparency", "it", transparencyR, transparencyG, transparencyB);
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0.0001f, 0.0001f, 0.0001f); // very light gray.
    nAttr.setUsedAsColor(true);

	// Add the attributes here
    addAttribute(color);
    addAttribute(transparency);


 // create output attributes here
	// outColor is the only output attribute and it is inherited
	// so we do not need to create or add it.
	//

    return MS::kSuccess;
}
Ejemplo n.º 16
0
MStatus	MayaToAppleseedGlobals::initialize()
{
	MayaRenderGlobalsNode::initialize();

	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat = MStatus::kSuccess;

	sampling_mode = eAttr.create("sampling_mode", "sampling_mode", 0, &stat);
	stat = eAttr.addField("qmc", 0);
	stat = eAttr.addField("rng", 1);
	CHECK_MSTATUS(addAttribute(sampling_mode));

	tile_ordering = eAttr.create("tile_ordering", "tile_ordering", 2, &stat);
	stat = eAttr.addField("linear", 0);
	stat = eAttr.addField("spiral", 1);
	stat = eAttr.addField("hilbert", 2);
	stat = eAttr.addField("random", 3);
	CHECK_MSTATUS(addAttribute(tile_ordering));

	bitdepth = eAttr.create( "bitdepth", "bitdepth", 3, &stat);
	stat = eAttr.addField( "8bit  Integer", 0 );
	stat = eAttr.addField( "16bit Integer", 1 );
	stat = eAttr.addField( "32bit Integer", 2 );
	stat = eAttr.addField( "16bit Float(Half)", 3 );
	stat = eAttr.addField( "32bit Float", 4 );
	stat = eAttr.addField( "64bit Double", 5 );
	CHECK_MSTATUS(addAttribute( bitdepth ));

	pixel_renderer = eAttr.create( "pixel_renderer", "pixel_renderer", 0, &stat);
	stat = eAttr.addField( "adaptive", 0 );
	stat = eAttr.addField( "uniform", 1 );
	CHECK_MSTATUS(addAttribute( pixel_renderer ));

	colorSpace = eAttr.create( "colorSpace", "colorSpace", 0, &stat);
	stat = eAttr.addField( "linear_rgb", 0 );
	stat = eAttr.addField( "srgb", 1 );
	stat = eAttr.addField( "ciexyz", 2 );
	CHECK_MSTATUS(addAttribute( colorSpace ));

	lightingEngine = eAttr.create( "lightingEngine", "lightingEngine", 0, &stat);
	stat = eAttr.addField( "Unidirectional Path tracing", 0 );
	stat = eAttr.addField( "Distributed Raytracing", 1 );
	stat = eAttr.addField( "Stochastic Progressive Photon Mapping", 2 );
	CHECK_MSTATUS(addAttribute( lightingEngine ));

	clamping = nAttr.create("clamping", "clamping",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( clamping ));

	maxError = nAttr.create("maxError", "maxError",  MFnNumericData::kFloat, 0.01f);
	CHECK_MSTATUS(addAttribute( maxError ));

	adaptiveQuality = nAttr.create("adaptiveQuality", "adaptiveQuality",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( adaptiveQuality ));
	
	enable_caustics = nAttr.create("enable_caustics", "enable_caustics",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( enable_caustics ));

	enable_dl = nAttr.create("enable_dl", "enable_ibl",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( enable_dl ));

	enable_diagnostics = nAttr.create("enable_diagnostics", "enable_diagnostics",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( enable_diagnostics ));

	diffuseDepth = nAttr.create("diffuseDepth", "diffuseDepth",  MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( diffuseDepth ));

	texCacheSize = nAttr.create("texCacheSize", "texCacheSize",  MFnNumericData::kInt, 512);
	CHECK_MSTATUS(addAttribute( texCacheSize ));

	frameRendererPasses = nAttr.create("frameRendererPasses", "frameRendererPasses",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( frameRendererPasses ));

	glossyDepth = nAttr.create("glossyDepth", "glossyDepth",  MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( glossyDepth ));

	environmentSamples = nAttr.create("environmentSamples", "environmentSamples",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( environmentSamples ));

	bsdfSamples = nAttr.create("bsdfSamples", "bsdfSamples",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( bsdfSamples ));

	next_event_estimation = nAttr.create("next_event_estimation", "next_event_estimation",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( next_event_estimation ));

	assemblySBVH = nAttr.create("assemblySBVH", "assemblySBVH",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( assemblySBVH ));

	max_path_length = nAttr.create("max_path_length", "max_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(max_path_length));

	rr_min_path_length = nAttr.create("rr_min_path_length", "rr_min_path_length",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( rr_min_path_length ));

	path_tracing_max_path_length = nAttr.create("path_tracing_max_path_length", "path_tracing_max_path_length", MFnNumericData::kFloat, 0.0f);
	CHECK_MSTATUS(addAttribute(path_tracing_max_path_length));

	path_tracing_rr_min_path_length = nAttr.create("path_tracing_rr_min_path_length", "path_tracing_rr_min_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(path_tracing_rr_min_path_length));

	photon_tracing_max_path_length = nAttr.create("photon_tracing_max_path_length", "photon_tracing_max_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(photon_tracing_max_path_length));

	photon_tracing_rr_min_path_length = nAttr.create("photon_tracing_rr_min_path_length", "photon_tracing_rr_min_path_length", MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute(photon_tracing_rr_min_path_length));

	max_ray_intensity = nAttr.create("max_ray_intensity", "max_ray_intensity",  MFnNumericData::kFloat, 0.0f);
	CHECK_MSTATUS(addAttribute( max_ray_intensity ));

	// reduced to auto because we do not need the others (I hope) remove the whole attribute in the next release
	assemblyExportType = eAttr.create( "assemblyExportType", "assemblyExportType", 0, &stat);
	stat = eAttr.addField( "Auto", 0 );
	CHECK_MSTATUS(addAttribute( assemblyExportType ));

	assemblyPolyTheshold = nAttr.create("assemblyPolyTheshold", "assemblyPolyTheshold",  MFnNumericData::kInt, 10000);
	CHECK_MSTATUS(addAttribute( assemblyPolyTheshold ));

	environmentType = eAttr.create( "environmentType", "environmentType", 0, &stat);
	stat = eAttr.addField("Constant", 0);
	stat = eAttr.addField("ConstantHemisphere", 1);
	stat = eAttr.addField("Gradient", 2);
	stat = eAttr.addField("Latitude Longitude", 3 );
	stat = eAttr.addField("Mirror Ball", 4 );
	stat = eAttr.addField("Physical Sky", 5);
	stat = eAttr.addField("OSL Environment", 6);
	CHECK_MSTATUS(addAttribute(environmentType));

	environmentColor = nAttr.createColor("environmentColor", "environmentColor");
	nAttr.setDefault(0.6f, 0.7f, 0.9f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( environmentColor ));

	gradientHorizon = nAttr.createColor("gradientHorizon", "gradientHorizon");
	nAttr.setDefault(0.8f, 0.8f, 0.9f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( gradientHorizon ));

	gradientZenit = nAttr.createColor("gradientZenit", "gradientZenit");
	nAttr.setDefault(0.2f, 0.3f, 0.6f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( gradientZenit ));

	environmentMap = nAttr.createColor("environmentMap", "environmentMap");
	nAttr.setDefault(0.6f, 0.7f, 0.9f);
	CHECK_MSTATUS(addAttribute( environmentMap ));

	environmentIntensity = nAttr.create("environmentIntensity", "environmentIntensity",  MFnNumericData::kFloat, 1.0f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( environmentIntensity ));

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

	latlongHoShift = nAttr.create("latlongHoShift", "latlongHoShift",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( latlongHoShift ));

	latlongVeShift = nAttr.create("latlongVeShift", "latlongVeShift",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( latlongVeShift ));

	AOVs = mAttr.create("AOVs", "AOVs");
	mAttr.setArray(true);
	mAttr.indexMatters(false);
	CHECK_MSTATUS(addAttribute( AOVs ));

	ground_albedo = nAttr.create("ground_albedo", "ground_albedo",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( ground_albedo ));

	horizon_shift = nAttr.create("horizon_shift", "horizon_shift",  MFnNumericData::kFloat, -0.05f);
	CHECK_MSTATUS(addAttribute( horizon_shift ));

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

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

	sun_phi = nAttr.create("sun_phi", "sun_phi",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( sun_phi ));

	sun_theta = nAttr.create("sun_theta", "sun_theta",  MFnNumericData::kFloat, 60.0f);
	CHECK_MSTATUS(addAttribute( sun_theta ));

	turbidity = nAttr.create("turbidity", "turbidity",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity ));

	turbidity_max = nAttr.create("turbidity_max", "turbidity_max",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity_max ));

	turbidity_min = nAttr.create("turbidity_min", "turbidity_min",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity_min ));

	skyModel = eAttr.create( "skyModel", "skyModel", 0, &stat);
	stat = eAttr.addField( "Preetham", 0 );
	stat = eAttr.addField( "Hosek", 1 );
	CHECK_MSTATUS(addAttribute( skyModel ));

	physicalSun = nAttr.create("physicalSun", "physicalSun",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( physicalSun ));

	physicalSunConnection = mAttr.create("physicalSunConnection", "physicalSunConnection");
	CHECK_MSTATUS(addAttribute( physicalSunConnection ));

	sunTurbidity = nAttr.create("sunTurbidity", "sunTurbidity",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( sunTurbidity ));

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

	sppmAlpha = nAttr.create("sppmAlpha", "sppmAlpha",  MFnNumericData::kFloat, .8f);
	CHECK_MSTATUS(addAttribute( sppmAlpha ));

	dl_mode = eAttr.create("dl_mode", "dl_mode", 0, &stat);
	stat = eAttr.addField("RT Direct Lighting", 0);
	stat = eAttr.addField("SPPM Direct Lighting", 1);
	stat = eAttr.addField("No Direct Lighting", 2);
	CHECK_MSTATUS(addAttribute(dl_mode));

	env_photons_per_pass = nAttr.create("env_photons_per_pass", "env_photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( env_photons_per_pass ));

	initial_radius = nAttr.create("initial_radius", "initial_radius",  MFnNumericData::kFloat, .5f);
	CHECK_MSTATUS(addAttribute( initial_radius ));

	light_photons_per_pass = nAttr.create("light_photons_per_pass", "light_photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( light_photons_per_pass ));

	max_photons_per_estimate = nAttr.create("max_photons_per_estimate", "max_photons_per_estimate",  MFnNumericData::kInt, 100);
	CHECK_MSTATUS(addAttribute( max_photons_per_estimate ));

	photons_per_pass = nAttr.create("photons_per_pass", "photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( photons_per_pass ));

	photon_type = eAttr.create("photon_type", "photon_type", 1, &stat);
	stat = eAttr.addField("Monochromatic", 0);
	stat = eAttr.addField("Polychromatic", 1);
	CHECK_MSTATUS(addAttribute(photon_type));

	return stat;

}
Ejemplo n.º 17
0
// Create and Add Attributes
//
//  Description:
//      This method is called to create and initialize all of the attributes
//      and attribute dependencies for this node type.  This is only called
//      once when the node type is registered with Maya.
//
//  Return Values:
//      MS::kSuccess
//      MS::kFailure
//
MStatus OsdPolySmooth::initialize() {

    MStatus stat;

    MFnCompoundAttribute  cAttr;
    MFnEnumAttribute      eAttr;
    MFnGenericAttribute   gAttr;
    MFnLightDataAttribute lAttr;
    MFnMatrixAttribute    mAttr;
    MFnMessageAttribute   msgAttr;
    MFnNumericAttribute   nAttr;
    MFnTypedAttribute     tAttr;
    MFnUnitAttribute      uAttr;

    // MAYA_NODE_BUILDER:BEG [ATTRIBUTE CREATION] ==========
    // a_inputPolymesh : This is a description for this attribute
    a_inputPolymesh = tAttr.create("inputPolymesh", "ip", MFnData::kMesh, MObject::kNullObj, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::inputPolymesh" );
    stat = tAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::inputPolymesh.setReadable()" );
    stat = tAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::inputPolymesh.setWritable()" );
    stat = tAttr.setHidden(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::inputPolymesh.setHidden()" );
    stat = addAttribute( a_inputPolymesh );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_inputPolymesh)" );

    // a_output : This is a description for this attribute
    a_output = tAttr.create("output", "out", MFnData::kMesh, MObject::kNullObj, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::output" );
    stat = tAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::output.setReadable()" );
    stat = tAttr.setWritable(false);
    MCHECKERR( stat, "cannot OsdPolySmooth::output.setWritable()" );
    stat = tAttr.setHidden(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::output.setHidden()" );
    stat = addAttribute( a_output );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_output)" );

    // a_subdivisionLevels : The number of recursive quad subdivisions to perform on each face.
    a_subdivisionLevels = nAttr.create("subdivisionLevels", "sl", MFnNumericData::kInt, 0.0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::subdivisionLevels" );
    stat = nAttr.setDefault(2);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setDefault(2)" );
    stat = nAttr.setMin(0);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setMin(0)" );
    stat = nAttr.setMax(10);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setMax(10)" );
    stat = nAttr.setSoftMax(4);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setSoftMax(4)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::subdivisionLevels.setWritable()" );
    stat = addAttribute( a_subdivisionLevels );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_subdivisionLevels)" );

    // a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul>
    a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::vertBoundaryMethod" );
    stat = eAttr.addField("Interpolate Edges", k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot OsdPolySmooth::vertBoundaryMethod.addField(Interpolate Edges, k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.addField("Interpolate Edges And Corners", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner);
    MCHECKERR( stat, "cannot OsdPolySmooth::vertBoundaryMethod.addField(Interpolate Edges And Corners, k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" );
    stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot OsdPolySmooth::vertBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::vertBoundaryMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::vertBoundaryMethod.setWritable()" );
    stat = addAttribute( a_vertBoundaryMethod );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_vertBoundaryMethod)" );

    // a_fvarBoundaryMethod : Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). <ul> <li>Bi-linear (None): Renderman: InterpolateBoundaryNone</li> <li>Smooth, (Edge Only): Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, (Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> <li>Smooth, (ZBrush and Maya "Smooth Internal Only"): Renderman: InterpolateBoundaryAlwaysSharp</li> </ul>
    a_fvarBoundaryMethod = eAttr.create("fvarBoundaryMethod", "fvbm", 0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::fvarBoundaryMethod" );
    stat = eAttr.addField("Bi-linear (None)", k_BoundaryMethod_InterpolateBoundaryNone);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.addField(Bi-linear (None), k_BoundaryMethod_InterpolateBoundaryNone)" );
    stat = eAttr.addField("Smooth (Edge Only)", k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge Only), k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.addField("Smooth (Edge and Corner)", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge and Corner), k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" );
    stat = eAttr.addField("Smooth (Always Sharp)", k_BoundaryMethod_InterpolateBoundaryAlwaysSharp);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.addField(Smooth (Always Sharp), k_BoundaryMethod_InterpolateBoundaryAlwaysSharp)" );
    stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryNone);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryNone)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarBoundaryMethod.setWritable()" );
    stat = addAttribute( a_fvarBoundaryMethod );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_fvarBoundaryMethod)" );

    // a_fvarPropagateCorners :
    a_fvarPropagateCorners = nAttr.create("fvarPropagateCorners", "fvpc", MFnNumericData::kBoolean, 0.0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::fvarPropagateCorners" );
    stat = nAttr.setDefault(false);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarPropagateCorners.setDefault(false)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarPropagateCorners.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::fvarPropagateCorners.setWritable()" );
    stat = addAttribute( a_fvarPropagateCorners );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_fvarPropagateCorners)" );

    // a_smoothTriangles : Apply a special subdivision rule be applied to all triangular faces that was empirically determined to make triangles subdivide more smoothly.
    a_smoothTriangles = nAttr.create("smoothTriangles", "stri", MFnNumericData::kBoolean, 0.0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::smoothTriangles" );
    stat = nAttr.setDefault(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::smoothTriangles.setDefault(true)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::smoothTriangles.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::smoothTriangles.setWritable()" );
    stat = addAttribute( a_smoothTriangles );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_smoothTriangles)" );

    // a_creaseMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Normal</li> <li>Chaikin: Improves the appearance of multiedge creases with varying weight</li> </ul>
    a_creaseMethod = eAttr.create("creaseMethod", "crm", 0, &stat);
    MCHECKERR( stat, "cannot create OsdPolySmooth::creaseMethod" );
    stat = eAttr.addField("Normal", k_creaseMethod_normal);
    MCHECKERR( stat, "cannot OsdPolySmooth::creaseMethod.addField(Normal, k_creaseMethod_normal)" );
    stat = eAttr.addField("Chaikin", k_creaseMethod_chaikin);
    MCHECKERR( stat, "cannot OsdPolySmooth::creaseMethod.addField(Chaikin, k_creaseMethod_chaikin)" );
    stat = eAttr.setDefault(0);
    MCHECKERR( stat, "cannot OsdPolySmooth::creaseMethod.setDefault(0)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::creaseMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot OsdPolySmooth::creaseMethod.setWritable()" );
    stat = addAttribute( a_creaseMethod );
    MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_creaseMethod)" );

    // MAYA_NODE_BUILDER:END [ATTRIBUTE CREATION] ==========


    // 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.
    //
    // MAYA_NODE_BUILDER:BEG [ATTRIBUTE DEPENDS] ==========
    stat = attributeAffects( a_creaseMethod, a_output );
    MCHECKERR( stat, "cannot have attribute creaseMethod affect output" );
    stat = attributeAffects( a_inputPolymesh, a_output );
    MCHECKERR( stat, "cannot have attribute inputPolymesh affect output" );
    stat = attributeAffects( a_subdivisionLevels, a_output );
    MCHECKERR( stat, "cannot have attribute subdivisionLevels affect output" );
    stat = attributeAffects( a_smoothTriangles, a_output );
    MCHECKERR( stat, "cannot have attribute smoothTriangles affect output" );
    stat = attributeAffects( a_fvarPropagateCorners, a_output );
    MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect output" );
    stat = attributeAffects( a_vertBoundaryMethod, a_output );
    MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect output" );
    stat = attributeAffects( a_fvarBoundaryMethod, a_output );
    MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect output" );
    // MAYA_NODE_BUILDER:END [ATTRIBUTE DEPENDS] ==========

    return MS::kSuccess;
}
Ejemplo n.º 18
0
MStatus hingeConstraintNode::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")

    ia_lowerLimit = fnNumericAttr.create("lowerLimit", "llmt", MFnNumericData::kDouble, -1.57, &status);
    MCHECKSTATUS(status, "creating lower limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerLimit);
    MCHECKSTATUS(status, "adding lower limit attribute")

	ia_upperLimit = fnNumericAttr.create("upperLimit", "ulmt", MFnNumericData::kDouble, 1.57, &status);
    MCHECKSTATUS(status, "creating upper limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperLimit);
    MCHECKSTATUS(status, "adding upper limit attribute")

	ia_limitSoftness = fnNumericAttr.create("limitSoftness", "lmSo", MFnNumericData::kDouble, 0.9, &status);
    MCHECKSTATUS(status, "creating limitSoftness attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_limitSoftness);
    MCHECKSTATUS(status, "adding limitSoftness attribute")

	ia_biasFactor = fnNumericAttr.create("biasFactor", "biFa", MFnNumericData::kDouble, 0.3, &status);
    MCHECKSTATUS(status, "creating biasFactor attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_biasFactor);
    MCHECKSTATUS(status, "adding biasFactor attribute")

	ia_relaxationFactor = fnNumericAttr.create("relaxationFactor", "reFa", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating relaxationFactor attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_relaxationFactor);
    MCHECKSTATUS(status, "adding relaxationFactor attribute")

	ia_hingeAxis = fnNumericAttr.createPoint("hingeAxis", "hgAx", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 1.0);
    MCHECKSTATUS(status, "creating hingeAxis attribute")
    status = addAttribute(ia_hingeAxis);
    MCHECKSTATUS(status, "adding hingeAxis attribute")

	//------------------------------------------------------------------------------
	
	ia_enableAngularMotor = fnNumericAttr.create("enableAngularMotor", "enAM", MFnNumericData::kBoolean, false, &status);
    MCHECKSTATUS(status, "creating enableAngularMotor attribute")
    status = addAttribute(ia_enableAngularMotor);
    MCHECKSTATUS(status, "adding enableAngularMotor attribute")

    ia_motorTargetVelocity = fnNumericAttr.create("motorTargetVelocity", "mTV", MFnNumericData::kDouble, 1, &status);
    MCHECKSTATUS(status, "creating motorTargetVelocity attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_motorTargetVelocity);
    MCHECKSTATUS(status, "adding motorTargetVelocity attribute")

	ia_maxMotorImpulse = fnNumericAttr.create("maxMotorImpulse", "mMI", MFnNumericData::kDouble, 1, &status);
    MCHECKSTATUS(status, "creating maxMotorImpulse attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_maxMotorImpulse);
    MCHECKSTATUS(status, "adding maxMotorImpulse 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)")

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

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

	status = attributeAffects(ia_limitSoftness, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_limitSoftness, ca_constraintParam)")
	status = attributeAffects(ia_biasFactor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_biasFactor, ca_constraintParam)")
	status = attributeAffects(ia_relaxationFactor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_relaxationFactor, ca_constraintParam)")

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

	status = attributeAffects(ia_enableAngularMotor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_enableAngularMotor, ca_constraintParam)")
	status = attributeAffects(ia_motorTargetVelocity, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_motorTargetVelocity, ca_constraintParam)")
	status = attributeAffects(ia_maxMotorImpulse, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_maxMotorImpulse, ca_constraintParam)")

	return MS::kSuccess;
}
Ejemplo n.º 19
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;
}
Ejemplo n.º 20
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 PhysicalsunNode::initialize()
{
    MFnTypedAttribute   tAttr;
    MFnStringData       tDefault;
    MFnNumericAttribute nAttr;
    MFnEnumAttribute    eAttr;
    MFnLightDataAttribute lAttr;
    MStatus status;
    MObject string;

    // Create input attributes
    aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, tDefault.create(getTypeName()), &status );
    MAKE_INPUT(tAttr);

    aRmanShaderType = tAttr.create( MString("rmanShaderType"), MString("rst"), MFnData::kString, tDefault.create(getShaderClasscification()), &status );
    MAKE_INPUT(tAttr);

    aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status );
    MAKE_INPUT(tAttr);

    aRmanShaderLif = tAttr.create(  MString("rmanShaderLif"),  MString("lif"), MFnData::kString, aRmanShaderLif, &status );
    MAKE_INPUT(tAttr);

    aRmanParams = tAttr.create(  MString("rmanParams"),  MString("rpr"), MFnData::kStringArray, aRmanParams, &status );
    MAKE_INPUT(tAttr);

    aRmanDetails = tAttr.create(  MString("rmanDetails"),  MString("rdt"), MFnData::kStringArray, aRmanDetails, &status );
    MAKE_INPUT(tAttr);

    aRmanTypes = tAttr.create(  MString("rmanTypes"),  MString("rty"), MFnData::kStringArray, aRmanTypes, &status );
    MAKE_INPUT(tAttr);

    aRmanDefaults = tAttr.create(  MString("rmanDefaults"),  MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status );
    MAKE_INPUT(tAttr);

    aRmanArraySizes = tAttr.create(  MString("rmanArraySizes"),  MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status );
    MAKE_INPUT(tAttr);

    aRmanLifCmds = tAttr.create(  MString("rmanLifCmds"),  MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status );
    MAKE_INPUT(tAttr);

    aRmanMethods = tAttr.create(  MString("rmanMethods"),  MString("rmt"), MFnData::kStringArray, aRmanMethods, &status );
    MAKE_INPUT(tAttr);

    aRmanIsOutput = tAttr.create(  MString("rmanIsOutput"),  MString("rio"), MFnData::kIntArray, aRmanIsOutput, &status );
    MAKE_INPUT(tAttr);

    aRmanAccept = tAttr.create(  MString("rmanAccept"),  MString("rma"), MFnData::kStringArray, aRmanAccept, &status );
    MAKE_INPUT(tAttr);


    aOutColor = nAttr.createColor("outColor", "oc");
    MAKE_OUTPUT(nAttr);
    aOutTransparency = nAttr.createColor("outTransparency", "ot");
    MAKE_OUTPUT(nAttr);

    IfMErrorWarn( addAttribute( aRmanShader ) );
    IfMErrorWarn( addAttribute( aRmanShaderType ) );
    IfMErrorWarn( addAttribute( aRmanShaderLong ) );
    IfMErrorWarn( addAttribute( aRmanShaderLif ) );
    IfMErrorWarn( addAttribute( aRmanParams ) );
    IfMErrorWarn( addAttribute( aRmanDetails ) );
    IfMErrorWarn( addAttribute( aRmanTypes ) );
    IfMErrorWarn( addAttribute( aRmanDefaults ) );
    IfMErrorWarn( addAttribute( aRmanArraySizes ) );
    IfMErrorWarn( addAttribute( aRmanLifCmds ) );
    IfMErrorWarn( addAttribute( aRmanMethods) );
    IfMErrorWarn( addAttribute( aRmanIsOutput) );
    IfMErrorWarn( addAttribute( aRmanAccept) );

    IfMErrorWarn( addAttribute( aOutColor ) );
    IfMErrorWarn( addAttribute( aOutTransparency ) );

    initialize_shader_parameters();

    return MS::kSuccess;
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
0
MStatus LSystemNode::initialize()
{
	MFnUnitAttribute unitAttr;
	MFnTypedAttribute typedAttr;

	MFnNumericAttribute angleNumAttr;
	MFnNumericAttribute stepNumAttr;

	MFnTypedAttribute grammarTypedAttr;

	MStatus returnStatus;

	LSystemNode::time = unitAttr.create( "time", "tm",
		MFnUnitAttribute::kTime,
		0.0, &returnStatus );
	McheckErr(returnStatus, "ERROR creating LSystemNode time attribute\n");


	LSystemNode::outputMesh = typedAttr.create( "outputMesh", "out",
		MFnData::kMesh,
		&returnStatus ); 
	McheckErr(returnStatus, "ERROR creating LSystemNode output attribute\n");
	typedAttr.setStorable(false);

	LSystemNode::angle = angleNumAttr.create( "angle", "a",
		MFnNumericData::kDouble, 90.0 );
	McheckErr(returnStatus, "ERROR creating LSystemNode angle attribute\n");

	LSystemNode::steps = stepNumAttr.create( "steps", "s",
		MFnNumericData::kDouble, 1.0 );
	McheckErr(returnStatus, "ERROR creating LSystemNode step size attribute\n");

	LSystemNode::grammar = grammarTypedAttr.create( "grammar", "g",
		MFnData::kString, &returnStatus );
	McheckErr(returnStatus, "ERROR creating LSystemNode grammar attribute\n");
	grammarTypedAttr.setStorable(false);


	returnStatus = addAttribute(LSystemNode::time);
	McheckErr(returnStatus, "ERROR adding time attribute\n");

	returnStatus = addAttribute(LSystemNode::outputMesh);
	McheckErr(returnStatus, "ERROR adding outputMesh attribute\n");

	returnStatus = addAttribute(LSystemNode::angle);
	McheckErr(returnStatus, "ERROR adding angle attribute\n");

	returnStatus = addAttribute(LSystemNode::steps);
	McheckErr(returnStatus, "ERROR adding steps attribute\n");

	returnStatus = addAttribute(LSystemNode::grammar);
	McheckErr(returnStatus, "ERROR adding grammar attribute\n");



	returnStatus = attributeAffects(LSystemNode::time,
		LSystemNode::outputMesh);
	returnStatus = attributeAffects(LSystemNode::angle,
		LSystemNode::outputMesh);
	returnStatus = attributeAffects(LSystemNode::grammar,
		LSystemNode::outputMesh);
	returnStatus = attributeAffects(LSystemNode::steps,
		LSystemNode::outputMesh);
	McheckErr(returnStatus, "ERROR in attributeAffects\n");

	return MS::kSuccess;
}
Ejemplo n.º 24
0
// initializes attribute information
MStatus myComp::initialize()
{
    MFnNumericAttribute nAttr; 

    // Create input attributes

    aForegroundColor = nAttr.createColor("foreground", "fg");
    MAKE_INPUT(nAttr);

    aBackgroundColor = nAttr.createColor("background", "bg");
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault(1., 1., 1.));

    aBackColor = nAttr.createColor("backColor", "bk");
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault(1., 1., 1.));

    aMask = nAttr.create( "mask", "ms", MFnNumericData::kFloat);
    CHECK_MSTATUS( nAttr.setMin(0.f));
    CHECK_MSTATUS( nAttr.setMax(1.f));
    MAKE_INPUT(nAttr);

	// Create output attributes here
    aOutColor = nAttr.createColor("outColor", "oc");
	MAKE_OUTPUT(nAttr);

    aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
	MAKE_OUTPUT(nAttr);

    // Add the attributes here
    CHECK_MSTATUS( addAttribute(aForegroundColor) );
    CHECK_MSTATUS( addAttribute(aBackgroundColor) );
    CHECK_MSTATUS( addAttribute(aBackColor) );
    CHECK_MSTATUS( addAttribute(aMask) );

    CHECK_MSTATUS( addAttribute(aOutColor) );
    CHECK_MSTATUS( addAttribute(aOutAlpha) );

    // all input affect the output color and alpha
    CHECK_MSTATUS( attributeAffects(aForegroundColor, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aForegroundColor, aOutAlpha) );

    CHECK_MSTATUS( attributeAffects(aBackgroundColor, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aBackgroundColor, aOutAlpha) );

    CHECK_MSTATUS( attributeAffects(aBackColor, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aBackColor, aOutAlpha) );

    CHECK_MSTATUS( attributeAffects(aMask, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aMask, aOutAlpha) );

    return MS::kSuccess;
}
Ejemplo n.º 25
0
MStatus squash::initialize()
{
	MFnNumericAttribute nAttr;
	MStatus				stat;

	lengthOriginal = nAttr.create( "lengthOriginal", "lo", MFnNumericData::kDouble, 1.0 );
	nAttr.setStorable(true);
	lengthModify = nAttr.create( "lengthModify", "lm", MFnNumericData::kDouble, 1.0 );
	nAttr.setStorable(true);
	squashRate = nAttr.create( "squashRate", "r", MFnNumericData::kDouble, 1.0 );
	nAttr.setStorable(true);
	forceValue = nAttr.create( "forceValue", "f", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	output = nAttr.create( "output", "o", MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	stat = addAttribute( lengthOriginal );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( lengthModify );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( squashRate );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( forceValue );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( output );
		if (!stat) { stat.perror("addAttribute"); return stat;}

	stat = attributeAffects( lengthOriginal, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( lengthModify, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( squashRate, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( forceValue, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}

	return MS::kSuccess;
}
Ejemplo n.º 26
0
MStatus Layered::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.
                    //

	baseShader = nAttr.createColor("baseShader", "baseShader");
	CHECK_MSTATUS(addAttribute(baseShader));

	layerWeight = nAttr.create("layerWeight", "layerWeight", MFnNumericData::kFloat, 0, &status);
	nAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerWeight));

	layerTexture = mAttr.create("layerTexture", "layerTexture");
	mAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerTexture));

	layerShader = nAttr.createColor("layerShader", "layerShader");
	nAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerShader));

	outColor = nAttr.createColor("outColor", "outColor");
	CHECK_MSTATUS(addAttribute(outColor));

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


	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));

	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(outColor));
	CHECK_MSTATUS(addAttribute(aOutTransparency));
	CHECK_MSTATUS(addAttribute(aNormalCamera));

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


	CHECK_MSTATUS(attributeAffects(layerTexture, outColor));
	CHECK_MSTATUS(attributeAffects(layerWeight, outColor));

	CHECK_MSTATUS(attributeAffects(aTranslucenceCoeff, outColor));
	CHECK_MSTATUS(attributeAffects(aDiffuseReflectivity, outColor));
	CHECK_MSTATUS(attributeAffects(aColor, outColor));
	CHECK_MSTATUS(attributeAffects(aInTransparency, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aInTransparency, outColor));
	CHECK_MSTATUS(attributeAffects(aIncandescence, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityR, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityB, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityG, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensity, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraX, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraY, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraZ, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCamera, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionX, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionY, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionZ, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirection, outColor));
	CHECK_MSTATUS(attributeAffects(aLightAmbient, outColor));
	CHECK_MSTATUS(attributeAffects(aLightSpecular, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDiffuse, outColor));
	CHECK_MSTATUS(attributeAffects(aLightShadowFraction, outColor));
	CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, outColor));
	CHECK_MSTATUS(attributeAffects(aLightBlindData, outColor));
	CHECK_MSTATUS(attributeAffects(aLightData, outColor));


    return( MS::kSuccess );
}
Ejemplo n.º 27
0
MStatus transCircle::initialize()
{
	MFnNumericAttribute nAttr;
	MStatus				stat;

	input = nAttr.create( "input", "in", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateX = nAttr.create( "inputTranslateX", "itX", 
									MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateY = nAttr.create( "inputTranslateY", "itY", 
									MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateZ = nAttr.create( "inputTranslateZ", "itZ", 
									MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslate = nAttr.create( "inputTranslate", "it", 
									inputTranslateX,
									inputTranslateY,
									inputTranslateZ );
	nAttr.setStorable(true);
	nAttr.setDefault(0.0,0.0,0.0);

	outputTranslateX = nAttr.create( "outputTranslateX", "otX",
									MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslateY = nAttr.create( "outputTranslateY", "otY",
									MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslateZ = nAttr.create( "outputTranslateZ", "otZ",
									MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslate = nAttr.create( "outputTranslate", "ot", 
									outputTranslateX,
									outputTranslateY,
									outputTranslateZ );
	nAttr.setWritable(false);
	nAttr.setStorable(true);
	nAttr.setDefault(0.0,0.0,0.0);

	scale = nAttr.create( "scale", "sc",
									MFnNumericData::kDouble, 10.0 );
	nAttr.setStorable(true);

	frames = nAttr.create( "frames", "fr",
									MFnNumericData::kDouble, 48.0 );
	nAttr.setStorable(true);

	stat = addAttribute( inputTranslate );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( input );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( scale );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( frames );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( outputTranslate );
		if (!stat) { stat.perror("addAttribute"); return stat;}

	stat = attributeAffects( inputTranslateX, outputTranslateX );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslateY, outputTranslateY );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslateZ, outputTranslateZ );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslate, outputTranslateX );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslate, outputTranslateY );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslate, outputTranslateZ );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( inputTranslate, outputTranslate );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( input, outputTranslateX );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( input, outputTranslateY );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( scale, outputTranslateX );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( scale, outputTranslateY );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( frames, outputTranslateX );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( frames, outputTranslateY );
		if (!stat) { stat.perror("attributeAffects"); return stat;}

	return MS::kSuccess;
}
Ejemplo n.º 28
0
// DESCRIPTION:
//
MStatus PtexColorNode::initialize()
{
	MStatus status;

	MFnNumericAttribute numericAttribute;

	// Input attributes

	MFnTypedAttribute fileNameAttribute;
	aPtexFileName = fileNameAttribute.create( "ptexFileName", "f", MFnData::kString );
	MAKE_INPUT( fileNameAttribute );
	fileNameAttribute.setConnectable(false);

	MFnEnumAttribute enumAttribute;
	aPtexFilterType = enumAttribute.create( "ptexFilterType", "t", 0, &status );
	MCHECKERROR( status, "create filterType attribute" );
	enumAttribute.addField( "Point",      0 );
	enumAttribute.addField( "Bilinear",   1 );
	enumAttribute.addField( "Box",        2 );
	enumAttribute.addField( "Gaussian",   3 );
	enumAttribute.addField( "Bicubic",    4 );
	enumAttribute.addField( "BSpline",    5 );
	enumAttribute.addField( "CatmullRom", 6 );
	enumAttribute.addField( "Mitchell",   7 );
	enumAttribute.setHidden( false );
	MAKE_INPUT( enumAttribute );
	enumAttribute.setConnectable(false);
	MCHECKERROR( status, "Error adding shapeType attribute." );

	MFnNumericAttribute filterSizeAttribute;
	aPtexFilterSize = filterSizeAttribute.create( "ptexFilterSize", "s", MFnNumericData::kFloat, 1.0 );
	MAKE_INPUT( filterSizeAttribute );
	filterSizeAttribute.setConnectable(false);

	// Implicit shading network attributes

	MObject child1 = numericAttribute.create( "uCoord", "u", MFnNumericData::kFloat);
	MObject child2 = numericAttribute.create( "vCoord", "v", MFnNumericData::kFloat);
	aUVPos = numericAttribute.create( "uvCoord", "uv", child1, child2);
	MAKE_INPUT( numericAttribute );
	CHECK_MSTATUS( numericAttribute.setHidden(true) );

	child1 = numericAttribute.create( "uvFilterSizeX", "fsx", MFnNumericData::kFloat);
	child2 = numericAttribute.create( "uvFilterSizeY", "fsy", MFnNumericData::kFloat);
	aUVSize = numericAttribute.create( "uvFilterSize", "fs", child1, child2 );
	MAKE_INPUT( numericAttribute );
	CHECK_MSTATUS( numericAttribute.setHidden(true) );

	// Output attributes
	aOutColor = numericAttribute.createColor("outColor", "oc");
	MAKE_OUTPUT(numericAttribute);

	// Add attributes to the node database.
	CHECK_MSTATUS( addAttribute(aPtexFileName) );
	CHECK_MSTATUS( addAttribute(aPtexFilterType) );
	CHECK_MSTATUS( addAttribute(aPtexFilterSize) );
	CHECK_MSTATUS( addAttribute(aUVPos) );
	CHECK_MSTATUS( addAttribute(aUVSize) );

	CHECK_MSTATUS( addAttribute(aOutColor) );

	// All input affect the output color
	CHECK_MSTATUS( attributeAffects( aPtexFileName,   aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aPtexFilterSize, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aPtexFilterType, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aUVPos,          aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aUVSize,         aOutColor ) );

	return MS::kSuccess;
}
Ejemplo n.º 29
0
MStatus CoatingMaterial::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 ------------------------------------
	backface_emit = nAttr.create("backface_emit", "backface_emit",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( backface_emit ));

	layer = nAttr.create("layer", "layer",  MFnNumericData::kInt, 0);
	CHECK_MSTATUS(addAttribute( layer ));

	iesProfile = tAttr.create("iesProfile", "iesProfile",  MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	CHECK_MSTATUS(addAttribute( iesProfile ));

	absorption = nAttr.createColor("absorption", "absorption");
	nAttr.setDefault(0,0,0);
	CHECK_MSTATUS(addAttribute( absorption ));

	base_emission = nAttr.createColor("base_emission", "base_emission");
	nAttr.setDefault(0.0,0.0,0.0);
	CHECK_MSTATUS(addAttribute( base_emission ));

	interference = nAttr.create("interference", "interference",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( interference ));

	displacement = nAttr.create("displacement", "displacement",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( displacement ));

	roughness = nAttr.create("roughness", "roughness",  MFnNumericData::kFloat, 0.01);
	CHECK_MSTATUS(addAttribute( roughness ));

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

	emission = nAttr.createColor("emission", "emission");
	nAttr.setDefault(0.0,0.0,0.0);
	CHECK_MSTATUS(addAttribute( emission ));

	normalMap = nAttr.createColor("normalMap", "normalMap");
	nAttr.setDefault(0,0,0);
	CHECK_MSTATUS(addAttribute( normalMap ));

	ior = nAttr.create("ior", "ior",  MFnNumericData::kFloat, 1.2);
	CHECK_MSTATUS(addAttribute( ior ));

	thickness = nAttr.create("thickness", "thickness",  MFnNumericData::kFloat, 0.01);
	CHECK_MSTATUS(addAttribute( thickness ));

//---------------------------- 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 );
}
Ejemplo n.º 30
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;
}