bool CBigStashPaser::parseVersion( CBigStash& ar_oBigStash ) { if( m_nIndex >= m_nDataLength ) { return false; } unsigned short lo_nVersion = getShortValue( m_pBigStashDatas, m_nDataLength, m_nIndex ); ar_oBigStash.Version( lo_nVersion ); m_nIndex += 2; return true; }
bool CBigStashPaser::parsePage( CBigStashPage& ar_oPage ) { if( m_nIndex >= m_nDataLength ) { return false; } /// 跳过页首 m_nIndex += g_scnPageHeaderLength; int lo_nNextPage = findNextPageHeader(); if( lo_nNextPage < 0 ) { lo_nNextPage = m_nDataLength; } int lo_nPageEnd = lo_nNextPage; unsigned short lo_sItemSize = getShortValue( m_pBigStashDatas, m_nDataLength, m_nIndex ); m_nIndex += 2; if( lo_sItemSize > 0 ) { ar_oPage.ItemSize(lo_sItemSize); int lo_nStartItem = findNextItem( m_nIndex, lo_nPageEnd ); if( lo_nStartItem < 0 ) { AfxMessageBox("未找到任何物品信息"); return false; } for( unsigned i = 0; i < ar_oPage.ItemSize(); ++i ) { if( lo_nStartItem >= lo_nPageEnd ) { CString lo_strErrorInfo; lo_strErrorInfo.Format(_T("物品%d解析错误"), i ); AfxMessageBox(lo_strErrorInfo); return false; } CBigStashItem lo_oItem; int lo_nNextItem = findNextItem( lo_nStartItem+sizeof(g_scbItemIdentifiedHeader)/sizeof(g_scbItemIdentifiedHeader[0]), lo_nPageEnd ); BYTE lo_bLocation = m_pBigStashDatas[lo_nNextItem+7]&0x1C; while( lo_bLocation == 0x18 ) { lo_nNextItem = findNextItem( lo_nNextItem+sizeof(g_scbItemIdentifiedHeader)/sizeof(g_scbItemIdentifiedHeader[0]), lo_nPageEnd ); if( lo_nNextItem < 0 ) { break; } lo_bLocation = m_pBigStashDatas[lo_nNextItem+7]&0x1C; } if( lo_nNextItem < 0 ) { lo_nNextItem = lo_nPageEnd; } if( i == ar_oPage.ItemSize()-1 && lo_nNextItem != lo_nPageEnd ) { AfxMessageBox(_T("物品信息解析错误")); return false; } int lo_nItemBufferSize = lo_nNextItem-lo_nStartItem; lo_oItem.setItemBuffer( m_pBigStashDatas, lo_nStartItem, lo_nItemBufferSize ); lo_nStartItem = lo_nNextItem; ar_oPage.setItem( i, lo_oItem ); } } m_nIndex = lo_nPageEnd; return true; }
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") }