Exemplo n.º 1
0
MStatus DynamicEnum::initialize()
{
	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnStringData sData;
	MStatus status; // Status will be used to hold the MStatus value

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

	// Attribute Initialization:
	aFilePath = tAttr.create( "filepath", "file", MFnData::kString, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( tAttr.setKeyable( true ) );
	CHECK_MSTATUS( tAttr.setStorable( true ) );
	CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) );

	aGridName = tAttr.create( "grid", "grd", MFnData::kString, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( tAttr.setKeyable( true ) );
	CHECK_MSTATUS( tAttr.setStorable( true ) );
	CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) );

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

	// Next we will add the attributes we have defined to the node
	//
	CHECK_MSTATUS( addAttribute( aFilePath ) );
	CHECK_MSTATUS( addAttribute( aGridName ) );
	CHECK_MSTATUS( addAttribute( aOutColor ) );

	// 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( aFilePath, aOutColor ) );
	CHECK_MSTATUS( attributeAffects( aGridName, aOutColor ) );

	return( MS::kSuccess );
}
Exemplo n.º 2
0
MStatus EntityInstanceNode::Initialize()
{
    MAYA_START_EXCEPTION_HANDLING();

    MStatus stat;

    // wtf is this - rachel
    MFnStringData dataFn;
    MObject stringData = dataFn.create( "" );

    // fileName attribute
    MFnTypedAttribute tAttr;
    s_ArtFilePath = tAttr.create("ArtFilePath", "fn", MFnData::kString, &stat);
    tAttr.setDefault( stringData );
    MCheckErr(stat, "Unable to create attr: ArtFilePath");

    tAttr.setReadable(true);
    tAttr.setWritable(false);

    stat = addAttribute(s_ArtFilePath);
    MCheckErr(stat, "Unable to add attr: ArtFilePath");

    MAYA_FINISH_EXCEPTION_HANDLING();

    return MS::kSuccess;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------
MStatus visualizeMeshNode::initialize()
//-----------------------------------------------------------------------
{ 
	MStatus				stat;
	MFnNumericAttribute	numericAttr;
	MFnTypedAttribute	typedAttr;



//!!!####################################################
	//COLOR
//!!!####################################################

	vtxColorObj = numericAttr.createColor("aColor","col");
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	numericAttr.setDefault(1.0,0.0,0.1);


//!!!####################################################
	//COLOR2
//!!!####################################################

	vtxColorObj2 = numericAttr.createColor("aColor2","col2");
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	numericAttr.setDefault(1.0,0.785,0.0);


//!!!####################################################
	//DRAWING ENABLED
//!!!####################################################

	drawingEnabled = numericAttr.create( "drawingEnabled", "en",
									MFnNumericData::kBoolean, 1, &stat );
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	if (!stat) {
		stat.perror("create drawingEnabled attribute");
		return stat;
	}


	
	/* // Dieses Feature ist eigentlich ziemlich unnötig
//!!!####################################################
	//SHOW ORIGINAL MESH
//!!!####################################################

	showOriginalObj = numericAttr.create( "showOriginal", "so",
									MFnNumericData::kBoolean, 1, &stat );
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	if (!stat) {
		stat.perror("create showOriginal attribute");
		return stat;
	}
	*/

//!!!####################################################
	//POINTSIZE
//!!!####################################################

	pointSize = numericAttr.create( "pointSize", "ps",
									MFnNumericData::kFloat, 10.0, &stat );
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	if (!stat) {
		stat.perror("create pointSize attribute");
		return stat;
	}
	

//!!!####################################################
	//INPUT MESH
//!!!####################################################

	inputMesh = typedAttr.create( "inputMesh", "is",
							 MFnMeshData::kMesh, &stat);
	if (!stat) {
		stat.perror("create inputMesh attribute");
		return stat;
	}


//!!!####################################################
	//VTXLOCATIONS (DUMMY OUT)
//!!!####################################################
	
	vtxLocations = numericAttr.create( "vtxLocations", "cv",
							 MFnNumericData::kBoolean,1, &stat);
	if (!stat) {
		stat.perror("create vtxLocations attribute");
		return stat;
	}



//!!!####################################################
	//VTXWEIGHTS
//!!!####################################################

	vtxWeights = typedAttr.create( "vtxWeights", "vw",
							 MFnData::kDoubleArray, &stat);
	if (!stat) {
		stat.perror("create vtxLocations attribute");
		return stat;
	}

	MFnDoubleArrayData	defaultWeights;
	typedAttr.setDefault(defaultWeights.create());
	
/*
//!!!####################################################
	//IN MATRIX (TRANSFORMATIONMATRIX FÜR DAS VTSSET)
//!!!####################################################
	//matrix

	matrixAttr = typedAttr.create( "inMatrix","imat", MFnData::kMatrix);

	MFnMatrixData	matrixData;
	typedAttr.setDefault(matrixData.create());
*/

#ifdef DEBUG
//!!!####################################################
	//DEBUG PARAMETER: FÜR POLYOFFSET
//!!!####################################################
	//matrix

	pOffset1Obj =	numericAttr.create( "offsetValue1", "ov1",
										MFnNumericData::kFloat, 0.45, &stat );
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	

	pOffset2Obj =	numericAttr.create( "offsetValue2", "ov2",
										MFnNumericData::kFloat, 0.55, &stat );
	numericAttr.setKeyable(true);
	numericAttr.setStorable(true);
	

#endif




	//Attribute hinzufügen
	//------------------------

	stat = addAttribute (drawingEnabled);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}

	stat = addAttribute (pointSize);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}

	stat = addAttribute (inputMesh);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}

	stat = addAttribute (vtxLocations);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}

	stat = addAttribute (vtxColorObj);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}

	stat = addAttribute (vtxColorObj2);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}
	

	stat = addAttribute (vtxWeights);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}
/*
	stat = addAttribute (matrixAttr);
		if (!stat) { stat.perror("addAttribute"); 
		return stat;}
*/

#ifdef DEBUG
		
		stat = addAttribute( pOffset1Obj );
		if (!stat) { stat.perror("addAttribute"); 
			return stat;}

		stat = addAttribute( pOffset2Obj );
		if (!stat) { stat.perror("addAttribute"); 
			return stat;}

#endif





	//Affections setzen
	//------------------------

	stat = attributeAffects(vtxWeights, vtxLocations );
		if (!stat) { stat.perror("attributeAffects"); 
		return stat;}


	stat = attributeAffects(inputMesh, vtxLocations );
		if (!stat) { stat.perror("attributeAffects"); 
		return stat;}
	

	// Die Parameter müssen die computeMethod aufrufen
#ifdef DEBUG
	
		stat = attributeAffects(pOffset1Obj, vtxLocations );
		if (!stat) { stat.perror("attributeAffects"); 
		return stat;}

		stat = attributeAffects(pOffset2Obj, vtxLocations );
		if (!stat) { stat.perror("attributeAffects"); 
		return stat;}

#endif

	return MS::kSuccess;
}
Exemplo n.º 4
0
MStatus cvColor::initialize()
{ 
	MStatus				stat;
	MFnNumericAttribute	numericAttr;
	MFnTypedAttribute	typedAttr;

	drawingEnabled = numericAttr.create( "drawingEnabled", "en",
									MFnNumericData::kBoolean, 1, &stat );
	if (!stat) {
		stat.perror("create drawingEnabled attribute");
		return stat;
	}

	pointSize = numericAttr.create( "pointSize", "ps",
									MFnNumericData::kFloat, 4.0, &stat );
	if (!stat) {
		stat.perror("create pointSize attribute");
		return stat;
	}
	
	inputSurface = typedAttr.create( "inputSurface", "is",
							 MFnNurbsSurfaceData::kNurbsSurface, &stat);
	if (!stat) {
		stat.perror("create inputSurface attribute");
		return stat;
	}

	cvLocations = typedAttr.create( "cvLocations", "cv",
							 MFnPointArrayData::kPointArray, &stat);
	if (!stat) {
		stat.perror("create cvLocations attribute");
		return stat;
	}

	MPointArray			defaultPoints;
	MFnPointArrayData	defaultArray;
	MObject				defaultAttr;

	defaultPoints.clear(); // Empty array
	defaultAttr = defaultArray.create (defaultPoints);
	stat = typedAttr.setDefault(defaultAttr);
	if (!stat) {
		stat.perror("could not create default output attribute");
		return stat;
	}

	stat = addAttribute (drawingEnabled);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (pointSize);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (inputSurface);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (cvLocations);
		if (!stat) { stat.perror("addAttribute"); return stat;}

	stat = attributeAffects( inputSurface, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( drawingEnabled, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( pointSize, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	
	return MS::kSuccess;
}