当前位置: 首页>>代码示例>>C++>>正文


C++ MDataHandle::setClean方法代码示例

本文整理汇总了C++中MDataHandle::setClean方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::setClean方法的具体用法?C++ MDataHandle::setClean怎么用?C++ MDataHandle::setClean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MDataHandle的用法示例。


在下文中一共展示了MDataHandle::setClean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compute

//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus depthShader::compute(
const MPlug&      plug,
      MDataBlock& block )
{
	// outColor or individial R, G, B channel
    if((plug != aOutColor) && (plug.parent() != aOutColor))
		return MS::kUnknownParameter;

	MFloatVector resultColor;

	// get sample surface shading parameters
	MFloatVector& pCamera = block.inputValue(aPointCamera).asFloatVector();
	MFloatVector& cNear   = block.inputValue(aColorNear).asFloatVector();
	MFloatVector& cFar    = block.inputValue(aColorFar).asFloatVector();
	float nearClip        = block.inputValue(aNear).asFloat();
	float farClip         = block.inputValue(aFar).asFloat();

	// pCamera.z is negative
	float ratio = (farClip + pCamera.z) / ( farClip - nearClip);
	resultColor = cNear * ratio + cFar*(1.f - ratio);

	// set ouput color attribute
	MDataHandle outColorHandle = block.outputValue( aOutColor );
	MFloatVector& outColor = outColorHandle.asFloatVector();
	outColor = resultColor;
	outColorHandle.setClean();

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:32,代码来源:depthShader.cpp

示例2: _initVertMapping_on_one_mesh

void TestDeformer::_initVertMapping_on_one_mesh( MObject &driver_mesh, MArrayDataBuilder &vertMapOutArrayBuilder, const MPointArray& allPts)
{
    MStatus status;

    // use vertIter to walk through the vertex of a driver mesh
    MItMeshVertex vertIter( driver_mesh, &status );
    CHECK_MSTATUS(status);
    CHECK_MSTATUS(vertIter.reset());

    // for each vertex of the driver mesh
    while( !vertIter.isDone(&status) )
    {
        CHECK_MSTATUS(status);

        // get vertex position
        MPoint driver_pt;
        driver_pt = vertIter.position( MSpace::kWorld, &status );
        CHECK_MSTATUS(status);

        //get the closest driven point
        int closest_pt_index = getClosestPt( driver_pt, allPts );//which one is the closest point(in allPts array) to driver_pt

        //add the closest driven point
        MDataHandle snapDataHnd = vertMapOutArrayBuilder.addElement( closest_pt_index, &status );
        CHECK_MSTATUS( status );
        snapDataHnd.setInt( vertIter.index() );
        snapDataHnd.setClean();

        CHECK_MSTATUS(vertIter.next());
    }
}
开发者ID:yaoyansi,项目名称:mymagicbox,代码行数:31,代码来源:testDeformer.cpp

示例3: compute

MStatus RemapArrayValuesNode::compute(const MPlug& plug, MDataBlock& data)
{
    if (plug != aOutput)
        return MS::kUnknownParameter;

    MStatus status;

    MFnDoubleArrayData input(data.inputValue(aInput).data());
    float inputMin = float(data.inputValue(aInputMin).asDouble());
    float inputMax = float(data.inputValue(aInputMax).asDouble());
    float outputMin = float(data.inputValue(aOutputMin).asDouble());
    float outputMax = float(data.inputValue(aOutputMax).asDouble());

    int size = input.length();
    MDoubleArray outputArray(size);
    
    MRampAttribute ramp(thisMObject(), aRamp, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    MFloatArray positions;
    MFloatArray values;
    MIntArray interps;
    MIntArray indices;

    ramp.getEntries(indices, positions, values, interps);

    int numIndices = indices.length();

    float inValue = 0.0;
    float outValue = 0.0;

    for (int i = 0; i < size; i++)
    {
        inValue = float(input[i]);
        
        inValue = remapValue(inValue, inputMin, inputMax);

        if (numIndices > 0)
        {
            ramp.getValueAtPosition(inValue, outValue, &status);
            CHECK_MSTATUS_AND_RETURN_IT(status);
        } else {
            outValue = inValue;
        }

        outValue = remapValue(outValue, 0.0, 1.0, outputMin, outputMax);

        outputArray.set(double(outValue), i);
    }

    MDataHandle outputHandle = data.outputValue(aOutput);
    MFnDoubleArrayData output;
    MObject outputData = output.create(outputArray);

    outputHandle.setMObject(outputData);
    outputHandle.setClean();

    return MS::kSuccess;
}
开发者ID:sonictk,项目名称:arrayNodes,代码行数:59,代码来源:n_remap.cpp

示例4: compute

//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus DispNode::compute(
const MPlug&      plug,
      MDataBlock& block ) 
{ 
    if ((plug == aOutColor) || (plug.parent() == aOutColor) ||
		(plug == aOutDisplacement))
	{
		MFloatVector resultColor(0.0,0.0,0.0);

		MFloatVector&  InputColor = block.inputValue( aColor ).asFloatVector();
		float MultValue = block.inputValue( aInputValue ).asFloat();

		resultColor = InputColor;

		float scalar = resultColor[0] + resultColor[1] + resultColor[2];
		if (scalar != 0.0) {
			scalar /= 3.0;
			scalar *= MultValue;
		}

		// set ouput color attribute
		MDataHandle outColorHandle = block.outputValue( aOutColor );
		MFloatVector& outColor = outColorHandle.asFloatVector();
		outColor = resultColor;
		outColorHandle.setClean();

		MDataHandle outDispHandle = block.outputValue( aOutDisplacement );
		float& outDisp = outDispHandle.asFloat();
		outDisp = scalar;
		outDispHandle.setClean( );
	}
	else if ((plug == aOutTransparency) || (plug.parent() == aOutTransparency))
	{
		// set output transparency to be opaque
		MFloatVector transparency(0.0,0.0,0.0);
		MDataHandle outTransHandle = block.outputValue( aOutTransparency );
		MFloatVector& outTrans = outTransHandle.asFloatVector();
		outTrans = transparency;
		outTransHandle.setClean( );
	}
	else
		return MS::kUnknownParameter;

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:48,代码来源:displacementShader.cpp

示例5: compute

//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus mtmEnvLight::compute(
const MPlug&      plug,
      MDataBlock& block ) 
{ 
    if ((plug != aLightData) && (plug.parent() != aLightData))
		return MS::kUnknownParameter;

    MFloatVector resultColor;

	// Real user input
    MFloatVector LColor(1,0,0);
    //MFloatVector& LColor  = block.inputValue( aColor ).asFloatVector();
    // MFloatVector& Position  = block.inputValue( aPosition ).asFloatVector();
    float LIntensity  = block.inputValue( aIntensity ).asFloat();

	// Components to build LightData
    MFloatVector& LDirection  = block.inputValue( aInputDirection ).asFloatVector();
    bool  LAmbient  = block.inputValue( aInputAmbient ).asBool();
    bool  LDiffuse  = block.inputValue( aInputDiffuse ).asBool();
    bool  LSpecular = block.inputValue( aInputSpecular ).asBool();


    resultColor = LColor * LIntensity;
  
    // set ouput color attribute
    MDataHandle outLightDataHandle = block.outputValue( aLightData );

    MFloatVector& outIntensity = outLightDataHandle.child(aLightIntensity).asFloatVector();
    outIntensity = resultColor;

    MFloatVector& outDirection = outLightDataHandle.child(aLightDirection).asFloatVector();

    outDirection = LDirection;

    bool& outAmbient = outLightDataHandle.child(aLightAmbient).asBool();
    outAmbient = LAmbient;
    bool& outDiffuse = outLightDataHandle.child(aLightDiffuse).asBool();
    outDiffuse = LDiffuse;
    bool& outSpecular = outLightDataHandle.child(aLightSpecular).asBool();
    outSpecular = LSpecular;

    float& outSFraction = outLightDataHandle.child(aLightShadowFraction).asFloat();
    outSFraction = 1.0f;

    float& outPSIntensity = outLightDataHandle.child(aPreShadowIntensity).asFloat();
    outPSIntensity = (resultColor[0] + resultColor[1] + resultColor[2]) / 3.0f;

	void*& outBlindData = outLightDataHandle.child(aLightBlindData).asAddr();
	outBlindData = NULL;

    outLightDataHandle.setClean();


    return MS::kSuccess;
}
开发者ID:MassW,项目名称:OpenMaya,代码行数:58,代码来源:mtm_envlight.cpp

示例6: compute

MStatus MG_curve::compute(const MPlug& plug,MDataBlock& dataBlock)
	{

		if (plug==output)
		{
			
			//MStatus
			MStatus stat;


			//Point array for the curve
			MPointArray pointArray ;

			//Get data from inputs
			MDataHandle degreeH = dataBlock.inputValue(degree);
			int degreeValue = degreeH.asInt();

			MDataHandle tmH = dataBlock.inputValue(transformMatrix);
			MMatrix tm = tmH.asMatrix();


			MArrayDataHandle inputMatrixH = dataBlock.inputArrayValue(inputMatrix);
			inputMatrixH.jumpToArrayElement(0);
			//Loop to get matrix data and convert in points

			for (int unsigned i=0;i<inputMatrixH.elementCount();i++,inputMatrixH.next())
			{
				

				MMatrix currentMatrix = inputMatrixH.inputValue(&stat).asMatrix() ;
				
				//Compensate the locator matrix
				
				MMatrix fixedMatrix = currentMatrix*tm.inverse();
				MPoint matrixP (fixedMatrix[3][0],fixedMatrix[3][1],fixedMatrix[3][2]);
				pointArray.append(matrixP);
				
			}
			
		MFnNurbsCurve curveFn;
		MFnNurbsCurveData curveDataFn;
		MObject curveData= curveDataFn.create();

		curveFn.createWithEditPoints(pointArray,degreeValue,MFnNurbsCurve::kOpen,0,0,0,curveData,&stat);
		
		MDataHandle outputH = dataBlock.outputValue(output);
		outputH.set(curveData);
		outputH.setClean();

		}


		return MS::kSuccess;
	}
开发者ID:bungnoid,项目名称:MG_Tools,代码行数:54,代码来源:MG_curve.cpp

示例7: compute

MStatus myComp::compute(const MPlug& plug, MDataBlock& block)
{
	// outColor or individial R, G, B channel
    if((plug != aOutColor) && (plug.parent() != aOutColor) &&
	   (plug != aOutAlpha))
		return MS::kUnknownParameter;

	MFloatVector resultColor;
	MFloatVector& fore = block.inputValue( aForegroundColor ).asFloatVector();
	MFloatVector& back = block.inputValue( aBackgroundColor ).asFloatVector();
	MFloatVector& bclr = block.inputValue( aBackColor ).asFloatVector();
	float& alpha = block.inputValue( aMask ).asFloat();

	if ( alpha > 0.99999f ) alpha = 1.f;
	else if ( alpha < 0.00001 )  alpha = 0.f;
	
	resultColor = fore + ((bclr - back) * (1.0f - alpha));

	// normalize output color
	if (resultColor[0] < 0.f )	resultColor[0] = 0.f;
	if (resultColor[1] < 0.f )	resultColor[1] = 0.f;
	if (resultColor[2] < 0.f )	resultColor[2] = 0.f;
	
	if (resultColor[0] > 1.f )	resultColor[0] = 1.f;
	if (resultColor[1] > 1.f )	resultColor[1] = 1.f;
	if (resultColor[2] > 1.f )	resultColor[2] = 1.f;

	// set ouput color attribute
	MDataHandle outColorHandle = block.outputValue( aOutColor );
	MFloatVector& outColor = outColorHandle.asFloatVector();
	outColor = resultColor;
	outColorHandle.setClean();
	
	MDataHandle outAlphaHandle = block.outputValue( aOutAlpha );
	float& outAlpha = outAlphaHandle.asFloat();
	outAlpha = ( resultColor.x + resultColor.y + resultColor.z ) / 3.0f;
	outAlphaHandle.setClean();

	return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:40,代码来源:compositingShader.cpp

示例8: compute

//
// This function gets called by Maya to evaluate the texture.
//
MStatus mySChecker::compute(const MPlug& plug, MDataBlock& block) 
{
	// outColor or individial R, G, B channel, or alpha
    if((plug != aOutColor) && (plug.parent() != aOutColor) && 
	   (plug != aOutAlpha))
		return MS::kUnknownParameter;

	MFloatVector resultColor;
	float3 & worldPos = block.inputValue(aPointWorld).asFloat3();
	MFloatMatrix& mat = block.inputValue(aPlaceMat).asFloatMatrix();
    float3 & bias = block.inputValue(aBias).asFloat3();

	MFloatPoint pos(worldPos[0], worldPos[1], worldPos[2]);
	pos *= mat;								// Convert into solid space

    // normalize the point
    int count = 0;
	if (pos.x - floor(pos.x) < bias[0]) count++;
	if (pos.y - floor(pos.y) < bias[1]) count++;
	if (pos.z - floor(pos.z) < bias[2]) count++;

    if (count & 1)
		resultColor = block.inputValue(aColor2).asFloatVector();
	else
		resultColor = block.inputValue(aColor1).asFloatVector();

	// Set ouput color attribute
	MDataHandle outColorHandle = block.outputValue( aOutColor );
	MFloatVector& outColor = outColorHandle.asFloatVector();
	outColor = resultColor;
	outColorHandle.setClean();

    // Set ouput alpha attribute
	MDataHandle outAlphaHandle = block.outputValue( aOutAlpha );
	float& outAlpha = outAlphaHandle.asFloat();
	outAlpha = ( count & 1) ? 1.0f : 0.0f;
	outAlphaHandle.setClean();

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:43,代码来源:solidCheckerShader.cpp

示例9: compute

MStatus liqDisplacementNode::compute( const MPlug& plug, MDataBlock& block )
{

  if( (plug == aDisplacement) || (plug.parent() == aDisplacement) ) {

    MDataHandle outDispHandle = block.outputValue( aDisplacement );
    outDispHandle.set( 0.0f );
    outDispHandle.setClean();

  } else return MS::kUnknownParameter;

  return MS::kSuccess;
}
开发者ID:virtualritz,项目名称:liquidmaya,代码行数:13,代码来源:liqDisplacementNode.cpp

示例10: compute

MStatus TestLightNode::compute( const MPlug& plug, MDataBlock& block )
{
	//CM_TRACE_FUNC("SkyLightNode::compute(job="<<plug.name()<<",block)");

	// outColor or individual R, G, B channel
	if( (plug == aOutColor)			|| (plug.parent() == aOutColor)		  ||
		(plug == aOutTransparency)	|| (plug.parent() == aOutTransparency)
		) 
	{

		// init shader
		MStatus status;
		MFloatVector& lightcolor  = block.inputValue(alightcolor).asFloatVector();


		//rendering begin (maya software)
		MFloatVector resultColor;
		resultColor = lightcolor;

		//rendering end

		// set ouput color attribute
		MDataHandle outColorHandle = block.outputValue( aOutColor, &status );
		IfMErrorWarn(status);
		outColorHandle.asFloatVector() = resultColor;
		outColorHandle.setClean();

		MDataHandle outTransHandle = block.outputValue( aOutTransparency, &status );
		IfMErrorWarn(status);
		outTransHandle.asFloatVector() = MFloatVector(0.0, 0.0, 0.0);
		outTransHandle.setClean();
	} 
	else {
		return MS::kUnknownParameter;
	}

	return MS::kSuccess;
}
开发者ID:maya2renderer,项目名称:maya2renderer,代码行数:38,代码来源:erTestLight_node.cpp

示例11: solidPos

//
// This function gets called by Maya to evaluate the texture.
//
MStatus noise3::compute(const MPlug& plug, MDataBlock& block) 
{
	// outColor or individial R, G, B channel, or alpha
    if((plug != aOutColor) && (plug.parent() != aOutColor) && 
	   (plug != aOutAlpha))
		return MS::kUnknownParameter;

	MFloatVector resultColor;
	MFloatVector & col1 = block.inputValue(aColor1).asFloatVector();
	MFloatVector & col2 = block.inputValue(aColor2).asFloatVector();
	
	float3 & worldPos = block.inputValue( aPointWorld ).asFloat3();
	MFloatMatrix& mat = block.inputValue( aPlaceMat ).asFloatMatrix();
	float& sc = block.inputValue( aScale ).asFloat();
	float& bi = block.inputValue( aBias ).asFloat();

	MFloatPoint solidPos(worldPos[0], worldPos[1], worldPos[2]);
	solidPos *= mat;						// Convert into solid space

	float val = fabsf( pnoise3( solidPos ) * sc + bi );
	if (val < 0.) val = 0.;
	if (val > 1.) val = 1.;
	resultColor = col1 * val + col2*(1-val);

	// Set output color attribute
	MDataHandle outColorHandle = block.outputValue( aOutColor );
	MFloatVector& outColor = outColorHandle.asFloatVector();
	outColor = resultColor;
	outColorHandle.setClean();

	MDataHandle outAlphaHandle = block.outputValue( aOutAlpha );
	float& outAlpha = outAlphaHandle.asFloat();
	outAlpha = val;
	outAlphaHandle.setClean();

    return MS::kSuccess;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:40,代码来源:noiseShader.cpp

示例12: compute

MStatus CheckerNode::compute(
const MPlug&      plug,
      MDataBlock& block )
{
	// outColor or individial R, G, B channel, or alpha
    if((plug != aOutColor) && (plug.parent() != aOutColor) &&
	   (plug != aOutAlpha))
		return MS::kUnknownParameter;

    MFloatVector resultColor;
    float2 & uv = block.inputValue( aUVCoord ).asFloat2();
    float2 & bias = block.inputValue( aBias ).asFloat2();

    int count = 0;
	if (uv[0] - floorf(uv[0]) < bias[0]) count++;
	if (uv[1] - floorf(uv[1]) < bias[1]) count++;

    if (count & 1)
        resultColor = block.inputValue( aColor2 ).asFloatVector();
    else
        resultColor = block.inputValue( aColor1 ).asFloatVector();

    // Set ouput color attribute
    MDataHandle outColorHandle = block.outputValue( aOutColor );
    MFloatVector& outColor = outColorHandle.asFloatVector();
    outColor = resultColor;
    outColorHandle.setClean();

    // Set ouput alpha attribute
	MDataHandle outAlphaHandle = block.outputValue( aOutAlpha );
	float& outAlpha = outAlphaHandle.asFloat();
	outAlpha = (count & 1) ? 1.f : 0.f;
	outAlphaHandle.setClean();

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:36,代码来源:checkerShader.cpp

示例13: compute

//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus InterpNode::compute(
const MPlug&      plug,
      MDataBlock& block ) 
{ 
    if ((plug != aOutColor) && (plug.parent() != aOutColor))
		return MS::kUnknownParameter;

    MFloatVector resultColor;

    MFloatVector& Side = block.inputValue( aColor1 ).asFloatVector();
    MFloatVector& Face = block.inputValue( aColor2 ).asFloatVector();
    MFloatVector& surfNorm = block.inputValue( aNormalCamera ).asFloatVector();
    MFloatVector& viewVector = block.inputValue(aPointCamera).asFloatVector();
    float power = block.inputValue( aInputValue ).asFloat();

    // Normalize the view vector
    CHECK_MSTATUS ( viewVector.normalize() );
	
    // find dot product
    float scalarNormal = (viewVector.x * surfNorm.x) + 
		(viewVector.y * surfNorm.y) +
		(viewVector.z * surfNorm.z);

    // take the absolute value
    if (scalarNormal < 0.0) scalarNormal = -scalarNormal;

    // Use InputValue to change interpolation 
    //     power == 1.0 linear
    //     power >= 0.0 use gamma function
    //
	float scalar;
    if (power > 0.0) {
        scalar = powf(scalarNormal, 1.0f / power);
    }
    else { scalar = 0.0; }

    // Interpolate the colors
    resultColor = Side + ((Face - Side) * scalar);

    // set ouput color attribute
    MDataHandle outColorHandle = block.outputValue( aOutColor );
    MFloatVector& outColor = outColorHandle.asFloatVector();
    outColor = resultColor;
    outColorHandle.setClean();

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:50,代码来源:interpShader.cpp

示例14: compute

//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus Gamma::compute(const MPlug &plug, MDataBlock &block)
{
    if ((plug != aOutColor) && (plug.parent() != aOutColor))
		return MS::kUnknownParameter;

    MFloatVector & icol = block.inputValue( aColor ).asFloatVector();
    MFloatVector & igam = block.inputValue( aGamma ).asFloatVector();

    MDataHandle och = block.outputValue( aOutColor );
    MFloatVector & ocol = och.asFloatVector();
    ocol[0]= powf(icol[0], 1.f/igam[0]);
    ocol[1]= powf(icol[1], 1.f/igam[1]);
    ocol[2]= powf(icol[2], 1.f/igam[2]);
    och.setClean();

    return MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:20,代码来源:gammaShader.cpp

示例15: compute

MStatus slopeShaderNode::compute(const MPlug & plug, MDataBlock & block )
//
//	Description:
//		Computes a color value  
//	from a surface noraml angle.
//
{ 
	if ((plug != aOutColor) && (plug.parent() != aOutColor))
		return MS::kUnknownParameter;

    MFloatVector resultColor;

    MFloatVector&  walkable = block.inputValue( aColor1 ).asFloatVector();
    MFloatVector&  nonWalkable = block.inputValue( aColor2 ).asFloatVector();
    MFloatVector&  surfaceNormal = block.inputValue( aTriangleNormalCamera ).asFloatVector();
	MFloatMatrix&  viewMatrix = block.inputValue( aMatrixEyeToWorld ).asFloatMatrix();
    float angle = block.inputValue( aAngle ).asFloat();

    // Normalize the view vector
	//
	surfaceNormal.normalize();
	MFloatVector WSVector = surfaceNormal * viewMatrix;
	
    // find dot product
	//
    float scalarNormal = WSVector * MFloatVector(0, 1, 0);

    // take the absolute value
	//
    if (scalarNormal < 0.0) scalarNormal *= -1.0;

	if(cos(angle*AWdegreesToRadians) < scalarNormal)
		resultColor = walkable;
	else
		resultColor = nonWalkable;

    // set ouput color attribute
	//
    MDataHandle outColorHandle = block.outputValue( aOutColor );
    MFloatVector& outColor = outColorHandle.asFloatVector();
    outColor = resultColor;
    outColorHandle.setClean();

    return MS::kSuccess;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:45,代码来源:slopeShaderNode.cpp


注:本文中的MDataHandle::setClean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。