@@ -341,6 +341,11 @@ void USDViewer::LoadStage()
341
341
{
342
342
m_Camera.SetRotation (PI_F * 3 .f / 4 .f , PI_F / 6 .f );
343
343
}
344
+
345
+ m_Stage.Animation .TimeCodesPerSecond = m_Stage.Stage ->GetTimeCodesPerSecond ();
346
+ m_Stage.Animation .StartTime = static_cast <float >(m_Stage.Stage ->GetStartTimeCode () / m_Stage.Animation .TimeCodesPerSecond );
347
+ m_Stage.Animation .EndTime = static_cast <float >(m_Stage.Stage ->GetEndTimeCode () / m_Stage.Animation .TimeCodesPerSecond );
348
+ m_Stage.Animation .Time = m_Stage.Animation .StartTime ;
344
349
}
345
350
346
351
// Render a frame
@@ -539,6 +544,19 @@ void USDViewer::UpdateUI()
539
544
}
540
545
}
541
546
547
+ if (m_Stage.Animation .EndTime > m_Stage.Animation .StartTime )
548
+ {
549
+ ImGui::Spacing ();
550
+
551
+ ImGui::SetNextItemOpen (true , ImGuiCond_FirstUseEver);
552
+ if (ImGui::TreeNode (" Animation" ))
553
+ {
554
+ ImGui::Checkbox (" Play" , &m_Stage.Animation .Play );
555
+ ImGui::SliderFloat (" Time" , &m_Stage.Animation .Time , m_Stage.Animation .StartTime , m_Stage.Animation .EndTime );
556
+ ImGui::TreePop ();
557
+ }
558
+ }
559
+
542
560
ImGui::Spacing ();
543
561
544
562
ImGui::SetNextItemOpen (true , ImGuiCond_FirstUseEver);
@@ -827,9 +845,23 @@ void USDViewer::Update(double CurrTime, double ElapsedTime)
827
845
m_Camera.SetZoomSpeed (m_Camera.GetDist () * 0 .1f );
828
846
m_Camera.Update (m_InputController);
829
847
UpdateCamera ();
848
+
849
+ const float LastAnimationTime = m_Stage.Animation .Time ;
850
+ if (m_Stage.Animation .Play )
851
+ {
852
+ m_Stage.Animation .Time += static_cast <float >(ElapsedTime);
853
+ if (m_Stage.Animation .Time > m_Stage.Animation .EndTime )
854
+ m_Stage.Animation .Time = m_Stage.Animation .StartTime ;
855
+ }
856
+
830
857
// Update camera first as TRS widget needs camera view/proj matrices.
831
858
UpdateUI ();
832
859
860
+ if (LastAnimationTime != m_Stage.Animation .Time )
861
+ {
862
+ m_Stage.ImagingDelegate ->SetTime (m_Stage.Animation .Time * m_Stage.Animation .TimeCodesPerSecond );
863
+ }
864
+
833
865
if (!m_Stage)
834
866
return ;
835
867
0 commit comments