@@ -341,6 +341,11 @@ void USDViewer::LoadStage()
341341 {
342342 m_Camera.SetRotation (PI_F * 3 .f / 4 .f , PI_F / 6 .f );
343343 }
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 ;
344349}
345350
346351// Render a frame
@@ -539,6 +544,19 @@ void USDViewer::UpdateUI()
539544 }
540545 }
541546
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+
542560 ImGui::Spacing ();
543561
544562 ImGui::SetNextItemOpen (true , ImGuiCond_FirstUseEver);
@@ -827,9 +845,23 @@ void USDViewer::Update(double CurrTime, double ElapsedTime)
827845 m_Camera.SetZoomSpeed (m_Camera.GetDist () * 0 .1f );
828846 m_Camera.Update (m_InputController);
829847 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+
830857 // Update camera first as TRS widget needs camera view/proj matrices.
831858 UpdateUI ();
832859
860+ if (LastAnimationTime != m_Stage.Animation .Time )
861+ {
862+ m_Stage.ImagingDelegate ->SetTime (m_Stage.Animation .Time * m_Stage.Animation .TimeCodesPerSecond );
863+ }
864+
833865 if (!m_Stage)
834866 return ;
835867
0 commit comments