本文整理汇总了C++中MDataHandle::asVector方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asVector方法的具体用法?C++ MDataHandle::asVector怎么用?C++ MDataHandle::asVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::asVector方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
MStatus sgMeshIntersect::compute( const MPlug& plug, MDataBlock& data )
{
MStatus status;
if( m_isDirtyMeshMatrix )
{
MDataHandle hInputMeshMatrix = data.inputValue( aInputMeshMatrix );
m_mtxMesh = hInputMeshMatrix.asMatrix();
m_mtxInvMesh = m_mtxMesh.inverse();
}
if( m_isDirtyMesh )
{
MDataHandle hInputMesh = data.inputValue( aInputMesh );
m_fnMesh.setObject( hInputMesh.asMesh() );
}
if( m_isDirtyPointDest )
{
MDataHandle hPointDest = data.inputValue( aPointDest );
m_pointDest = MPoint( hPointDest.asVector() ) * m_mtxInvMesh;
}
if( m_isDirtyPointSrc )
{
MDataHandle hPointSource = data.inputValue( aPointSource );
m_pointSource = MPoint( hPointSource.asVector() ) * m_mtxInvMesh;
}
m_rayDirection = m_pointDest - m_pointSource;
m_fnMesh.intersect( m_pointSource, m_rayDirection, m_pointsIntersect, &status );
if( !status ) return MS::kSuccess;
MDataHandle hParentInverse = data.inputValue( aParentInverseMatrix );
m_mtxParentInverse = hParentInverse.asMatrix();
MDataHandle hOutPoint = data.outputValue( aOutPoint );
hOutPoint.setMVector( m_pointsIntersect[0]*m_mtxMesh*m_mtxParentInverse );
return MS::kSuccess;
}
示例2: compute
MStatus retargetLocator::compute( const MPlug& plug, MDataBlock& data )
{
MStatus status;
MDataHandle hDiscMatrix = data.inputValue( aDiscMatrix );
MDataHandle hDiscAxis = data.inputValue( aDiscAxis );
MDataHandle hDiscAngle = data.inputValue( aDiscAngle );
MDataHandle hDiscDivision = data.inputValue( aDiscDivision );
MDataHandle hDiscOffset = data.inputValue( aDiscOffset );
MDataHandle hDiscSize = data.inputValue( aDiscSize );
MDataHandle hDiscActiveColor = data.inputValue( aDiscActiveColor );
MDataHandle hDiscLeadColor = data.inputValue( aDiscLeadColor );
MDataHandle hDiscDefaultColor = data.inputValue( aDiscDefaultColor );
MDataHandle hDiscFillAlpha = data.inputValue( aDiscFillAlpha );
MDataHandle hDiscLineAlpha = data.inputValue( aDiscLineAlpha );
discAxis = hDiscAxis.asInt();
discDivision = hDiscDivision.asInt();
discAngle = hDiscAngle.asDouble();
discSize = hDiscSize.asVector();
discOffset = hDiscOffset.asVector();
discActiveColor = hDiscActiveColor.asFloat3();
discLeadColor = hDiscLeadColor.asFloat3();
discDefaultColor = hDiscDefaultColor.asFloat3();
discFillAlpha = hDiscFillAlpha.asFloat();
discLineAlpha = hDiscLineAlpha.asFloat();
MArrayDataHandle hArrArrow = data.inputArrayValue( aArrow );
arrowNum = hArrArrow.elementCount();
inheritMatrix.setLength( arrowNum );
aimMatrix.setLength( arrowNum );
inputMeshObj.setLength( arrowNum );
startSize.setLength( arrowNum );
size.setLength( arrowNum );
activeColor.setLength( arrowNum );
leadColor.setLength( arrowNum );
defaultColor.setLength( arrowNum );
fillAlpha.setLength( arrowNum );
lineAlpha.setLength( arrowNum );
offset.setLength( arrowNum );
for( int i =0; i < arrowNum; i++ )
{
MDataHandle hArrow = hArrArrow.inputValue();
MDataHandle hInheritMatrix = hArrow.child( aInheritMatrix );
MDataHandle hAimMatrix = hArrow.child( aAimMatrix );
MDataHandle hInputMesh = hArrow.child( aInputMesh );
MDataHandle hStartSize = hArrow.child( aStartSize );
MDataHandle hSize = hArrow.child( aSize );
MDataHandle hActiveColor = hArrow.child( aActiveColor );
MDataHandle hLeadColor = hArrow.child( aLeadColor );
MDataHandle hDefaultColor = hArrow.child( aDefaultColor );
MDataHandle hFillAlpha = hArrow.child( aFillAlpha );
MDataHandle hLineAlpha = hArrow.child( aLineAlpha );
MDataHandle hOffset = hArrow.child( aOffset );
inheritMatrix[i] = hInheritMatrix.asBool();
aimMatrix[i] = hAimMatrix.asMatrix()*hDiscMatrix.asMatrix().inverse();
inputMeshObj[i] = hInputMesh.asMesh();
startSize[i] = hStartSize.asFloat();
size[i] = hSize.asFloat();
activeColor[i] = hActiveColor.asFloat3();
leadColor[i] = hLeadColor.asFloat3();
defaultColor[i] = hDefaultColor.asFloat3();
fillAlpha[i] = hFillAlpha.asFloat();
lineAlpha[i] = hLineAlpha.asFloat();
offset[i] = hOffset.asVector();
hArrArrow.next();
}
MDataHandle hOutput = data.outputValue( aOutput );
hOutput.set( 1.0 );
data.setClean( plug );
return MS::kSuccess;
}
示例3: compute
MStatus dgTransform::compute( const MPlug& plug, MDataBlock& data )
{
MStatus status;
MDataHandle hTranslate = data.inputValue( aTranslate, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hRotate = data.inputValue( aRotate, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hScale = data.inputValue( aScale, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hShear = data.inputValue( aShear, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hJointOrient = data.inputValue( aJointOrient, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hInputTranslate = data.inputValue( aInputTranslate, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hInputRotate = data.inputValue( aInputRotate, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hInputScale = data.inputValue( aInputScale, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MDataHandle hInputShear = data.inputValue( aInputShear, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
MPxTransformationMatrix inputMpxTrMtx;
MEulerRotation inputEulerRot( hInputRotate.asVector() );
inputMpxTrMtx.translateTo( hInputTranslate.asVector() );
inputMpxTrMtx.rotateTo( inputEulerRot );
inputMpxTrMtx.scaleTo( hInputScale.asVector() );
inputMpxTrMtx.shearTo( hInputShear.asVector() );
MMatrix parentMatrix = inputMpxTrMtx.asMatrix();
MPxTransformationMatrix mpxTrMtx;
MEulerRotation eulerRot( hRotate.asVector() );
MEulerRotation joEulerRot( hJointOrient.asVector() );
mpxTrMtx.translateTo( hTranslate.asVector() );
mpxTrMtx.rotateTo( eulerRot );
mpxTrMtx.rotateBy( joEulerRot );
mpxTrMtx.scaleTo( hScale.asVector() );
mpxTrMtx.shearTo( hShear.asVector() );
if( plug == aMatrix )
{
//cout <<"matrix"<<endl;
MDataHandle hMatrix = data.outputValue( aMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hMatrix.setMMatrix( mpxTrMtx.asMatrix() );
}
if( plug == aInverseMatrix )
{
//cout <<"inverseMatrix"<<endl;
MDataHandle hInverseMatrix = data.outputValue( aInverseMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hInverseMatrix.setMMatrix( mpxTrMtx.asMatrix().inverse() );
}
if( plug == aWorldMatrix || plug == aWorldInverseMatrix )
{
MMatrix worldMatrix = mpxTrMtx.asMatrix()*parentMatrix;
if( plug == aWorldMatrix )
{
//cout <<"worldMatrix"<<endl;
MDataHandle hWorldMatrix = data.outputValue( aWorldMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hWorldMatrix.setMMatrix( worldMatrix );
}
if( plug == aWorldInverseMatrix )
{
//cout <<"worldInverseMatrix"<<endl;
MDataHandle hWorldInverseMatrix = data.outputValue( aWorldInverseMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hWorldInverseMatrix.setMMatrix( worldMatrix.inverse() );
}
}
if( plug == aParentMatrix )
{
//cout <<"parentMatrix"<<endl;
MDataHandle hParentMatrix = data.outputValue( aParentMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hParentMatrix.setMMatrix( parentMatrix );
}
if( plug == aParentInverseMatrix )
{
//cout <<"parentInverseMatrix"<<endl;
MDataHandle hParentInverseMatrix = data.outputValue( aParentInverseMatrix, &status );
CHECK_MSTATUS_AND_RETURN_IT( status );
hParentInverseMatrix.setMMatrix( parentMatrix.inverse() );
}
data.setClean( plug );
//.........这里部分代码省略.........
示例4: compute
MStatus MG_nurbsRivet::compute(const MPlug& plug,MDataBlock& dataBlock)
{
//Get recompute value
MDataHandle recomputeH = dataBlock.inputValue(recompute);
bool recomputeV = recomputeH.asBool();
//input mesh
MDataHandle inputNurbsH = dataBlock.inputValue(inputNurbSurface);
MObject inputNurb = inputNurbsH.asNurbsSurfaceTransformed();
MMatrix offsetMatrixV = dataBlock.inputValue(offsetMatrix).asMatrix();
double U,V;
MFnNurbsSurface nurbsFn ;
nurbsFn.setObject(inputNurb);
MStatus stat;
if (recomputeV == true)
{
//input point
MDataHandle inputPointH = dataBlock.inputValue(inputPoint);
MPoint inputP = inputPointH.asVector();
MPoint closestP = nurbsFn.closestPoint(inputP,NULL,NULL,false,1e+99,MSpace::kObject);
stat = nurbsFn.getParamAtPoint(closestP,U,V,MSpace::kObject);
//Handle to U and V
MDataHandle uValueH =dataBlock.outputValue(uValue);
MDataHandle vValueH =dataBlock.outputValue(vValue);
uValueH.set(float(U));
vValueH.set(float(V));
uValueH.setClean();
vValueH.setClean();
MDataHandle recomputeOutH = dataBlock.outputValue(recompute);
}
MDataHandle uH = dataBlock.inputValue(uValue);
MDataHandle vH = dataBlock.inputValue(vValue);
U = uH.asFloat();
V = vH.asFloat();
MPoint outPoint ;
MVector uVec ;
MVector vVec;
MVector normal;
//Get point
stat = nurbsFn.getPointAtParam(U,V,outPoint,MSpace::kObject);
//Since if getting both the U and V tangent was leading to some little rotation snapping
//of the rivet I only used the U tangent and calculated the next one by dot product
//of the normal and U tangent leading to a 100% stable rivet
nurbsFn.getTangents(U,V,uVec,vVec,MSpace::kObject);
uVec.normalize();
vVec.normalize();
MVector vVecCross;
//Get normal
normal = nurbsFn.normal(U,V,MSpace::kObject);
normal.normalize();
vVecCross =(uVec^normal);
//.........这里部分代码省略.........
示例5: compute
MStatus buildRotation::compute( const MPlug& plug, MDataBlock& data )
{
MStatus returnStatus;
if ((plug == rotate) || (plug.parent() == rotate) || (plug == rotateMatrix)) {
MDataHandle upData = data.inputValue( up, &returnStatus );
McheckErr(returnStatus,"ERROR getting up vector data");
MDataHandle forwardData = data.inputValue( forward, &returnStatus );
McheckErr(returnStatus,"ERROR getting forward vector data");
MVector up = upData.asVector();
MVector forward = forwardData.asVector();
// Make sure that the up and forward vectors are orthogonal
//
if ( fabs( up * forward ) > EPSILON ) {
// Non-zero dot product
//
MVector orthoVec = up ^ forward;
MVector newForward = orthoVec ^ up;
if ( forward * newForward < 0.0 ) {
// Reverse the vector
//
newForward *= -1.0;
}
forward = newForward;
}
// Calculate the rotation required to align the y-axis with the up
// vector
//
MTransformationMatrix firstRot;
MVector rotAxis = MVector::yAxis ^ up;
rotAxis.normalize();
firstRot.setToRotationAxis( rotAxis, MVector::yAxis.angle( up ) );
// Calculate the second rotation required to align the forward vector
//
MTransformationMatrix secondRot;
MVector transformedForward = firstRot.asMatrix() * forward;
transformedForward.normalize();
double angle = transformedForward.angle( MVector::zAxis );
if ( transformedForward.x < 0.0 ) {
// Compensate for the fact that the angle method returns
// the absolute value
//
angle *= -1.0;
}
secondRot.setToRotationAxis( up, angle );
// Get the requested rotation order
//
MDataHandle orderHandle = data.inputValue( rotateOrder );
short order = orderHandle.asShort();
MTransformationMatrix::RotationOrder rotOrder;
switch ( order ) {
case ROTATE_ORDER_XYZ:
rotOrder = MTransformationMatrix::kXYZ; break;
case ROTATE_ORDER_YZX:
rotOrder = MTransformationMatrix::kYZX; break;
case ROTATE_ORDER_ZXY:
rotOrder = MTransformationMatrix::kZXY; break;
case ROTATE_ORDER_XZY:
rotOrder = MTransformationMatrix::kXZY; break;
case ROTATE_ORDER_YXZ:
rotOrder = MTransformationMatrix::kYXZ; break;
case ROTATE_ORDER_ZYX:
rotOrder = MTransformationMatrix::kZYX; break;
default:
rotOrder = MTransformationMatrix::kInvalid; break;
}
MTransformationMatrix result = firstRot.asMatrix() * secondRot.asMatrix();
result.reorderRotation( rotOrder );
double rotation[3];
result.getRotation( rotation, rotOrder, MSpace::kTransform );
MDataHandle outputRot = data.outputValue( rotate );
outputRot.set( rotation[0], rotation[1], rotation[2] );
outputRot.setClean();
MDataHandle outputMatrix = data.outputValue( rotateMatrix );
outputMatrix.set( result.asMatrix() );
outputMatrix.setClean();
} else
return MS::kUnknownParameter;
return MS::kSuccess;
}