本文整理汇总了C++中MDataHandle::setMMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::setMMatrix方法的具体用法?C++ MDataHandle::setMMatrix怎么用?C++ MDataHandle::setMMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::setMMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
//.........这里部分代码省略.........
示例2: compute
//.........这里部分代码省略.........
for(long i=1;i<in_subdiv;i++,sampleu+=samplestep){
results = bezier4point(pos[index1],tan[index1],pos[index2],tan[index2],sampleu);
presample[i] = results[0];
presampletan[i] = results[1];
diff = presample[i] - prevsample;
overalllen += diff.length();
samplelen[i] = overalllen;
prevsample = presample[i];
}
// now as we have the
sampleu = 0;
for(long i=0;i<in_subdiv-1;i++,sampleu+=samplestep){
samplelen[i+1] = samplelen[i+1] / overalllen;
if(v>=samplelen[i] && v <= samplelen[i+1]){
v = (v - samplelen[i]) / (samplelen[i+1] - samplelen[i]);
bezierPos = linearInterpolate(presample[i],presample[i+1],v);
xAxis = linearInterpolate(presampletan[i],presampletan[i+1],v);
break;
}
}
}
else{
MVectorArray presample(in_subdiv);
MVectorArray presampletan(in_subdiv);
MDoubleArray samplelen(in_subdiv);
double samplestep = 1.0 / double(in_subdiv-1);
double sampleu = samplestep;
presample[0] = pos[0];
presampletan[0] = tan[0];
MVector prevsample(presample[0]);
MVector diff;
samplelen[0] = 0;
double overalllen = 0;
MVectorArray results;
for(long i=1;i<in_subdiv;i++,sampleu+=samplestep){
index1 = (int)min(count-2,sampleu / step);
index2 = index1+1;
v = (sampleu - step * double(index1)) / step;
results = bezier4point(pos[index1],tan[index1],pos[index2],tan[index2],v);
presample[i] = results[0];
presampletan[i] = results[1];
diff = presample[i] - prevsample;
overalllen += diff.length();
samplelen[i] = overalllen;
prevsample = presample[i];
}
// now as we have the
sampleu = 0;
for(long i=0;i<in_subdiv-1;i++,sampleu+=samplestep){
samplelen[i+1] = samplelen[i+1] / overalllen;
if(in_u>=samplelen[i] && in_u <= samplelen[i+1]){
in_u = (in_u - samplelen[i]) / (samplelen[i+1] - samplelen[i]);
bezierPos = linearInterpolate(presample[i],presample[i+1],in_u);
xAxis = linearInterpolate(presampletan[i],presampletan[i+1],in_u);
break;
}
}
}
// compute the scaling (straight interpolation!)
MVector scl1 = linearInterpolate(scl[index1temp], scl[index2temp],vtemp);
// compute the rotation!
MQuaternion q = slerp(rot[index1temp], rot[index2temp], vtemp);
yAxis = MVector(0,1,0);
yAxis = yAxis.rotateBy(q);
// use directly or project the roll values!
// print roll
double a = linearInterpolate(roll[index1temp], roll[index2temp], vtemp);
yAxis = yAxis.rotateBy( MQuaternion(xAxis.x * sin(a/2.0), xAxis.y * sin(a/2.0), xAxis.z * sin(a/2.0), cos(a/2.0)));
zAxis = xAxis ^ yAxis;
zAxis.normalize();
yAxis = zAxis ^ xAxis;
yAxis.normalize();
// Output -------------------------------------------
MTransformationMatrix result;
// translation
result.setTranslation(bezierPos, MSpace::kWorld);
// rotation
q = getQuaternionFromAxes(xAxis,yAxis,zAxis);
result.setRotationQuaternion(q.x, q.y, q.z, q.w);
// scaling
threeDoubles[0] = 1;
threeDoubles[0] = scl1.y;
threeDoubles[0] = scl1.z;
result.setScale(threeDoubles, MSpace::kWorld);
MDataHandle h = data.outputValue( output );
h.setMMatrix( result.asMatrix() * outputParent.inverse() );
data.setClean( plug );
return MS::kSuccess;
}