コード例 #1
0
ファイル: ropeGenerator.cpp プロジェクト: skarone/PipeL
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
0
ファイル: Convert.cpp プロジェクト: AtomicFiction/cortex
float convert( const MAngle &from )
{
	return from.asRadians();
}