本文整理汇总了C++中MDataHandle::setMObject方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::setMObject方法的具体用法?C++ MDataHandle::setMObject怎么用?C++ MDataHandle::setMObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::setMObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: compute
MStatus TCC::compute(const MPlug& plug, MDataBlock& data)
{
MStatus stat;
if (plug == aOutputMesh) {
/* Get time */
int subdivRes = data.inputValue(aRes, &stat).asInt();
int subdivRefRes = data.inputValue(aRefRes, &stat).asInt();
float lineThickness = data.inputValue(aLineThickness, &stat).asFloat();
MDataHandle inMeshHandle = data.inputValue( aInputMesh, &stat ); McheckErr(stat,"ERROR getting attribute");
MObject inMeshObj = inMeshHandle.asMesh();
MFnMesh inMeshFn(inMeshObj);
MIntArray nFV, F;
inMeshFn.getVertices(nFV, F);
MIntArray nFVc = MFnIntArrayData( data.inputValue( anFVc ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray Fc = MFnIntArrayData( data.inputValue( aFc ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray pole = MFnIntArrayData( data.inputValue( aPole ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray corner = MFnIntArrayData( data.inputValue( aCorner ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray T = MFnIntArrayData( data.inputValue( aT ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray eqc = MFnIntArrayData( data.inputValue( aEqc ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MDoubleArray itv = MFnDoubleArrayData( data.inputValue( aItv ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
MIntArray err = MFnIntArrayData( data.inputValue( aErr ).data() ).array(&stat); McheckErr(stat,"ERROR getting attr");
TCCData tccData(nFV, F, nFVc, Fc, pole, corner, T, eqc, itv, err);
/* Get output object */
MDataHandle outMeshHandle = data.outputValue(aOutputMesh, &stat); McheckErr(stat, "ERROR getting attribute\n");
if (validTopology(tccData))
{
stat = createSubdividedMesh(subdivRes, subdivRefRes, inMeshFn, tccData, outMeshHandle, lineThickness, stat);
}
else
{
outMeshHandle.setMObject(inMeshObj);
MFnMesh outMeshFn(outMeshHandle.asMesh());
stat = setErrorColors(outMeshFn, tccData);
}
data.setClean( plug );
} else
return MS::kUnknownParameter;
return stat;
}
示例3: compute
MStatus ArrayAngleConstructorNode::compute(const MPlug& plug, MDataBlock& data)
{
if (plug != aOutput)
return MS::kUnknownParameter;
MStatus status;
int index;
MArrayDataHandle inputArrayHandle = data.inputArrayValue(aInput);
int inputSize = inputArrayHandle.elementCount();
int outputSize = data.inputValue(aSize).asInt();
MDoubleArray outputArray(outputSize);
MAngle::Unit uiUnit = MAngle::uiUnit();
for (int i = 0; i < inputSize; i++)
{
index = inputArrayHandle.elementIndex();
if (index >= outputSize) break;
if (uiUnit == MAngle::kRadians)
{
outputArray[index] = inputArrayHandle.inputValue().asAngle().asRadians();
} else {
outputArray[index] = inputArrayHandle.inputValue().asAngle().asDegrees();
}
if (!inputArrayHandle.next()) break;
}
MFnDoubleArrayData outputArrayData;
MObject outputData = outputArrayData.create(outputArray, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
MDataHandle outputHandle = data.outputValue(aOutput);
outputHandle.setMObject(outputData);
outputHandle.setClean();
return MS::kSuccess;
}
示例4: compute
MStatus ModifyArrayNode::compute(const MPlug& plug, MDataBlock& data)
{
if (plug != aOutput)
return MS::kUnknownParameter;
MStatus status;
MFnDoubleArrayData inputArray(data.inputValue(aInput).data());
short op = data.inputValue(aOperation).asShort();
bool reverse = data.inputValue(aReverse).asBool();
int inputSize = int(inputArray.length());
int outputSize = 0;
switch (op)
{
case kREFLECT_LEFT:
case kREFLECT_RIGHT:
outputSize = max(0, inputSize * 2 - 1);
break;
default:
outputSize = inputSize;
break;
}
std::vector<double> values = std::vector<double>(outputSize);
MDoubleArray outputArray(outputSize);
int index = 0;
switch (op)
{
case kNO_OP:
for (int i = 0; i < outputSize; i++)
values[i] = inputArray[i];
break;
case kSORT:
for (int i = 0; i < outputSize; i++)
values[i] = inputArray[i];
std::sort(values.begin(), values.end());
break;
case kABS:
for (int i = 0; i < outputSize; i++)
values[i] = abs(inputArray[i]);
break;
case kREFLECT_LEFT:
for (int i = inputSize - 1; i > 0; i--)
{
values[index] = inputArray[i];
index++;
}
for (int i = 0; i < inputSize; i++)
{
values[index] = inputArray[i];
index++;
}
break;
case kREFLECT_RIGHT:
for (int i = 0; i < inputSize - 1; i++)
{
values[index] = inputArray[i];
index++;
}
for (int i = inputSize - 1; i >= 0; i--)
{
values[index] = inputArray[i];
index++;
}
break;
}
for (int i = 0; i < outputSize; i++)
{
index = reverse ? outputSize - i - 1 : i;
outputArray[i] = values[index];
}
MDataHandle outputHandle = data.outputValue(this->aOutput);
MFnDoubleArrayData output;
MObject outputData = output.create(outputArray);
outputHandle.setMObject(outputData);
outputHandle.setClean();
return MS::kSuccess;
}
示例5: compute
MStatus geometrySurfaceConstraint::compute( const MPlug& plug, MDataBlock& block )
{
MStatus returnStatus;
if ( plug == geometrySurfaceConstraint::constraintGeometry )
{
//
block.inputValue(constraintParentInverseMatrix);
//
MArrayDataHandle targetArray = block.inputArrayValue( compoundTarget );
unsigned int targetArrayCount = targetArray.elementCount();
double weight,selectedWeight = 0;
if ( weightType == geometrySurfaceConstraintCommand::kSmallestWeight )
selectedWeight = FLT_MAX;
MObject selectedMesh;
unsigned int i;
for ( i = 0; i < targetArrayCount; i++ )
{
MDataHandle targetElement = targetArray.inputValue();
weight = targetElement.child(targetWeight).asDouble();
if ( !equivalent(weight,0.0))
{
if ( weightType == geometrySurfaceConstraintCommand::kLargestWeight )
{
if ( weight > selectedWeight )
{
MObject mesh = targetElement.child(targetGeometry).asMesh();
if ( !mesh.isNull() )
{
selectedMesh = mesh;
selectedWeight = weight;
}
}
}
else
{
if ( weight < selectedWeight )
{
MObject mesh = targetElement.child(targetGeometry).asMesh();
if ( !mesh.isNull() )
{
selectedMesh = mesh;
selectedWeight = weight;
}
}
}
}
targetArray.next();
}
//
if ( selectedMesh.isNull() )
{
block.setClean(plug);
}
else
{
// The transform node via the geometry attribute will take care of
// updating the location of the constrained geometry.
MDataHandle outputConstraintGeometryHandle = block.outputValue(constraintGeometry);
outputConstraintGeometryHandle.setMObject(selectedMesh);
}
}
else
{
return MS::kUnknownParameter;
}
return MS::kSuccess;
}