Skip to content

Commit 5a50833

Browse files
authored
Finalize the Recording API (newton-physics#1600)
1 parent 8e0a1c8 commit 5a50833

File tree

5 files changed

+1271
-1411
lines changed

5 files changed

+1271
-1411
lines changed

docs/guide/visualization.rst

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,27 @@ To use binary format, install the optional dependency:
110110
111111
**Loading and playing back recordings:**
112112

113-
.. note::
114-
115-
The RecorderModelAndState class is deprecated and will be removed in a future version.
116-
Use the :class:`~newton.viewers.ViewerFile` class instead.
113+
Use :class:`~newton.viewer.ViewerFile` to load a recording, then restore the model and state for a given frame. Use :class:`~newton.viewer.ViewerGL` (or another rendering viewer) to visualize.
117114

118115
.. code-block:: python
119116
120117
# Load a recording for playback
121-
from newton._src.utils.recorder import RecorderModelAndState
122-
recorder = RecorderModelAndState()
123-
recorder.load_from_file("simulation.bin")
118+
viewer_file = newton.viewer.ViewerFile("simulation.bin")
119+
viewer_file.load_recording()
124120
125-
# Create model and state for playback
121+
# Restore the model and state from the recording
126122
model = newton.Model()
127-
state = newton.State()
128-
129-
# Restore the model from the recording
130-
recorder.playback_model(model)
123+
viewer_file.load_model(model)
131124
132-
# Playback a specific frame (e.g., frame 10)
133-
recorder.playback(state, frame_index=10)
125+
state = model.state()
126+
viewer_file.load_state(state, frame_id=10) # frame index in [0, get_frame_count())
134127
135-
# Use with any viewer to visualize
128+
# Use ViewerGL for visualization
136129
viewer = newton.viewer.ViewerGL()
137130
viewer.set_model(model)
138131
viewer.log_state(state)
139132
140-
For a complete example with UI controls for playback, see ``newton/examples/basic/example_replay_viewer.py``.
133+
For a complete example with UI controls for scrubbing and playback, see ``newton/examples/basic/example_replay_viewer.py``.
141134

142135
Key parameters:
143136

0 commit comments

Comments
 (0)