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


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

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


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

示例1: compute

// COMPUTE ======================================
MStatus gear_uToPercentage::compute(const MPlug& plug, MDataBlock& data)
{
	MStatus returnStatus;
	// Error check
    if (plug != percentage)
        return MS::kUnknownParameter;

	// Curve
	MFnNurbsCurve crv( data.inputValue( curve ).asNurbsCurve() );

	// Sliders
	bool in_normU = data.inputValue( normalizedU ).asBool();
	double in_u = (double)data.inputValue( u ).asFloat();
	unsigned in_steps = data.inputValue( steps ).asShort();

	// Process
	if (in_normU)
		in_u = normalizedUToU(in_u, crv.numCVs());

	// Get length
	MVectorArray u_subpos(in_steps);
	MVectorArray t_subpos(in_steps);
	MPoint pt;
	double step;
	for (unsigned i = 0; i < in_steps ; i++){

		step = i * in_u / (in_steps - 1.0);
		crv.getPointAtParam(step, pt, MSpace::kWorld);
		u_subpos[i] = MVector(pt);

        step = i/(in_steps - 1.0);
		crv.getPointAtParam(step, pt, MSpace::kWorld);
		t_subpos[i] = MVector(pt);

	}
	
	double u_length = 0;
	double t_length = 0;
	MVector v;
	for (unsigned i = 0; i < in_steps ; i++){
		if (i>0){
			v = u_subpos[i] - u_subpos[i-1];
			u_length += v.length();
			v = t_subpos[i] - t_subpos[i-1];
			t_length += v.length();
		}
	}

	double out_perc = (u_length / t_length) * 100;
		
	// Output
    MDataHandle h = data.outputValue( percentage );
    h.setDouble( out_perc );
    data.setClean( plug );

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

示例2: compute

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

    MStatus status;

    MDataHandle inputHandle = data.inputValue(aInput, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    MFnDoubleArrayData inputArrayData(inputHandle.data());
    MDoubleArray inputArray = inputArrayData.array();
    int numInputs = inputArray.length();

    short operation = data.inputValue(aOperation).asShort();

    double output = numInputs > 0 ? inputArray[0] : 0.0;

    if (operation == kLENGTH)
    {
        output = double(numInputs);
    } else {
        for (int i = 1; i < numInputs; i++)
        {
            output = computeOutput(output, inputArray[i], operation, status);

            if (!status)
            {
                reportComputeError(this, operation);
                break;
            }
        }
    }

    MDataHandle outputHandle = data.outputValue(this->aOutput);
    outputHandle.setDouble(output);
    outputHandle.setClean();

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

示例3: compute

// COMPUTE ======================================
MStatus gear_percentageToU::compute(const MPlug& plug, MDataBlock& data)
{
	MStatus returnStatus;
	// Error check
    if (plug != percentage)
        return MS::kUnknownParameter;
	
	// Curve
	MFnNurbsCurve crv( data.inputValue( curve ).asNurbsCurve() );

	// Sliders
	bool in_normU = data.inputValue( normalizedU ).asBool();
	double in_percentage = (double)data.inputValue( percentage ).asFloat() * .01;
	const unsigned in_steps = data.inputValue( steps ).asShort();

	// Process
	// Get length
	MVectorArray u_subpos(in_steps);
	MPoint pt;
	MDoubleArray u_list(in_steps);
	for(unsigned i = 0 ; i < in_steps ; i++ ){
		u_list[i] = normalizedUToU(i /(in_steps - 1.0), crv.numCVs());

		crv.getPointAtParam(u_list[i], pt, MSpace::kWorld);
		u_subpos[i] = MVector(pt);
	}
	
	
	double t_length = 0;
	MDoubleArray dist(in_steps);
	MVector v;
	for (unsigned i = 0; i < in_steps ; i++){
		if (i>0){
			v = u_subpos[i] - u_subpos[i-1];
			t_length += v.length();
			dist[i] = t_length;
		}
	}

	MDoubleArray u_perc(in_steps);
	for (unsigned i = 0; i < in_steps ; i++){
		u_perc[i] = dist[i] / t_length;
	}

	
    // Get closest indices
    unsigned index = findClosestInArray(in_percentage, u_perc);
	unsigned indexA, indexB;
    if (in_percentage <= u_perc[index]){
        indexA = abs(int(index));
        indexB = index;
		if ( indexA > indexB){
			indexA = indexB;
			indexB = indexA+1;
		}
	}
    else {
        indexA = index;
        indexB = index + 1;
	}
	
    // blend value
    double blend = set01range(in_percentage, u_perc[indexA], u_perc[indexB]);
            
    double out_u = linearInterpolate(u_list[indexA], u_list[indexB], blend);
        
    if (in_normU)
        out_u = uToNormalizedU(out_u, crv.numCVs());
	
	// Ouput
	MDataHandle h = data.outputValue( u );
    h.setDouble( out_u );
    data.setClean( plug );

	return MS::kSuccess;
}
开发者ID:kattkieru,项目名称:mgear,代码行数:77,代码来源:percentageToU.cpp


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