Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

754 lines
20 KiB

  1. //===== Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ====
  2. //
  3. // Animation commands
  4. //
  5. //==========================================================================
  6. // Valve includes
  7. #include "datamodel/dmelementfactoryhelper.h"
  8. #include "movieobjects/dmemodel.h"
  9. #include "movieobjects/dmedrawsettings.h"
  10. #include "mdlobjects/dmeanimcmd.h"
  11. #include "mdlobjects/dmebodygroup.h"
  12. #include "mdlobjects/dmebodygrouplist.h"
  13. #include "mdlobjects/dmelodlist.h"
  14. #include "mdlobjects/dmematsysroot.h"
  15. #include "mdlobjects/dmesequence.h"
  16. #include "mdlobjects/dmesequencelist.h"
  17. #include "tier1/utldict.h"
  18. #include "bone_setup.h"
  19. // memdbgon must be the last include file in a .cpp file!!!
  20. #include "tier0/memdbgon.h"
  21. //=============================================================================
  22. // CDmeMatSysSettings
  23. //=============================================================================
  24. IMPLEMENT_ELEMENT_FACTORY( DmeMatSysPanelSettings, CDmeMatSysPanelSettings );
  25. //-----------------------------------------------------------------------------
  26. //
  27. //-----------------------------------------------------------------------------
  28. void CDmeMatSysPanelSettings::OnConstruction()
  29. {
  30. m_cBackgroundColor.InitAndSet( this, "backgroundColor", Color( 0.3f, 0.3f, 0.3f ) );
  31. m_cAmbientColor.InitAndSet( this, "ambientColor", Color( 0.3f, 0.3f, 0.3f ) );
  32. m_bDrawGroundPlane.InitAndSet( this, "drawGroundPlane", true );
  33. m_bDrawOriginAxis.InitAndSet( this, "drawOriginAxis", true );
  34. }
  35. //-----------------------------------------------------------------------------
  36. //
  37. //-----------------------------------------------------------------------------
  38. void CDmeMatSysPanelSettings::OnDestruction()
  39. {
  40. }
  41. //=============================================================================
  42. // CDmeMatSysSettings
  43. //=============================================================================
  44. IMPLEMENT_ELEMENT_FACTORY( DmeMatSysRoot, CDmeMatSysRoot );
  45. //-----------------------------------------------------------------------------
  46. //
  47. //-----------------------------------------------------------------------------
  48. void CDmeMatSysRoot::OnConstruction()
  49. {
  50. m_Settings.InitAndCreate( this, "settings" );
  51. }
  52. //-----------------------------------------------------------------------------
  53. //
  54. //-----------------------------------------------------------------------------
  55. void CDmeMatSysRoot::OnDestruction()
  56. {
  57. }
  58. //=============================================================================
  59. // IDmeMatSysModel
  60. //=============================================================================
  61. //-----------------------------------------------------------------------------
  62. //
  63. //-----------------------------------------------------------------------------
  64. int IDmeMatSysModel::SelectSequence( const char *pszSequenceName )
  65. {
  66. Assert( 0 );
  67. return -1;
  68. }
  69. //-----------------------------------------------------------------------------
  70. //
  71. //-----------------------------------------------------------------------------
  72. void IDmeMatSysModel::SetTime( DmeTime_t dmeTime )
  73. {
  74. Assert( 0 );
  75. return;
  76. }
  77. //-----------------------------------------------------------------------------
  78. //
  79. //-----------------------------------------------------------------------------
  80. void IDmeMatSysModel::SetFrame( float flFrame )
  81. {
  82. Assert( 0 );
  83. return;
  84. }
  85. //=============================================================================
  86. // CDmeMatSysMDLDag
  87. //=============================================================================
  88. IMPLEMENT_ELEMENT_FACTORY( DmeMatSysMDLDag, CDmeMatSysMDLDag );
  89. //-----------------------------------------------------------------------------
  90. //
  91. //-----------------------------------------------------------------------------
  92. void CDmeMatSysMDLDag::OnConstruction()
  93. {
  94. CDmeMDL *pDmeMDL = CreateElement< CDmeMDL >( CUtlString( GetName() ) + "Shape", GetFileId() );
  95. if ( pDmeMDL )
  96. {
  97. pDmeMDL->DrawInEngine( true );
  98. SetShape( pDmeMDL );
  99. }
  100. }
  101. //-----------------------------------------------------------------------------
  102. //
  103. //-----------------------------------------------------------------------------
  104. void CDmeMatSysMDLDag::OnDestruction()
  105. {
  106. }
  107. //-----------------------------------------------------------------------------
  108. //
  109. //-----------------------------------------------------------------------------
  110. studiohdr_t *CDmeMatSysMDLDag::GetStudioHdr() const
  111. {
  112. CDmeMDL *pDmeMDL = GetDmeMDL();
  113. if ( !pDmeMDL )
  114. return NULL;
  115. const MDLHandle_t hMDL = pDmeMDL->GetMDL();
  116. if ( hMDL == MDLHANDLE_INVALID || g_pMDLCache->IsErrorModel( hMDL ) )
  117. return NULL;
  118. return g_pMDLCache->GetStudioHdr( hMDL );
  119. }
  120. //-----------------------------------------------------------------------------
  121. //
  122. //-----------------------------------------------------------------------------
  123. void CDmeMatSysMDLDag::GetSequenceList( CUtlVector< CUtlString > *pOutList )
  124. {
  125. if ( !pOutList )
  126. return;
  127. pOutList->RemoveAll();
  128. studiohdr_t *pStudioHdr = GetStudioHdr();
  129. if ( !pStudioHdr )
  130. return;
  131. for ( int j = 0; j < pStudioHdr->GetNumSeq(); ++j )
  132. {
  133. if ( !( pStudioHdr->pSeqdesc( j ).flags & STUDIO_HIDDEN ) )
  134. {
  135. const char *pszSequenceName = pStudioHdr->pSeqdesc(j).pszLabel();
  136. if ( pszSequenceName && pszSequenceName[0] )
  137. {
  138. pOutList->AddToTail( pszSequenceName );
  139. }
  140. }
  141. }
  142. }
  143. //-----------------------------------------------------------------------------
  144. //
  145. //-----------------------------------------------------------------------------
  146. void CDmeMatSysMDLDag::GetActivityList( CUtlVector< CUtlString > *pOutList )
  147. {
  148. pOutList->RemoveAll();
  149. studiohdr_t *pStudioHdr = GetStudioHdr();
  150. if ( !pStudioHdr )
  151. return;
  152. CUtlDict<int, unsigned short> activityNames( true, 0, pStudioHdr->GetNumSeq() );
  153. for ( int j = 0; j < pStudioHdr->GetNumSeq(); ++j )
  154. {
  155. if ( !( pStudioHdr->pSeqdesc( j ).flags & STUDIO_HIDDEN ) )
  156. {
  157. const char *pszActivityName = pStudioHdr->pSeqdesc( j ).pszActivityName();
  158. if ( pszActivityName && pszActivityName[0] )
  159. {
  160. // Multiple sequences can have the same activity name; only add unique activity names
  161. if ( activityNames.Find( pszActivityName ) == activityNames.InvalidIndex() )
  162. {
  163. pOutList->AddToTail( pszActivityName );
  164. activityNames.Insert( pszActivityName, j );
  165. }
  166. }
  167. }
  168. }
  169. }
  170. //-----------------------------------------------------------------------------
  171. //
  172. //-----------------------------------------------------------------------------
  173. int CDmeMatSysMDLDag::SelectSequence( const char *pszSequenceName )
  174. {
  175. if ( !pszSequenceName || !pszSequenceName[0] )
  176. return -1;
  177. CDmeMDL *pDmeMdl = GetDmeMDL();
  178. studiohdr_t *pStudioHdr = GetStudioHdr();
  179. if ( !pStudioHdr )
  180. return -1;
  181. pDmeMdl->m_nSequence = -1;
  182. for ( int i = 0; i < pStudioHdr->GetNumSeq(); ++i )
  183. {
  184. mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( i );
  185. if ( !Q_stricmp( seqdesc.pszLabel(), pszSequenceName ) )
  186. {
  187. pDmeMdl->m_nSequence = i;
  188. break;
  189. }
  190. }
  191. if ( pDmeMdl->m_nSequence < 0 )
  192. {
  193. pDmeMdl->m_nSequence = 0;
  194. return -1;
  195. }
  196. CStudioHdr cStudioHdr( pStudioHdr, g_pMDLCache );
  197. float flPoseParameter[MAXSTUDIOPOSEPARAM];
  198. Studio_CalcDefaultPoseParameters( &cStudioHdr, flPoseParameter, MAXSTUDIOPOSEPARAM );
  199. int nFrameCount = Studio_MaxFrame( &cStudioHdr, pDmeMdl->m_nSequence, flPoseParameter );
  200. if ( nFrameCount == 0 )
  201. {
  202. nFrameCount = 1;
  203. }
  204. return nFrameCount;
  205. }
  206. //-----------------------------------------------------------------------------
  207. //
  208. //-----------------------------------------------------------------------------
  209. void CDmeMatSysMDLDag::SetTime( DmeTime_t dmeTime )
  210. {
  211. CDmeMDL *pDmeMDL = GetDmeMDL();
  212. if ( !pDmeMDL )
  213. return;
  214. pDmeMDL->m_flTime = dmeTime.GetSeconds();
  215. }
  216. //-----------------------------------------------------------------------------
  217. //
  218. //-----------------------------------------------------------------------------
  219. void CDmeMatSysMDLDag::SetFrame( float flFrame )
  220. {
  221. CDmeMDL *pDmeMDL = GetDmeMDL();
  222. if ( !pDmeMDL )
  223. return;
  224. pDmeMDL->m_flTime = flFrame / pDmeMDL->m_flPlaybackRate;
  225. }
  226. //-----------------------------------------------------------------------------
  227. //
  228. //-----------------------------------------------------------------------------
  229. void CDmeMatSysMDLDag::SetMDL( MDLHandle_t hMDL )
  230. {
  231. CDmeMDL *pDmeMDL = GetDmeMDL();
  232. if ( !pDmeMDL )
  233. return;
  234. pDmeMDL->SetMDL( hMDL );
  235. }
  236. //-----------------------------------------------------------------------------
  237. //
  238. //-----------------------------------------------------------------------------
  239. MDLHandle_t CDmeMatSysMDLDag::GetMDL() const
  240. {
  241. CDmeMDL *pDmeMDL = GetDmeMDL();
  242. if ( !pDmeMDL )
  243. return MDLHANDLE_INVALID;
  244. return pDmeMDL->GetMDL();
  245. }
  246. //-----------------------------------------------------------------------------
  247. //
  248. //-----------------------------------------------------------------------------
  249. CDmeMDL *CDmeMatSysMDLDag::GetDmeMDL() const
  250. {
  251. return CastElement< CDmeMDL >( m_Shape );
  252. }
  253. //=============================================================================
  254. // CDmeMatSysDMXDag
  255. //=============================================================================
  256. IMPLEMENT_ELEMENT_FACTORY( DmeMatSysDMXDag, CDmeMatSysDMXDag );
  257. //-----------------------------------------------------------------------------
  258. //
  259. //-----------------------------------------------------------------------------
  260. void CDmeMatSysDMXDag::OnConstruction()
  261. {
  262. m_eDmxRoot.InitAndSet( this, "dmxRoot", DMELEMENT_HANDLE_INVALID );
  263. m_hDmxModel = DMELEMENT_HANDLE_INVALID;
  264. }
  265. //-----------------------------------------------------------------------------
  266. //
  267. //-----------------------------------------------------------------------------
  268. void CDmeMatSysDMXDag::OnDestruction()
  269. {
  270. }
  271. //-----------------------------------------------------------------------------
  272. //
  273. //-----------------------------------------------------------------------------
  274. void CDmeMatSysDMXDag::Draw( CDmeDrawSettings *pDrawSettings /* = NULL */ )
  275. {
  276. if ( !m_Visible )
  277. return;
  278. // This is meant to be called from mixed rendering environment and
  279. // DmeMesh windings are backwards relative to MDL windings
  280. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  281. pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
  282. BaseClass::Draw( pDrawSettings );
  283. pRenderContext->CullMode( MATERIAL_CULLMODE_CCW );
  284. }
  285. //-----------------------------------------------------------------------------
  286. //
  287. //-----------------------------------------------------------------------------
  288. void CDmeMatSysDMXDag::GetSequenceList( CUtlVector< CUtlString > *pOutList )
  289. {
  290. // TODO: Look for sequences in the DMX file
  291. Assert( 0 );
  292. pOutList->RemoveAll();
  293. }
  294. //-----------------------------------------------------------------------------
  295. //
  296. //-----------------------------------------------------------------------------
  297. void CDmeMatSysDMXDag::GetActivityList( CUtlVector< CUtlString > *pOutList )
  298. {
  299. // DMX Model files don't have any activities
  300. pOutList->RemoveAll();
  301. }
  302. //-----------------------------------------------------------------------------
  303. //
  304. //-----------------------------------------------------------------------------
  305. void CDmeMatSysDMXDag::SetDmxRoot( CDmElement *pDmxRoot )
  306. {
  307. m_eDmxRoot.Set( pDmxRoot );
  308. // Remove old DmeModel child
  309. if ( m_hDmxModel != DMELEMENT_HANDLE_INVALID )
  310. {
  311. for ( int i = 0; i < GetChildCount(); ++i )
  312. {
  313. CDmeDag *pDmeDag = GetChild( i );
  314. if ( !pDmeDag )
  315. continue;
  316. if ( pDmeDag->GetHandle() == m_hDmxModel )
  317. {
  318. RemoveChild( i );
  319. break;
  320. }
  321. }
  322. }
  323. m_hDmxModel = DMELEMENT_HANDLE_INVALID;
  324. matrix3x4_t mIdentity;
  325. SetIdentityMatrix( mIdentity );
  326. GetTransform()->SetTransform( mIdentity );
  327. if ( pDmxRoot )
  328. {
  329. CDmeModel *pDmeModel = pDmxRoot->GetValueElement< CDmeModel >( "model" );
  330. if ( pDmeModel )
  331. {
  332. if ( !pDmeModel->IsZUp() )
  333. {
  334. GetTransform()->SetTransform(
  335. matrix3x4_t(
  336. 0.0f, 0.0f, 1.0f, 0.0f,
  337. 1.0f, 0.0f, 0.0f, 0.0f,
  338. 0.0f, 1.0f, 0.0f, 0.0f ) );
  339. }
  340. m_hDmxModel = pDmeModel->GetHandle();
  341. AddChild( pDmeModel );
  342. }
  343. }
  344. }
  345. //=============================================================================
  346. // CDmeMatSysMPPDag
  347. //=============================================================================
  348. IMPLEMENT_ELEMENT_FACTORY( DmeMatSysMPPDag, CDmeMatSysMPPDag );
  349. //-----------------------------------------------------------------------------
  350. //
  351. //-----------------------------------------------------------------------------
  352. void CDmeMatSysMPPDag::OnConstruction()
  353. {
  354. m_eMppRoot.InitAndSet( this, "mppRoot", DMELEMENT_HANDLE_INVALID );
  355. m_hDmeBodyGroupList = DMELEMENT_HANDLE_INVALID;
  356. m_hDmeSequenceList = DMELEMENT_HANDLE_INVALID;
  357. }
  358. //-----------------------------------------------------------------------------
  359. //
  360. //-----------------------------------------------------------------------------
  361. void CDmeMatSysMPPDag::OnDestruction()
  362. {
  363. }
  364. //-----------------------------------------------------------------------------
  365. //
  366. //-----------------------------------------------------------------------------
  367. void CDmeMatSysMPPDag::Draw( CDmeDrawSettings *pDrawSettings /* = NULL */ )
  368. {
  369. if ( !m_Visible )
  370. return;
  371. // This is meant to be called from mixed rendering environment and
  372. // DmeMesh windings are backwards relative to MDL windings
  373. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  374. pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
  375. BaseClass::Draw( pDrawSettings );
  376. pRenderContext->CullMode( MATERIAL_CULLMODE_CCW );
  377. }
  378. //-----------------------------------------------------------------------------
  379. //
  380. //-----------------------------------------------------------------------------
  381. void CDmeMatSysMPPDag::GetSequenceList( CUtlVector< CUtlString > *pOutList )
  382. {
  383. pOutList->RemoveAll();
  384. if ( !m_eMppRoot )
  385. return;
  386. CDmeSequenceList *pDmeSequenceList = m_eMppRoot->GetValueElement< CDmeSequenceList >( "sequenceList" );
  387. if ( !pDmeSequenceList )
  388. return;
  389. CUtlVector< CDmeSequenceBase * > sortedSequenceList;
  390. pDmeSequenceList->GetSortedSequenceList( sortedSequenceList );
  391. for ( int i = 0; i < sortedSequenceList.Count(); ++i )
  392. {
  393. pOutList->AddToTail( sortedSequenceList[i]->GetName() );
  394. }
  395. }
  396. //-----------------------------------------------------------------------------
  397. //
  398. //-----------------------------------------------------------------------------
  399. void CDmeMatSysMPPDag::GetActivityList( CUtlVector< CUtlString > *pOutList )
  400. {
  401. pOutList->RemoveAll();
  402. if ( !m_eMppRoot )
  403. return;
  404. CDmeSequenceList *pDmeSequenceList = m_eMppRoot->GetValueElement< CDmeSequenceList >( "sequenceList" );
  405. if ( !pDmeSequenceList )
  406. return;
  407. CUtlVector< CDmeSequenceBase * > sortedSequenceList;
  408. pDmeSequenceList->GetSortedSequenceList( sortedSequenceList );
  409. CUtlDict<int, unsigned short> activityNames( true, 0, sortedSequenceList.Count() );
  410. for ( int i = 0; i < sortedSequenceList.Count(); ++i )
  411. {
  412. const char *pszActivityName = sortedSequenceList[i]->m_eActivity->GetName();
  413. if ( pszActivityName && pszActivityName[0] )
  414. {
  415. // Multiple sequences can have the same activity name; only add unique activity names
  416. if ( activityNames.Find( pszActivityName ) == activityNames.InvalidIndex() )
  417. {
  418. pOutList->AddToTail( pszActivityName );
  419. activityNames.Insert( pszActivityName, i );
  420. }
  421. }
  422. }
  423. }
  424. //-----------------------------------------------------------------------------
  425. //
  426. //-----------------------------------------------------------------------------
  427. CUtlString UniqueIdToString( const UniqueId_t &uniqueId )
  428. {
  429. char buf[64];
  430. UniqueIdToString( uniqueId, buf, ARRAYSIZE( buf ) );
  431. return CUtlString( buf );
  432. }
  433. //-----------------------------------------------------------------------------
  434. //
  435. //-----------------------------------------------------------------------------
  436. void CDmeMatSysMPPDag::SetMppRoot( CDmElement *pMppRoot )
  437. {
  438. m_eMppRoot.Set( pMppRoot );
  439. RemoveNullAndImplicitChildren();
  440. m_hDmeBodyGroupList = DMELEMENT_HANDLE_INVALID;
  441. m_hDmeSequenceList = DMELEMENT_HANDLE_INVALID;
  442. matrix3x4_t mIdentity;
  443. SetIdentityMatrix( mIdentity );
  444. GetTransform()->SetTransform( mIdentity );
  445. if ( pMppRoot )
  446. {
  447. CDmeBodyGroupList *pDmeBodyGroupList = pMppRoot->GetValueElement< CDmeBodyGroupList >( "bodyGroupList" );
  448. if ( pDmeBodyGroupList )
  449. {
  450. m_hDmeBodyGroupList = pDmeBodyGroupList->GetHandle();
  451. }
  452. CDmeSequenceList *pDmeSequenceList = pMppRoot->GetValueElement< CDmeSequenceList >( "sequenceList" );
  453. if ( pDmeSequenceList )
  454. {
  455. m_hDmeSequenceList = pDmeSequenceList->GetHandle();
  456. }
  457. bool bZUp = true;
  458. for ( int i = 0; i < pDmeBodyGroupList->m_BodyGroups.Count(); ++i )
  459. {
  460. CDmeBodyGroup *pDmeBodyGroup = pDmeBodyGroupList->m_BodyGroups[i];
  461. if ( !pDmeBodyGroup )
  462. continue;
  463. CDmeDag *pDmeBodyGroupDag = CreateElement< CDmeDag >( pDmeBodyGroup->GetName(), pDmeBodyGroup->GetFileId() );
  464. AddChild( pDmeBodyGroupDag );
  465. m_hChildren.AddToTail( pDmeBodyGroupDag->GetHandle() );
  466. for ( int j = 0; j < pDmeBodyGroup->m_BodyParts.Count(); ++j )
  467. {
  468. CDmeBodyPart *pDmeBodyPart = pDmeBodyGroup->m_BodyParts[j];
  469. if ( !pDmeBodyPart )
  470. continue;
  471. CDmeLODList *pDmeLODList = CastElement< CDmeLODList >( pDmeBodyPart );
  472. if ( !pDmeLODList )
  473. continue;
  474. for ( int k = 0; k < pDmeLODList->m_LODs.Count(); ++k )
  475. {
  476. CDmeLOD *pDmeLOD = pDmeLODList->m_LODs[k];
  477. if ( !pDmeLOD )
  478. continue;
  479. CDmeModel *pDmeModel = pDmeLOD->m_Model;
  480. if ( !pDmeModel )
  481. continue;
  482. pDmeBodyGroupDag->AddChild( pDmeModel );
  483. if ( !pDmeModel->IsZUp() )
  484. bZUp = false;
  485. }
  486. }
  487. }
  488. if ( !bZUp )
  489. {
  490. GetTransform()->SetTransform(
  491. matrix3x4_t(
  492. 0.0f, 0.0f, 1.0f, 0.0f,
  493. 1.0f, 0.0f, 0.0f, 0.0f,
  494. 0.0f, 1.0f, 0.0f, 0.0f ) );
  495. }
  496. }
  497. }
  498. //-----------------------------------------------------------------------------
  499. //
  500. //-----------------------------------------------------------------------------
  501. int CDmeMatSysMPPDag::SelectSequence( const char *pszSequenceName )
  502. {
  503. m_hDmeSequence = DMELEMENT_HANDLE_INVALID;
  504. m_dmeOperatorList.RemoveAll();
  505. if ( !pszSequenceName || !pszSequenceName[0] )
  506. return -1;
  507. if ( !m_eMppRoot )
  508. return -1;
  509. CDmeSequenceList *pDmeSequenceList = m_eMppRoot->GetValueElement< CDmeSequenceList >( "sequenceList" );
  510. if ( !pDmeSequenceList )
  511. return -1;
  512. CUtlVector< CDmeSequenceBase * > sortedSequenceList;
  513. for ( int i = 0; i < pDmeSequenceList->m_Sequences.Count(); ++i )
  514. {
  515. CDmeSequenceBase *pDmeSequenceBase = pDmeSequenceList->m_Sequences[i];
  516. if ( pDmeSequenceBase && !Q_stricmp( pszSequenceName, pDmeSequenceBase->GetName() ) )
  517. {
  518. CDmeSequence *pDmeSequence = CastElement< CDmeSequence >( pDmeSequenceBase );
  519. if ( !pDmeSequence )
  520. continue;
  521. m_hDmeSequence = pDmeSequence->GetHandle();
  522. pDmeSequence->PrepareChannels( m_dmeOperatorList );
  523. return pDmeSequence->GetFrameCount();
  524. }
  525. }
  526. return -1;
  527. }
  528. //-----------------------------------------------------------------------------
  529. //
  530. //-----------------------------------------------------------------------------
  531. void CDmeMatSysMPPDag::SetTime( DmeTime_t dmeTime )
  532. {
  533. CDmeSequence *pDmeSequence = CastElement< CDmeSequence >( g_pDataModel->GetElement( m_hDmeSequence ) );
  534. if ( !pDmeSequence )
  535. return;
  536. pDmeSequence->UpdateChannels( m_dmeOperatorList, dmeTime );
  537. CUtlStack< CDmeDag * > depthFirstStack;
  538. depthFirstStack.Push( this );
  539. while ( depthFirstStack.Count() > 0 )
  540. {
  541. CDmeDag *pDmeDag = NULL;
  542. depthFirstStack.Pop( pDmeDag );
  543. if ( !pDmeDag )
  544. continue;
  545. for ( int i = pDmeDag->GetChildCount() - 1; i >= 0; --i )
  546. {
  547. depthFirstStack.Push( pDmeDag->GetChild( i ) );
  548. }
  549. if ( !Q_stricmp( pDmeDag->GetName(), "root" ) )
  550. {
  551. CDmeTransform *pDmeTransform = pDmeDag->GetTransform();
  552. if ( !pDmeTransform )
  553. continue;
  554. }
  555. }
  556. }
  557. //-----------------------------------------------------------------------------
  558. //
  559. //-----------------------------------------------------------------------------
  560. void CDmeMatSysMPPDag::SetFrame( float flFrame )
  561. {
  562. // TODO: Handle a frame rate, Assume 30 fps :(
  563. SetTime( DmeTime_t( flFrame / 30.0f ) );
  564. }
  565. //-----------------------------------------------------------------------------
  566. //
  567. //-----------------------------------------------------------------------------
  568. void CDmeMatSysMPPDag::RemoveNullAndImplicitChildren()
  569. {
  570. // Clean up all automatically added children
  571. CUtlStack< int > childRemoveStack;
  572. for ( int i = 0; i < GetChildCount(); ++i )
  573. {
  574. CDmeDag *pDmeDag = GetChild( i );
  575. if ( pDmeDag )
  576. {
  577. for ( int j = 0; j < m_hChildren.Count(); ++j )
  578. {
  579. if ( pDmeDag->GetHandle() == m_hChildren[j] )
  580. {
  581. childRemoveStack.Push( i );
  582. }
  583. }
  584. }
  585. else
  586. {
  587. // Remove NULL Children
  588. childRemoveStack.Push( i );
  589. }
  590. }
  591. for ( int i = 0; i < childRemoveStack.Count(); ++i )
  592. {
  593. RemoveChild( childRemoveStack.Top() );
  594. childRemoveStack.Pop();
  595. }
  596. m_hChildren.RemoveAll();
  597. }