本文整理汇总了C++中MDataHandle::asPluginData方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asPluginData方法的具体用法?C++ MDataHandle::asPluginData怎么用?C++ MDataHandle::asPluginData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::asPluginData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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")
}
示例2: 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;
}
示例3: compute
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")
}