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


C++ MDataBlock类代码示例

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


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

示例1: compute

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

{
	MStatus returnStatus;

	if (plug == outputMesh) {
		/* 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(time, newOutputData, returnStatus);
		McheckErr(returnStatus, "ERROR creating new Cube");

		outputHandle.set(newOutputData);
		data.setClean( plug );
	} else
		return MS::kUnknownParameter;

	return MS::kSuccess;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:30,代码来源:animCubeNode.cpp

示例2: compute

// The compute() method does the actual work of the node using the inputs
// of the node to generate its output.
//
// Compute takes two parameters: plug and data.
// - Plug is the the data value that needs to be recomputed
// - Data provides handles to all of the nodes attributes, only these
//   handles should be used when performing computations.
//
MStatus affects::compute( const MPlug& plug, MDataBlock& data )
{
    MStatus status;
    MObject thisNode = thisMObject();
    MFnDependencyNode fnThisNode( thisNode );
    fprintf(stderr,"affects::compute(), plug being computed is \"%s\"\n",
            plug.name().asChar());

    if ( plug.partialName() == "B" ) {
        // Plug "B" is being computed. Assign it the value on plug "A"
        // if "A" exists.
        //
        MPlug pA = fnThisNode.findPlug( "A", &status );
        if ( MStatus::kSuccess == status ) {
            fprintf(stderr,"\t\t... found dynamic attribute \"A\", copying its value to \"B\"\n");
            MDataHandle inputData = data.inputValue( pA, &status );
            CHECK_MSTATUS( status );
            int value = inputData.asInt();

            MDataHandle outputHandle = data.outputValue( plug );
            outputHandle.set( value );
            data.setClean(plug);
        }
    } else {
        return MS::kUnknownParameter;
    }
    return( MS::kSuccess );
}
开发者ID:EricTRocks,项目名称:Maya-devkit,代码行数:36,代码来源:affectsNode.cpp

示例3: 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

示例4: loadInternal

bool ProxyViz::loadInternal(MDataBlock& block)
{
	MDataHandle tmH = block.inputValue(aplantTransformCache);
	MFnPointArrayData tmFn(tmH.data());
	MPointArray plantTms = tmFn.array();
	if(plantTms.length() < 1) return false;
	
	MDataHandle idH = block.inputValue(aplantIdCache);
	MFnIntArrayData idFn(idH.data());
	MIntArray plantIds = idFn.array();
	if(plantIds.length() < 1) return false;
	
	MDataHandle triH = block.inputValue(aplantTriangleIdCache);
	MFnIntArrayData triFn(triH.data());
	MIntArray plantTris = triFn.array();
	if(plantTris.length() < 1) return false;
	
	MDataHandle crdH = block.inputValue(aplantTriangleCoordCache);
	MFnVectorArrayData crdFn(crdH.data());
	MVectorArray plantCoords = crdFn.array();
	if(plantCoords.length() < 1) return false;
	
	MDataHandle cotH = block.inputValue(aplantOffsetCache);
	MFnVectorArrayData cotFn(cotH.data());
	MVectorArray plantOffsets = cotFn.array();
		
	return loadPlants(plantTms, plantIds, plantTris, plantCoords, plantOffsets);
}
开发者ID:spinos,项目名称:aphid,代码行数:28,代码来源:ProxyVizNode.cpp

示例5: compute

MStatus arcLen::compute( const MPlug& plug, MDataBlock& data )
{
	
	MStatus status;
 
	if( plug == output )
	{
		MDataHandle inputData = data.inputValue( inputCurve, &status );

		if( !status ) {
			status.perror("ERROR getting data");
		} else {
			MObject curve = inputData.asNurbsCurveTransformed();
			MFnNurbsCurve curveFn( curve, &status ); 
			if( !status ) {
				status.perror("ERROR creating curve function set");
			} else {
				double result = curveFn.length();
				MDataHandle outputHandle = data.outputValue( arcLen::output );
				outputHandle.set( result );
				data.setClean(plug);
			}
		}
	} else {
		return MS::kUnknownParameter;
	}

	return MS::kSuccess;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:29,代码来源:arcLenNode.cpp

示例6:

//-----------------------------------------------------------------------------
MStatus [!output CLASS_NAME]::compute (const MPlug &plug, MDataBlock &data) {
	//- This method computes the value of the given output plug based
	//- on the values of the input attributes.
	//-		plug - the plug to compute
	//-		data - object that provides access to the attributes for this node
 
	//- Check which output attribute we have been asked to compute. If this 
	//- node doesn't know how to compute it, we must return MS::kUnknownParameter
	MStatus returnStatus =MStatus::kUnknownParameter ;
	if ( plug == attr2 ) {
		//- Get a handle to the input attribute that we will need for the
		//- computation. If the value is being supplied via a connection 
		//- in the dependency graph, then this call will cause all upstream  
		//- connections to be evaluated so that the correct value is supplied.
		MDataHandle attr1Data =data.inputValue (attr1, &returnStatus) ;
		if ( returnStatus == MStatus::kSuccess ) {
			//- Read the input value from the handle.
			float result =attr1Data.asFloat () ;
			//- Get a handle to the output attribute. This is similar to the
			//- "inputValue" call above except that no dependency graph 
			//- computation will be done as a result of this call.
			MDataHandle attr2Handle =data.outputValue (attr2) ;
			//- This sample just copies the input value through to the output.  
			attr2Handle.set (result) ;
			//- Mark the destination plug as being clean. This will prevent the
			//- dependency graph from repeating this calculation until an input 
			//- of this node changes.
			data.setClean (plug) ;
		}
	}
	return (returnStatus) ;
}
开发者ID:BigMacchia,项目名称:Maya-Cpp-Wizards,代码行数:33,代码来源:object.cpp

示例7: updateShape

void rigidBodyNode::updateShape(const MPlug& plug, MDataBlock& data, float& collisionMarginOffset)
{
	MObject thisObject(thisMObject());
    MPlug plgCollisionShape(thisObject, ia_collisionShape);
    MObject update;
    //force evaluation of the shape
    plgCollisionShape.getValue(update);

   /* vec3f prevCenter(0, 0, 0);
    quatf prevRotation(qidentity<float>());
    if(m_rigid_body) {
        prevCenter = m_rigid_body->collision_shape()->center();
        prevRotation = m_rigid_body->collision_shape()->rotation();
    }*/

    collision_shape_t::pointer  collision_shape;
	
    if(plgCollisionShape.isConnected()) {
        MPlugArray connections;
        plgCollisionShape.connectedTo(connections, true, true);
        if(connections.length() != 0) {
            MFnDependencyNode fnNode(connections[0].node());
            if(fnNode.typeId() == collisionShapeNode::typeId) {
				collisionShapeNode *pCollisionShapeNode = static_cast<collisionShapeNode*>(fnNode.userNode());
				pCollisionShapeNode->setCollisionMarginOffset(collisionMarginOffset); //mb
                collision_shape = pCollisionShapeNode->collisionShape();
            } else {
                std::cout << "rigidBodyNode connected to a non-collision shape node!" << std::endl;
            }
        }
    }

	data.outputValue(ca_rigidBody).set(true);
    data.setClean(plug);
}
开发者ID:benelot,项目名称:dynamica,代码行数:35,代码来源:rigidBodyNode.cpp

示例8: setOutPlugs

void SurfaceAttach::setOutPlugs(MDataBlock dataBlock, const MFnNurbsSurface &fnSurface,
                                const double dataOffset, const bool dataReverse, const short dataGenus, const double dataStaticLength,
                                const MMatrix &dataParentInverse, const short dataDirection) {

    MTransformationMatrix tfm;
    MVector t;
    MEulerRotation r;

    MArrayDataHandle outputHandle = dataBlock.outputArrayValue(SurfaceAttach::out);
    std::int32_t count = outputHandle.elementCount();
    MDataHandle o;

    for (unsigned int k = 0; k < count; ++k) {
        outputHandle.jumpToElement(k);

        // Get Transformations
        tfm = this->matrix(fnSurface, outputHandle.elementIndex(), dataOffset, dataReverse, dataGenus,
                           dataStaticLength, dataParentInverse, dataDirection);
        t = tfm.translation(MSpace::Space::kWorld);
        r = tfm.eulerRotation();

        o = outputHandle.outputValue();
        o.child(SurfaceAttach::translate).set(t);
        o.child(SurfaceAttach::rotate).set(r.x, r.y, r.z);
    }

    // Mark Clean
    dataBlock.setClean(SurfaceAttach::translate);
    dataBlock.setClean(SurfaceAttach::rotate);
    dataBlock.setClean(SurfaceAttach::out);
}
开发者ID:illmillrig,项目名称:SurfaceAttach,代码行数:31,代码来源:SurfaceAttach.cpp

示例9: compute

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

	// Check which output attribute we have been asked to compute.  If this 
	// node doesn't know how to compute it, we must return 
	// MS::kUnknownParameter.
	// 
	if( plug == outData )
	{
		// Get a handle to the input attribute that we will need for the
		// computation.  If the value is being supplied via a connection 
		// in the dependency graph, then this call will cause all upstream  
		// connections to be evaluated so that the correct value is supplied.
		// 
		MDataHandle inputDataHandle = data.inputValue( voxelData, &stat );

		MObject inputDataObj = inputDataHandle.data();
		
		MFnPluginData fnDataCreator;
		MTypeId tmpid( VoxelPreviewDataWrapper::id );
		VoxelPreviewDataWrapper * newData = NULL;

		MDataHandle outHandle = data.outputValue( outData );	
		newData = (VoxelPreviewDataWrapper*)outHandle.asPluginData();

		if ( newData == NULL ) {
			// Create some output data
			fnDataCreator.create( tmpid, &stat );
			MCHECKERROR( stat, "compute : error creating VoxelPreviewDataWrapper")
				newData = (VoxelPreviewDataWrapper*)fnDataCreator.data( &stat );
			MCHECKERROR( stat, "compute : error getting proxy VoxelPreviewDataWrapper object")
		}
开发者ID:elanifegnirf,项目名称:Sampler,代码行数:32,代码来源:VoxelShape.cpp

示例10: compute

//-----------------------------------------------------------------------
MStatus visualizeMeshNode::compute( const MPlug& plug, MDataBlock& data )
//-----------------------------------------------------------------------
{ 
	MStatus stat;

	// cout << "cvColor::compute\n";

	if ( plug == vtxLocations ) {


		MObject	weightObj = data.inputValue(vtxWeights).data();
		
		MFnDoubleArrayData weightData(weightObj);
		
		vtxWeightArray = weightData.array();
		
		//die displayList muss jetzt auf jeden Fall neu erstellt werden
		listNeedsUpdate = wasInCompute = true;

		stat = data.setClean ( plug );
		if (!stat) {
			stat.perror("visualizeMeshNoder::compute setClean");
			return stat;
		}
	} else {
		return MS::kUnknownParameter;
	}

	return MS::kSuccess;
}
开发者ID:Byron,项目名称:BPT,代码行数:31,代码来源:visualizeMeshNode.cpp

示例11: compute

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

	if (plug == g_aOutputMesh)
	{
		MDataHandle timeData = data.inputValue(g_aTime, &returnStatus);
		McheckErr(returnStatus, "Error getting time data handle\n");
		MTime time = timeData.asTime();

		/* Get output object */

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

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

		createMesh(time, newOutputData, returnStatus);
		if (!returnStatus)
		{
			std::cerr << "ERROR creating new Cube: " << returnStatus.errorString() << std::endl;
			return returnStatus;
		}

		outputHandle.set(newOutputData);
		data.setClean(plug);
	}
	else
		return MS::kUnknownParameter;

	return MS::kSuccess;
}
开发者ID:davvm,项目名称:clothSim,代码行数:34,代码来源:ClothSimMayaPlugin.cpp

示例12: 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

示例13: compute

MStatus Trimmer::compute( const MPlug& plug, MDataBlock& data )
//
//	Description:
//		This method computes the value of the given output plug based
//		on the values of the input attributes.
//
//	Arguments:
//		plug - the plug to compute
//		data - object that provides access to the attributes for this node
//
{
    if ( plug == outputData ) {
        MStatus stat;

        MDataHandle inDataHandle = data.inputValue( Trimmer::inputData, &stat );
        MDataHandle outDataHandle = data.outputValue( Trimmer::outputData, &stat );

        GrowerData* growerData = static_cast< GrowerData* >( inDataHandle.asPluginData() );
        if ( growerData == NULL ) {
            cerr << "Trimmer: error retrieving data" << endl;
            return MS::kFailure;
        }

        int maxDepth = GetMaxDepth( growerData->nodes );
        int length = (int)ceilf( (float)maxDepth * data.inputValue( Trimmer::maxLength ).asFloat() ) + 1;

        Trim( growerData->nodes, length );

        outDataHandle.setMPxData( growerData );
        data.setClean( plug );
        return MS::kSuccess;
    }

    return MS::kUnknownParameter;
}
开发者ID:pyrochlore,项目名称:Grower,代码行数:35,代码来源:TrimmerNode.cpp

示例14: compute

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

	MDataHandle hOutputMatrix = data.outputValue( aOutputMatrix, &status );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	MDataHandle hOutputInverseMatrix = data.outputValue( aOutputInverseMatrix, &status );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	MDataHandle hTransMatrix = data.inputValue( aInputTransMatrix, &status );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	MDataHandle hRotateMatrix = data.inputValue( aInputRotateMatrix, &status );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	MMatrix transMatrix = hTransMatrix.asMatrix();
	MMatrix rotateMatrix = hRotateMatrix.asMatrix();

	double buildMatrix[4][4] = { rotateMatrix( 0,0 ), rotateMatrix( 0,1 ), rotateMatrix( 0,2 ), 0,
		                         rotateMatrix( 1,0 ), rotateMatrix( 1,1 ), rotateMatrix( 1,2 ), 0,
								 rotateMatrix( 2,0 ), rotateMatrix( 2,1 ), rotateMatrix( 2,2 ), 0,
								 transMatrix( 3,0 ),  transMatrix( 3,1 ),  transMatrix( 3,2 ),  1 };

	MMatrix buildMtx = buildMatrix;
	
	if( plug == aOutputMatrix )
		hOutputMatrix.set( buildMtx );
	if( plug == aOutputInverseMatrix )
		hOutputInverseMatrix.set( buildMtx.inverse() );

	data.setClean( plug );

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

示例15: compute

MStatus RemapArrayValuesNode::compute(const MPlug& plug, MDataBlock& data)
{
    if (plug != aOutput)
        return MS::kUnknownParameter;

    MStatus status;

    MFnDoubleArrayData input(data.inputValue(aInput).data());
    float inputMin = float(data.inputValue(aInputMin).asDouble());
    float inputMax = float(data.inputValue(aInputMax).asDouble());
    float outputMin = float(data.inputValue(aOutputMin).asDouble());
    float outputMax = float(data.inputValue(aOutputMax).asDouble());

    int size = input.length();
    MDoubleArray outputArray(size);
    
    MRampAttribute ramp(thisMObject(), aRamp, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    MFloatArray positions;
    MFloatArray values;
    MIntArray interps;
    MIntArray indices;

    ramp.getEntries(indices, positions, values, interps);

    int numIndices = indices.length();

    float inValue = 0.0;
    float outValue = 0.0;

    for (int i = 0; i < size; i++)
    {
        inValue = float(input[i]);
        
        inValue = remapValue(inValue, inputMin, inputMax);

        if (numIndices > 0)
        {
            ramp.getValueAtPosition(inValue, outValue, &status);
            CHECK_MSTATUS_AND_RETURN_IT(status);
        } else {
            outValue = inValue;
        }

        outValue = remapValue(outValue, 0.0, 1.0, outputMin, outputMax);

        outputArray.set(double(outValue), i);
    }

    MDataHandle outputHandle = data.outputValue(aOutput);
    MFnDoubleArrayData output;
    MObject outputData = output.create(outputArray);

    outputHandle.setMObject(outputData);
    outputHandle.setClean();

    return MS::kSuccess;
}
开发者ID:sonictk,项目名称:arrayNodes,代码行数:59,代码来源:n_remap.cpp


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