当前位置: 首页>>代码示例>>C++>>正文


C++ MDataHandle::asDouble方法代码示例

本文整理汇总了C++中MDataHandle::asDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asDouble方法的具体用法?C++ MDataHandle::asDouble怎么用?C++ MDataHandle::asDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MDataHandle的用法示例。


在下文中一共展示了MDataHandle::asDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deform

MStatus SwirlDeformer::deform( MDataBlock& block, MItGeometry &iter,
												const MMatrix &localToWorld, unsigned int geomIndex )
{
MStatus stat;
	
MDataHandle envData = block.inputValue( envelope );
float env = envData.asFloat();	
if( env == 0.0 ) // Deformer has no effect
	return MS::kSuccess;

MDataHandle matData = block.inputValue( deformSpace );
MMatrix mat = matData.asMatrix();
MMatrix invMat = mat.inverse();

MDataHandle startDistHnd = block.inputValue( startDist );
double startDist = startDistHnd.asDouble();	

MDataHandle endDistHnd = block.inputValue( endDist );
double endDist = endDistHnd.asDouble();	

MPoint pt;
float weight;
double dist;
double ang;
double cosAng;
double sinAng;
double x;
double distFactor;
for( iter.reset(); !iter.isDone(); iter.next() ) 
	{
	weight = weightValue( block, geomIndex, iter.index() );
	if( weight == 0.0f )
		continue;

	pt = iter.position();
	pt *= invMat;

	dist = sqrt( pt.x * pt.x + pt.z * pt.z );
	if( dist < startDist || dist > endDist )
		continue;

	distFactor = 1 - ((dist - startDist) / (endDist - startDist));

	ang = distFactor * M_PI * 2.0 * env * weight;
	if( ang == 0.0 )
		continue;

	cosAng = cos( ang );
	sinAng = sin( ang );
	x = pt.x * cosAng - pt.z * sinAng;
	pt.z = pt.x * sinAng + pt.z * cosAng;
	pt.x = x;

	pt *= mat;
	
	iter.setPosition( pt );
	}

return stat;
}
开发者ID:animformed,项目名称:complete-maya-programming-book-files,代码行数:60,代码来源:SwirlDeformer.cpp

示例2: compute

MStatus transCircle::compute( const MPlug& plug, MDataBlock& data )
{
    MStatus stat;
 
	bool k = ( plug == outputTranslateX ) |
	         ( plug == outputTranslateY ) |
			 ( plug == outputTranslateZ ) |
			 ( plug == outputTranslate );
	if (!k) return MS::kUnknownParameter;

	MDataHandle inputData = data.inputValue( input, &stat );
	MDataHandle scaleData = data.inputValue( scale, &stat );
	MDataHandle framesData = data.inputValue( frames, &stat );
	MDataHandle transData  = data.inputValue( inputTranslate, &stat ); 
	double3& iTranslate = transData.asDouble3();
	double currentFrame = inputData.asDouble();
	double scaleFactor  = scaleData.asDouble();
	double framesPerCircle = framesData.asDouble();
	double angle = 6.2831853 * ( currentFrame/framesPerCircle );
	double3 oTranslate;
	
	oTranslate[0] = iTranslate[0] + (sin( angle ) * scaleFactor);
	oTranslate[1] = iTranslate[1] + 1.0;
	oTranslate[2] = iTranslate[2] + (cos( angle ) * scaleFactor);

	MDataHandle otHandle = data.outputValue( outputTranslate ); 
	otHandle.set( oTranslate[0], oTranslate[1], oTranslate[2] );
	data.setClean(plug);

    return MS::kSuccess;
}
开发者ID:ADN-DevTech,项目名称:Maya-Training-Material,代码行数:31,代码来源:transCircleNode.cpp

示例3: compute

MStatus  matrixFromPolygon::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus status;

	//MFnDependencyNode thisNode( thisMObject() );
	//cout << thisNode.name() << ", start" << endl;

	if( plug == aOutputMatrix )
	{
		MDataHandle  hInputMesh = data.inputValue( aInputMesh, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );
		MDataHandle  hInputMeshMatrix = data.inputValue( aInputMeshMatrix, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );
		MDataHandle  hPolygonIndex = data.inputValue( aPolygonIndex, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );
		MDataHandle  hU = data.inputValue( aU, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );
		MDataHandle  hV = data.inputValue( aV, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );
		MDataHandle  hOutputMatrix = data.outputValue( aOutputMatrix, &status );
		CHECK_MSTATUS_AND_RETURN_IT( status );

		MMatrix outMatrix;
		getMatrixByPoints( outMatrix, hPolygonIndex.asInt(), hU.asDouble(), hV.asDouble(), hInputMesh.asMesh() );

		outMatrix *= hInputMeshMatrix.asMatrix();

		hOutputMatrix.set( outMatrix );

		data.setClean( plug );
	}
	//cout << thisNode.name() << ", end" << endl;

	return MS::kSuccess;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:35,代码来源:matrixFromPolygon.cpp

示例4: compute

MStatus squash::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus returnStatus;
	if( plug == output )
	{
		MDataHandle lengthOrigHandle = data.inputValue( lengthOriginal, &returnStatus );
		MDataHandle lengthModiHandle = data.inputValue( lengthModify, &returnStatus );
		MDataHandle rateHandle = data.inputValue( squashRate, &returnStatus );
		MDataHandle forceHandle = data.inputValue( forceValue, &returnStatus );

		if( returnStatus != MS::kSuccess )
			MGlobal::displayError( "Node squash cannot get value\n" );
		else
		{
			double lengthOrig = lengthOrigHandle.asDouble();
			double lengthModi = lengthModiHandle.asDouble();
			double rate       = rateHandle.asDouble();
			double force      = forceHandle.asDouble();

			double result = pow( lengthOrig/lengthModi, 0.5*rate )*(1+force);

			MDataHandle outputHandle = data.outputValue( squash::output );
			outputHandle.set( result );
			data.setClean(plug);
		}
	} else {
		return MS::kUnknownParameter;
	}

	return MS::kSuccess;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:31,代码来源:squash.cpp

示例5: compute

MStatus sgLockAngleMatrix::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus status;

	MDataHandle hBaseMatrix = data.inputValue( aBaseMatrix );
	m_baseMatrix = hBaseMatrix.asMatrix();

	MDataHandle hInputMatrix = data.inputValue( aInputMatrix );
	m_inputMatrix = hInputMatrix.asMatrix();

	MDataHandle hAngleAxis = data.inputValue( aAngleAxis );
	m_angleAxis = hAngleAxis.asUChar();

	MDataHandle hInputAngle = data.inputValue( aInputAngle );
	m_inputAngle = hInputAngle.asDouble();

	m_mtxResult = getsgLockAngleMatrix( m_inputMatrix*m_baseMatrix.inverse(), m_angleAxis, m_inputAngle );

	MDataHandle hOutputMatrix = data.outputValue( aOutputMatrix );
	hOutputMatrix.set( m_mtxResult * m_baseMatrix );

	data.setClean( plug );

	return MS::kSuccess;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:25,代码来源:sgLockAngleMatrix.cpp

示例6: compute

MStatus timeControl::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus status;

	MDataHandle hInTime = data.inputValue( aInTime );
	MDataHandle hOffset = data.inputValue( aOffset );
	MDataHandle hMult = data.inputValue( aMult );
	MDataHandle hMinTime = data.inputValue( aMinTime );
	MDataHandle hMaxTime = data.inputValue( aMaxTime );
	MDataHandle hLimitAble = data.inputValue( aLimitAble );

	MTime inTime = hInTime.asTime();
	
	double offset = hOffset.asDouble();
	double mult = hMult.asDouble();

	double timeValue = inTime.value();
	
	if( hLimitAble.asBool() )
	{
		MTime minTime = hMinTime.asTime();
		MTime maxTime = hMaxTime.asTime();
		double minTimeValue = minTime.value();
		double maxTimeValue = maxTime.value();
		if( timeValue < minTimeValue )
			timeValue = minTimeValue;
		if( timeValue > maxTimeValue )
			timeValue = maxTimeValue;
	}

	timeValue += offset;
	timeValue *= mult;

	MTime outTime( timeValue );

	MDataHandle hOutTime = data.outputValue( aOutTime );
	hOutTime.set( outTime );

	MDataHandle hWeight = data.inputValue( aWeight );
	MDataHandle hOutWeight = data.outputValue( aOutWeight );
	hOutWeight.set( hWeight.asDouble() );

	data.setClean( plug );

	return status;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:46,代码来源:timeControl.cpp

示例7: magnitude

double dynExprField::magnitude( MDataBlock& block )
{
	MStatus status;
	MDataHandle hValue = block.inputValue( mMagnitude, &status );

	double value = 0.0;
	if( status == MS::kSuccess )
		value = hValue.asDouble();

	return( value );
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:11,代码来源:dynExprField.cpp

示例8: compute

MStatus LSystemNode::compute(const MPlug& plug, MDataBlock& data)
{
        MStatus returnStatus;

        if (plug == outputMesh) {
			//angle
			MDataHandle angleData = data.inputValue(angle,&returnStatus);
			McheckErr(returnStatus, "Error getting angle data handle\n");
			double angle = angleData.asDouble();
			//step
			MDataHandle stepData = data.inputValue(step,&returnStatus);
			McheckErr(returnStatus, "Error getting step data handle\n");
			double step = stepData.asDouble();
			//grammar
			MDataHandle grammarData = data.inputValue(grammar,&returnStatus);
			McheckErr(returnStatus, "Error getting grammar data handle\n");
			MString grammar = grammarData.asString();

                /* Get time */
                MDataHandle timeData = data.inputValue( time, &returnStatus ); 
                McheckErr(returnStatus, "Error getting time data handle\n");
                MTime time = timeData.asTime();

                /* Get output object */

                MDataHandle outputHandle = data.outputValue(outputMesh, &returnStatus);
                McheckErr(returnStatus, "ERROR getting polygon data handle\n");

                MFnMeshData dataCreator;
                MObject newOutputData = dataCreator.create(&returnStatus);
                McheckErr(returnStatus, "ERROR creating outputData");

                createMesh(angle, step, grammar, time, newOutputData, returnStatus);
                McheckErr(returnStatus, "ERROR creating new Cube");

                outputHandle.set(newOutputData);
                data.setClean( plug );
        } else
        return MS::kUnknownParameter;
		return MS::kSuccess;
}
开发者ID:zammiez,项目名称:BicycleSimulation,代码行数:41,代码来源:LSystemNode.cpp

示例9: compute

//----------------------------------------------------------------------------------------------------------------------
// This method should be overridden in user defined nodes.
// Recompute the given output based on the nodes inputs.
// The plug represents the data value that needs to be recomputed, and the data block holds the storage
// for all of the node'_scale attributes.
//----------------------------------------------------------------------------------------------------------------------
MStatus OceanNode::compute( const MPlug &_plug , MDataBlock &_data ){
    MStatus status;
    // see if we get the output plug
    if( _plug == m_output){    

        MDataHandle dataHandle;

        dataHandle = _data.inputValue(m_resolution, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for resolution plug");

        if (m_res != dataHandle.asInt()){
            switch(dataHandle.asInt()){
                case 0:
                    m_ocean->setResolution(128);
                    MGlobal::displayInfo("Resolution: 128");
                    break;
                case 1:
                    m_ocean->setResolution(256);
                    MGlobal::displayInfo("Resolution: 256");
                    break;
                case 2:
                    m_ocean->setResolution(512);
                    MGlobal::displayInfo("Resolution: 512");
                    break;
                case 3:
                    m_ocean->setResolution(1024);
                    MGlobal::displayInfo("Resolution: 1024");
                    break;
                default:
                    break;
            }
            m_res = dataHandle.asInt();
        }

        dataHandle = _data.inputValue( m_amplitude , &status );
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to get data handle for amplitude plug" );
        // now get the value for the data handle as a double
        double amp = dataHandle.asDouble();
        m_ocean->setAmplitude(amp);

        dataHandle = _data.inputValue(m_frequency, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get handle for \"frequency\" plug");
        double freq = dataHandle.asDouble();
        m_ocean->setFrequency(freq);

        dataHandle = _data.inputValue(m_windDirectionX, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for windDirectionX plug");
        // now get value for data handle
        double wdx = dataHandle.asDouble();
        dataHandle = _data.inputValue(m_windDirectionZ, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for windDirectionY plug");
        // now get value for data handle
        double wdz = dataHandle.asDouble();
        m_ocean->setWindVector(make_float2(wdx, wdz));

        dataHandle = _data.inputValue(m_windSpeed, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for windSpeed plug");
        // now get value for data handle
        double ws = dataHandle.asDouble();
        m_ocean->setWindSpeed(ws);

        // Only create a new frequency domain if either amplitude or the wind vecotr has changed
        if (m_amp != amp || m_wdx != wdx || m_wdz != wdz || m_ws != ws ){
            MGlobal::displayInfo("here");
            m_ocean->createH0();
            m_amp = amp;
            m_wdx = wdx;
            m_wdz = wdz;
            m_ws = ws;
        }

        dataHandle = _data.inputValue(m_choppiness, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for the choppiness plug");
        double choppiness = dataHandle.asDouble();

        dataHandle = _data.inputValue(m_time, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to get data handle for time plug");
        MTime time = dataHandle.asTime();

        MDataHandle outputData = _data.outputValue(m_output, &status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to get data handle for output plug" );

        MFnMeshData mesh;
        MObject outputObject = mesh.create(&status);
        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create output mesh");

        // Find the current frame number we're on and create the grid based on this
        MAnimControl anim;
        anim.setMinTime(time);

        createGrid((int)pow(2.0, m_res+7), anim.currentTime().value()/24, choppiness, outputObject, status);

        CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to to create grid");

//.........这里部分代码省略.........
开发者ID:TobyGilbert,项目名称:OceanMayaPlugin,代码行数:101,代码来源:OceanNode.cpp

示例10: compute

MStatus proWater::compute(const MPlug& plug, MDataBlock& dataBlock)
{
    MStatus status = MStatus::kUnknownParameter;
    if (plug.attribute() == outputGeom) {
        // get the input corresponding to this output
        //
        unsigned int index = plug.logicalIndex();
        MObject thisNode = this->thisMObject();
        MPlug inPlug(thisNode,input);
        inPlug.selectAncestorLogicalIndex(index,input);
        MDataHandle hInput = dataBlock.inputValue(inPlug);
        
        // get the input geometry and input groupId
        //
        MDataHandle hGeom = hInput.child(inputGeom);
        MDataHandle hGroup = hInput.child(groupId);
        
        
        
        unsigned int groupId = hGroup.asLong();
        MDataHandle hOutput = dataBlock.outputValue(plug);
        hOutput.copy(hGeom);
        
        
        MStatus returnStatus;
        
        MDataHandle envData = dataBlock.inputValue(envelope, &returnStatus);
        if (MS::kSuccess != returnStatus) return returnStatus;
        float env = envData.asFloat();
        
        MDataHandle timeData = dataBlock.inputValue(time, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double t = timeData.asDouble();
        
        MDataHandle dirData = dataBlock.inputValue(dir, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double dirDeg = dirData.asDouble();
        
        MDataHandle bigData = dataBlock.inputValue(bigFreq, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double bigFreqAmp = bigData.asDouble();
        
        MDataHandle ampData = dataBlock.inputValue(amplitude1, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double amp1 = ampData.asDouble();
        
        MDataHandle freqData = dataBlock.inputValue(frequency1, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double freq1 = freqData.asDouble();
        
        MDataHandle ampData2 = dataBlock.inputValue(amplitude2, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double amp2 = ampData2.asDouble();
        
        MDataHandle freqData2 = dataBlock.inputValue(frequency2, &returnStatus);
        if(MS::kSuccess != returnStatus) return returnStatus;
        double freq2 = freqData2.asDouble();
        
        
        // Get the MFnMesh
        MStatus stat;
        MObject inputObj = hOutput.data();
        MFnMesh * meshFn = new MFnMesh(inputObj, &stat);
        
        // do the deformation
        //
        MItGeometry iter(hOutput,groupId,false);
        
        for ( ; !iter.isDone(); iter.next()) {
            MPoint pt = iter.position();
            
            //float2 uvPoint;
            //float u,v;
            
            //uvPoint[0] = u;
            //uvPoint[1] = v;
            
            //meshFn->getUVAtPoint(pt, uvPoint, MSpace::kObject);
            
            float u = pt.x; //uvPoint[0]*100;
            float v = pt.z; //uvPoint[1]*100;
            
            float degDir = dirDeg;
            
            float dir = degDir* M_PI/180;
            
            float dirX = cos(dir);
            float dirY = sin(dir);
            
            
            float bigFreq = 0.01;
            
            float bigWaves = scaled_raw_noise_3d(0, 1, (u + 3*t*dirX)*bigFreq*dirX, (v + 3*t*dirY)*bigFreq*dirY*2, t*0.01);
            
            
            float frequency1 = freq1/10;//0.2;
            float amplitude1 = amp1;//1.3;
            
            float firstOctave = -(std::abs(scaled_raw_noise_3d(-amplitude1, amplitude1, (float)(u + 0.7*t*dirX)*frequency1*0.4, (float)(v + 0.7*t*dirY)*frequency1*0.6, 0.05*t))-amplitude1);
            
//.........这里部分代码省略.........
开发者ID:albintornqvist,项目名称:TNCG13-ProceduralWater,代码行数:101,代码来源:proWater.cpp

示例11: compute

MStatus LSSolverNode::compute(const MPlug& plug, MDataBlock& data)
{
	MStatus stat;
	
	if( plug == deformed)
	{
		MDataHandle tetWorldMatrixData = data.inputValue(tetWorldMatrix, &returnStatus);
		McheckErr(returnStatus, "Error getting tetWorldMatrix data handle\n");

		MDataHandle restShapeData = data.inputValue(restShape, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle restVerticesData = data.inputValue(restVertices, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle restElementsData = data.inputValue(restElements, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle selectedConstraintVertsData = data.inputValue(selectedConstraintVerts, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle selectedForceVertsData = data.inputValue(selectedForceVerts, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle timeData = data.inputValue(time, &returnStatus);
		McheckErr(returnStatus, "Error getting step data handle\n");

		MDataHandle outputMeshData = data.outputValue(deformed, &returnStatus);
		McheckErr(returnStatus, "Error getting outputMesh data handle\n");
		
		MMatrix twmat = tetWorldMatrixData.asMatrix();
		MObject rs = restShapeData.asMesh();
		double t = timeData.asDouble();

		MDataHandle poissonRatioData = data.inputValue(poissonRatio, &returnStatus);
		McheckErr(returnStatus, "Error getting poissonRatio data handle\n");

		MDataHandle youngsModulusData = data.inputValue(youngsModulus, &returnStatus);
		McheckErr(returnStatus, "Error getting youngsmodulus data handle\n");

		MDataHandle objectDensityData = data.inputValue(objectDensity, &returnStatus);
		McheckErr(returnStatus, "Error getting objectDensity data handle\n");

		MDataHandle frictionData = data.inputValue(friction, &returnStatus);
		McheckErr(returnStatus, "Error getting friction data handle\n");

		MDataHandle restitutionData = data.inputValue(restitution, &returnStatus);
		McheckErr(returnStatus, "Error getting restitution data handle\n");

		MDataHandle dampingData = data.inputValue(damping, &returnStatus);
		McheckErr(returnStatus, "Error getting damping data handle\n");

		MDataHandle userSuppliedDtData = data.inputValue(userSuppliedDt, &returnStatus);
		McheckErr(returnStatus, "Error getting user supplied dt data handle\n");


		MDataHandle integrationTypeData = data.inputValue(integrationType, &returnStatus);
		McheckErr(returnStatus, "Error getting user integrationTypeData\n");

		MDataHandle forceModelTypeData = data.inputValue(forceModelType, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceModelTypeData\n");

		MDataHandle forceApplicationTimeData = data.inputValue(forceApplicationTime, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceApplicationTime\n");
	
		MDataHandle forceReleasedTimeData = data.inputValue(forceReleasedTime, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceReleasedTime\n");

		MDataHandle forceIncrementTimeData = data.inputValue(forceIncrementTime, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceIncrementTime\n");

		MDataHandle forceStartTimeData = data.inputValue(forceStartTime, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceStartTime\n");

		MDataHandle forceStopTimeData = data.inputValue(forceStopTime, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceStopTime\n");

		MDataHandle forceMagnitudeData = data.inputValue(forceMagnitude, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceIdleTime\n");

		MDataHandle useSuppliedForceData = data.inputValue(useSuppliedForce, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceIdleTime\n");

		MDataHandle useSuppliedConstraintsData = data.inputValue(useSuppliedConstraints, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceIdleTime\n");

		MDataHandle forceDirectionData = data.inputValue(forceDirection, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceDirection\n");

		MDataHandle contactKsData = data.inputValue(contactKs, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceDirection\n");	

		MDataHandle contactKdData = data.inputValue(contactKd, &returnStatus);
		McheckErr(returnStatus, "Error getting user forceDirection\n");

		MTime currentTime, maxTime;
		currentTime = MAnimControl::currentTime();
		maxTime = MAnimControl::maxTime();
					
		if (currentTime == MAnimControl::minTime())
//.........这里部分代码省略.........
开发者ID:siqihuang,项目名称:Movable-Tree,代码行数:101,代码来源:LSSolverNode.cpp

示例12: optionsArray

//----------------------------------------------------------------------------
MStatus		BPT_InsertVtx::doCompleteCompute( MDataBlock& data )
//----------------------------------------------------------------------------
{

				SPEED("Berechne EdgeSplit neu: ");

				MStatus status;

				MPRINT("MACHE KOMPLETTE BERECHNUNG")



				MDataHandle inMeshHandle = data.inputValue(IVinMesh);
				MDataHandle outMeshHandle = data.outputValue(IVoutMesh);


					//splitCount setzen
				
				MDataHandle countHandle	= data.inputValue(IVcount);			
				fIVfty.setCount(countHandle.asInt());
			
				

				MDataHandle spinHandle = data.inputValue(IVspin);

				fIVfty.setSpin(spinHandle.asInt());
				

				int initialVtxCount;	//wird spueueter benueuetigt, um das ValidIndicesArray gleich in der rictigen grueueueuee zu erstellen und zu schreiben


				//gleich zu beginn muss der MeshPath initialisiert werden, damit der MeshPath an die fty ueuebergeben werden kann
				// Dies geschieht besser durch die STE - sie ist darauf ausgelegt
				softTransformationEngine::gatherAttributeObjects(thisMObject());
				softTransformationEngine::saveMeshPathes();

				

				fIVfty.setMeshPath(meshPath);
				
				
			
				MDataHandle	rHandle = data.inputValue(IVslideRelative);
				fIVfty.setRelative(rHandle.asInt());
				
				
				MDataHandle nRelativeHandle = data.inputValue(IVnormalRelative);
				fIVfty.setNormalRelative(nRelativeHandle.asInt());
				
				
				//selection setzen
				MFnIntArrayData		intDataArray;	
				
				MDataHandle arrayHandle = data.inputValue(IVselEdgeIDs);
				intDataArray.setObject(arrayHandle.data());
				
				fIVfty.setEdgeIDs( intDataArray.array() );

				arrayHandle = data.inputValue(IVselVertIDs);
				intDataArray.setObject(arrayHandle.data());

				fIVfty.setVertIDs(intDataArray.array());
				

				//				optionen holen
				
				arrayHandle = data.inputValue(IVoptions);
				intDataArray.setObject(arrayHandle.data());
				MIntArray optionsArray(intDataArray.array());
				

				fIVfty.setOptions(optionsArray);
				
				
				
				
				MDataHandle slideHandle = data.inputValue(IVslide);
				fIVfty.setSlide(slideHandle.asDouble());

				
				//whichSide attribute wird nur fueuer SLide selbst verwendet und kann nicht bereits beim command gestetzt werden
				
				


				MObject inMeshRef = inMeshHandle.asMesh();
				fIVfty.setMesh(inMeshRef);


				MFnMesh meshFn(inMeshHandle.asMesh());
				initialVtxCount = meshFn.numVertices();
				

				

				//ACTION
				try
				{
					status = fIVfty.doIt();
//.........这里部分代码省略.........
开发者ID:Byron,项目名称:bsuite,代码行数:101,代码来源:BPT_insertVtxNode.cpp

示例13: depFn

//---------------------------------------------------------------------------------------------------
bool	BPT_InsertVtx::setInternalValue ( const MPlug & plug, const MDataHandle & dataHandle)
//---------------------------------------------------------------------------------------------------
{ 

//	cout<<"War hier, plug war "<<plug.info()<<endl;


	if(plug == IVslide)
	{
		int isLimited;
		
		MFnDependencyNode depFn(plug.node());
		depFn.findPlug( "sll" ).getValue( isLimited );


		if( isLimited )
		{//limits setzen, wenn gewueuenscht
			
			double value = dataHandle.asDouble();
			
	//		cout<<value<<endl;

			if(value > 1.0)
				value = 1.0;

			if(value < 0.0)
				value = 0.0;
			
			//Das muss hier einfach sein, um limits dynamisch zu setzen je nach userwunsch
			 const_cast<MDataHandle&>(dataHandle).set(value);
		}

	}
	else if( plug == IVcount )
	{
		int value = dataHandle.asInt();
		
		if(value != lastCount)
		{//count hat sich nicht verueuendert, also outHandle sueueubern und raus hier
			meshDirty = true;
			lastCount = value;	
		}
		
	}
	else if( plug == IVspin )
	{
		int value = dataHandle.asInt();
/*
		MFnIntArrayData arrayData;
		MPlug optionPlug(thisMObject(), options);	//dieser wert kann gefahrlos geholt werden, da er das outmesh nicht beeinflusst
		
		MObject data;
		optionsPlug.getValue(data);
		arrayData.setObject(data);

		if(!(arrayData.array())[9])
		{//wenn civ nicht gesetzt ist, dann macht dieser Wert keinen sinn



		}
*/
		
		if(value != lastSpin)
		{
			meshDirty = true;
			lastSpin = value;
		}

	}

	
	// Sich jetzt um die STE internals kuemmern
	//
	//

	STE_CHECK_INTERNALS( IV,dataHandle );

	

	if(plug==IVinMesh)
		meshDirty = true; 
	
	return MPxNode::setInternalValue (plug, dataHandle);
}
开发者ID:Byron,项目名称:bsuite,代码行数:86,代码来源:BPT_insertVtxNode.cpp

示例14: compute

MStatus closestPointOnCurveNode::compute(const MPlug &plug, MDataBlock &data)

{

   // DO THE COMPUTE ONLY FOR THE *OUTPUT* PLUGS THAT ARE DIRTIED:

   if ((plug == aPosition)  || (plug == aPositionX)  || (plug == aPositionY)  || (plug == aPositionZ)

    || (plug == aNormal) || (plug == aNormalX) || (plug == aNormalY) || (plug == aNormalZ)

    || (plug == aTangent) || (plug == aTangentX) || (plug == aTangentY) || (plug == aTangentZ)

	|| (plug == aParamU) || (plug == aDistance))

   {

      // READ IN ".inCurve" DATA:

      MDataHandle inCurveDataHandle = data.inputValue(aInCurve);

      MObject inCurve = inCurveDataHandle.asNurbsCurve();



      // READ IN ".inPositionX" DATA:

      MDataHandle inPositionXDataHandle = data.inputValue(aInPositionX);

      double inPositionX = inPositionXDataHandle.asDouble();



      // READ IN ".inPositionY" DATA:

      MDataHandle inPositionYDataHandle = data.inputValue(aInPositionY);

      double inPositionY = inPositionYDataHandle.asDouble();



      // READ IN ".inPositionZ" DATA:

      MDataHandle inPositionZDataHandle = data.inputValue(aInPositionZ);

      double inPositionZ = inPositionZDataHandle.asDouble();



      // GET THE CLOSEST POSITION, NORMAL, TANGENT, PARAMETER-U AND DISTANCE:

      MPoint inPosition(inPositionX, inPositionY, inPositionZ), position;

      MVector normal, tangent;

      double paramU, distance;

      MDagPath dummyDagPath;

      closestTangentUAndDistance(dummyDagPath, inPosition, position, normal, tangent, paramU, distance, inCurve);



      // WRITE OUT ".position" DATA:

      MDataHandle positionDataHandle = data.outputValue(aPosition);

      positionDataHandle.set(position.x, position.y, position.z);

      data.setClean(plug);



      // WRITE OUT ".normal" DATA:

      MDataHandle normalDataHandle = data.outputValue(aNormal);

      normalDataHandle.set(normal.x, normal.y, normal.z);

      data.setClean(plug);



      // WRITE OUT ".tangent" DATA:

      MDataHandle tangentDataHandle = data.outputValue(aTangent);

      tangentDataHandle.set(tangent.x, tangent.y, tangent.z);

      data.setClean(plug);



      // WRITE OUT ".paramU" DATA:

      MDataHandle paramUDataHandle = data.outputValue(aParamU);

      paramUDataHandle.set(paramU);

      data.setClean(plug);

//.........这里部分代码省略.........
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:101,代码来源:closestPointOnCurveNode.cpp

示例15: compute

MStatus sgIkSmoothStretch::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus stat;

	if ( plug == aOutputDistance )
	{
		MArrayDataHandle hArrInputDistance = data.inputArrayValue( aInputDistance );
		MDataHandle hStretchAble = data.inputValue( aStretchAble );
		MDataHandle hSmoothArea = data.inputValue( aSmoothArea );

		float stretchAble = hStretchAble.asFloat();

		double allDistance = 0.0;
		int arrayCount = hArrInputDistance.elementCount();

		double* outputDistances = new double[arrayCount]; 

		int multMinus = 1;
		for( int i=0; i<arrayCount; i++ )
		{
			MDataHandle hInputDistance = hArrInputDistance.inputValue();
			double inputDistance = hInputDistance.asDouble();

			if( inputDistance < 0 )
			{
				multMinus = -1;
				outputDistances[i] = -inputDistance;
			}
			else
			{
				outputDistances[i] = inputDistance;
			}
			allDistance += outputDistances[i];
			hArrInputDistance.next();
		}
		
		MDataHandle hInPosition = data.inputValue( aInPosition );
		MDataHandle hInPositionX = hInPosition.child( aInPositionX );
		MDataHandle hInPositionY = hInPosition.child( aInPositionY );
		MDataHandle hInPositionZ = hInPosition.child( aInPositionZ );

		double smoothArea = hSmoothArea.asDouble()*0.1;

		double poseDistance = sqrt( pow( hInPositionX.asDouble(), 2 )+pow( hInPositionY.asDouble(), 2 )+pow( hInPositionZ.asDouble(), 2 ) ) ;
		allDistance = fabs( allDistance );

		double stretchRate = getSmoothStretchRate( outputDistances[0], outputDistances[1], poseDistance, smoothArea );
		double smoothRate  = getSmoothRate( outputDistances[0], outputDistances[1], poseDistance, smoothArea );

		double currentRate = ( 1-stretchAble )*smoothRate + stretchAble*stretchRate;

		outputDistances[0] *= currentRate*multMinus;
		outputDistances[1] *= currentRate*multMinus;

		MArrayDataHandle hArrOutputDistance = data.outputArrayValue( aOutputDistance );
		MArrayDataBuilder bArrOutputDistance( aOutputDistance, arrayCount, &stat );

		for( int i=0; i<arrayCount; i++ )
		{
			MDataHandle hOutputDistance = bArrOutputDistance.addElement( i );
			hOutputDistance.set( outputDistances[i] );
		}

		hArrOutputDistance.set( bArrOutputDistance );
		hArrOutputDistance.setAllClean();

		data.setClean( plug );
	}
	return MS::kSuccess;
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:70,代码来源:sgIkSmoothStretch.cpp


注:本文中的MDataHandle::asDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。