本文整理汇总了C++中MFnNurbsCurve::normal方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnNurbsCurve::normal方法的具体用法?C++ MFnNurbsCurve::normal怎么用?C++ MFnNurbsCurve::normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnNurbsCurve
的用法示例。
在下文中一共展示了MFnNurbsCurve::normal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMatrixFromParamCurve
MMatrix ropeGenerator::getMatrixFromParamCurve( MFnNurbsCurve &curveFn, float param, float twist, MAngle divTwist )
{
MPoint pDivPos;
//Here we control the tangent of the rope
curveFn.getPointAtParam( param, pDivPos, MSpace::kWorld );
MVector vTangent( curveFn.tangent( param, MSpace::kWorld ).normal() );
MVector vNormal( curveFn.normal( param, MSpace::kWorld ).normal() );
if ( MAngle( PrevNormal.angle( vNormal ) ).asDegrees() > 90 )
//fprintf(stderr, "Angle = %g\n",MAngle( PrevNormal.angle( vNormal )).asDegrees());
vNormal = vNormal * -1;
PrevNormal = vNormal;
//if ( vNormal.angle( ) )
MQuaternion qTwist( twist * divTwist.asRadians(), vTangent );
vNormal = vNormal.rotateBy( qTwist );
MVector vExtra( vNormal ^ vTangent );
vNormal.normalize();
vTangent.normalize();
vExtra.normalize();
double dTrans[4][4] ={
{vNormal.x, vNormal.y, vNormal.z, 0.0f},
{vTangent.x, vTangent.y, vTangent.z, 0.0f},
{vExtra.x, vExtra.y, vExtra.z, 0.0f},
{pDivPos.x,pDivPos.y,pDivPos.z, 1.0f}};
MMatrix mTrans( dTrans );
return mTrans;
}
示例2: preSolve
MStatus splineSolverNode::preSolve()
{
MStatus stat;
setRotatePlane(false);
setSingleChainOnly(true);
setPositionOnly(false);
//Get Handle
MIkHandleGroup * handle_group = handleGroup();
if (NULL == handle_group) {
return MS::kFailure;
}
MObject handle = handle_group->handle( 0 );
MDagPath handlePath = MDagPath::getAPathTo( handle );
fnHandle.setObject( handlePath );
//Get Curve
MPlug inCurvePlug = fnHandle.findPlug( "inCurve" );
MDataHandle curveHandle = inCurvePlug.asMDataHandle();
MObject inputCurveObject = curveHandle.asNurbsCurveTransformed();
curveFn.setObject( inputCurveObject );
float initCurveLength = curveFn.length();
MVector initNormal = curveFn.normal(0);
MVector initTangent = curveFn.tangent(0);
float stretchRatio = 1;
// Get the position of the end_effector
//
MDagPath effectorPath;
fnHandle.getEffector(effectorPath);
tran.setObject( effectorPath );
// Get the start joint position
//
MDagPath startJointPath;
fnHandle.getStartJoint( startJointPath );
joints.clear();
//Get Joints
while (true)
{
effectorPath.pop();
joints.push_back( effectorPath );
if (effectorPath == startJointPath)
break;
}
std::reverse(joints.begin(), joints.end());
if (!fnHandle.hasAttribute("str"))
{
//Add Custom Attributes to Handle
MFnNumericAttribute fnAttr;
MObject attr = fnAttr.create("stretchRatio", "str", MFnNumericData::kDouble, stretchRatio);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setMin(0);
fnAttr.setMax(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("anchorPosition", "ancp", MFnNumericData::kDouble, 0.0);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setMin(0);
fnAttr.setMax(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("curveLength", "cvLen", MFnNumericData::kDouble, initCurveLength);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("initNormal", "norm", MFnNumericData::k3Double);
fnAttr.setDefault(initNormal.x, initNormal.y, initNormal.z);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("initTangent", "tang", MFnNumericData::k3Double);
fnAttr.setDefault(initTangent.x, initTangent.y, initTangent.z);
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("jointsLength", "jsLen", MFnNumericData::kDouble, getJointsTotalLenght());
fnAttr.setKeyable(0);
fnAttr.setWritable(1);
fnAttr.setHidden(1);
fnAttr.setStorable(1);
fnAttr.setReadable(1);
fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
attr = fnAttr.create("startTwist", "strtw", MFnNumericData::kDouble, 0.0);
fnAttr.setKeyable(1);
fnAttr.setWritable(1);
fnAttr.setHidden(0);
fnAttr.setStorable(1);
//.........这里部分代码省略.........