本文整理汇总了C++中MDataBlock::context方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataBlock::context方法的具体用法?C++ MDataBlock::context怎么用?C++ MDataBlock::context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataBlock
的用法示例。
在下文中一共展示了MDataBlock::context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAndSetRotation
//
// Calls applyRotationLocks && applyRotationLimits
// This method verifies that the passed value can be set on the
// rotate plugs. In the base class, limits as well as locking are
// checked by this method.
//
// The compute, validateAndSetValue, and rotateTo functions
// all use this method.
//
MStatus rockingTransformCheckNode::checkAndSetRotation(MDataBlock &block,
const MPlug& plug,
const MEulerRotation& newRotation,
MSpace::Space space )
{
const MDGContext context = block.context();
updateMatrixAttrs(context);
MStatus status = MS::kSuccess;
MEulerRotation outRotation = newRotation;
if (context.isNormal()) {
// For easy reading.
//
MPxTransformationMatrix *xformMat = baseTransformationMatrix;
// Get the current translation in transform space for
// clamping and locking.
//
MEulerRotation savedRotation =
xformMat->eulerRotation(MSpace::kTransform, &status);
ReturnOnError(status);
// Translate to transform space, since the limit test needs the
// values in transform space. The locking test needs the values
// in the same space as the savedR value - which is transform
// space as well.
//
status = baseTransformationMatrix->rotateTo(newRotation, space);
ReturnOnError(status);
outRotation = xformMat->eulerRotation(MSpace::kTransform, &status);
ReturnOnError(status);
// Now that everything is in the same space, apply limits
// and change the value to adhere to plug locking.
//
outRotation = applyRotationLimits(outRotation, block, &status);
ReturnOnError(status);
outRotation = applyRotationLocks(outRotation, savedRotation, &status);
ReturnOnError(status);
// The value that remain is in transform space.
//
status = xformMat->rotateTo(outRotation, MSpace::kTransform);
ReturnOnError(status);
// Get the value that was just set. It needs to be in transform
// space since it is used to set the datablock values at the
// end of this method. Getting the vaolue right before setting
// ensures that the transformation matrix and data block will
// be synchronized.
//
outRotation = xformMat->eulerRotation(MSpace::kTransform, &status);
ReturnOnError(status);
} else {
// Get the rotation for clamping and locking. This will get the
// rotate value in transform space.
//
double3 &s3 = block.inputValue(rotate).asDouble3();
MEulerRotation savedRotation(s3[0], s3[1], s3[2]);
// Create a local transformation matrix for non-normal context
// calculations.
//
MPxTransformationMatrix *local = createTransformationMatrix();
if (NULL == local) {
MGlobal::displayError("rockingTransformCheck::checkAndSetRotation internal error");
return status;
}
// Fill the newly created transformation matrix.
//
status = computeLocalTransformation(local, block);
if ( MS::kSuccess != status)
{
delete local;
return status;
}
// Translate the values to transform space. This will allow the
// limit and locking tests to work properly.
//
status = local->rotateTo(newRotation, space);
if ( MS::kSuccess != status)
{
delete local;
return status;
}
outRotation = local->eulerRotation(MSpace::kTransform, &status);
//.........这里部分代码省略.........