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") }
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; }
MStatus NuiMayaDeviceGrabber::compute( const MPlug& plug, MDataBlock& datablock ) // // 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 // { assert(m_pCache); if(!m_pCache) return MS::kFailure; MStatus returnStatus; /* Get time */ MDataHandle timeData = datablock.inputValue( aTime, &returnStatus ); MCHECKERROR(returnStatus, "Error getting time data handle\n") MTime time = timeData.asTime(); //!< 30 frames per second int frame = (int)time.as( MTime::kNTSCFrame ) - 1;//Noted: The first frame in MAYA is 1; if(m_pDevice) { std::shared_ptr<NuiCompositeFrame> pFrame = m_pDevice->popFrame(); if(pFrame) { pFrame->m_depthFrame.SetMinDepth(getShortValue(aMinDepth)); pFrame->m_depthFrame.SetMaxDepth(getShortValue(aMaxDepth)); if(m_pSLAM /*&& m_pSLAM->m_tracker.isThreadOn()*/) { std::shared_ptr<NuiVisualFrame> pVisualFrame = std::make_shared<NuiVisualFrame>(); pVisualFrame->acquireFromCompositeFrame(pFrame.get()); m_pSLAM->m_tracker.pushbackFrame(pVisualFrame); pVisualFrame.reset(); } m_pCache->pushbackFrame(pFrame); pFrame.reset(); } } std::shared_ptr<NuiCompositeFrame> pCurrentFrame = m_pCache->getLatestFrame(); if ( plug == aOutputMappable ) { std::shared_ptr<NuiCLMappableData> clData(nullptr); MDataHandle outHandle = datablock.outputValue( aOutputMappable ); NuiMayaMappableData* clmData = static_cast<NuiMayaMappableData*>(outHandle.asPluginData()); if(!clmData) { // Create some user defined geometry data and access the // geometry so we can set it // MFnPluginData fnDataCreator; MTypeId tmpid( NuiMayaMappableData::id ); fnDataCreator.create( tmpid, &returnStatus ); MCHECKERROR( returnStatus, "compute : error creating mappableData") clmData = (NuiMayaMappableData*)fnDataCreator.data( &returnStatus ); MCHECKERROR( returnStatus, "compute : error gettin at proxy mappableData object") clData = std::shared_ptr<NuiCLMappableData>(new NuiCLMappableData()); clmData->setData(clData); returnStatus = outHandle.set( clmData ); MCHECKERROR( returnStatus, "compute : error gettin at proxy mappableData object") }