esp::gfx::replay::Recorder class

Recording for "render replay".

This class saves and serializes render keyframes. A render keyframe is a visual snapshot of a scene. It includes the visual parts of a scene, such that observations can be reproduced (from the same camera perspective or a different one). The render keyframe includes support for named "user transforms" which can be used to store cameras, agents, or other application-specific objects. See also Player. See examples/replay_tutorial.py for usage of this class through bindings.

Constructors, destructors, conversion operators

~Recorder()

Public functions

void onCreateRenderAssetInstance(scene::SceneNode* node, const esp::assets::RenderAssetInstanceCreationInfo& creation)
User code should call this upon creating a render asset instance so that Recorder can track the instance.
void onLoadRenderAsset(const esp::assets::AssetInfo& assetInfo)
User code should call this upon loading a render asset to inform Recorder about the asset.
void onCreateRigInstance(int rigId, const Rig& rig)
User code should call this upon instantiating a skinned asset rig to inform Recorder about it.
void onHideSceneGraph(const esp::scene::SceneGraph& sceneGraph)
Record deletion of all render instances in a scene graph. Because scene graphs are currently leaked when the active scene changes, we cannot rely on node deletion to issue gfx-replay deletion entries. This function allows to circumvent this issue. The scene graph leak occurs in createSceneInstance(), in Simulator.cpp.
void saveKeyframe()
Save/capture a render keyframe (a visual snapshot of the scene).
auto extractKeyframe() -> Keyframe
auto getLatestKeyframe() -> const Keyframe&
Returns the last saved keyframe.
void addUserTransformToKeyframe(const std::string& name, const Magnum::Vector3& translation, const Magnum::Quaternion& rotation)
Add a named "user transform" which can be used to store cameras, agents, or other application-specific objects.
void addLightToKeyframe(const LightInfo& lightInfo)
Add a light to the current keyframe.
void clearLightsFromKeyframe()
Delete all lights from the current keyframe.
void writeSavedKeyframesToFile(const std::string& filepath, bool usePrettyWriter = false)
write saved keyframes to file.
auto writeSavedKeyframesToString() -> std::string
write saved keyframes to string. '{"keyframes": [{...},{...},...]}'
auto writeIncrementalSavedKeyframesToStringArray() -> std::vector<std::string>
write saved keyframes as individual strings ['{"keyframe": ...}', '{"keyframe": ...}', ...]
void setMaxDecimalPlaces(int maxDecimalPlaces)
Set the precision of the floating points serialized by this recorder.
auto getMaxDecimalPlaces() const -> int
Get the precision of the floating points serialized by this recorder.
auto keyframeToString(const Keyframe& keyframe) const -> std::string
returns JSONized version of given keyframe.
auto debugGetSavedKeyframes() const -> const std::vector<Keyframe>&
Reserved for unit-testing.

Function documentation

void esp::gfx::replay::Recorder::onCreateRenderAssetInstance(scene::SceneNode* node, const esp::assets::RenderAssetInstanceCreationInfo& creation)

User code should call this upon creating a render asset instance so that Recorder can track the instance.

Parameters
node The root node of the instance
creation How the instance was created. Recorder will save this so that the instance can be re-created later.

void esp::gfx::replay::Recorder::onLoadRenderAsset(const esp::assets::AssetInfo& assetInfo)

User code should call this upon loading a render asset to inform Recorder about the asset.

Parameters
assetInfo The asset that was loaded.

void esp::gfx::replay::Recorder::onCreateRigInstance(int rigId, const Rig& rig)

User code should call this upon instantiating a skinned asset rig to inform Recorder about it.

Parameters
rigId Id of the rig that was instantiated.
rig Rig that was instantiated.

void esp::gfx::replay::Recorder::onHideSceneGraph(const esp::scene::SceneGraph& sceneGraph)

Record deletion of all render instances in a scene graph. Because scene graphs are currently leaked when the active scene changes, we cannot rely on node deletion to issue gfx-replay deletion entries. This function allows to circumvent this issue. The scene graph leak occurs in createSceneInstance(), in Simulator.cpp.

Parameters
sceneGraph The scene graph being hidden.

void esp::gfx::replay::Recorder::saveKeyframe()

Save/capture a render keyframe (a visual snapshot of the scene).

User code can call this any time, but the intended usage is to save a keyframe after stepping the environment and/or when drawing observations. See also writeSavedKeyframesToFile.

void esp::gfx::replay::Recorder::addUserTransformToKeyframe(const std::string& name, const Magnum::Vector3& translation, const Magnum::Quaternion& rotation)

Add a named "user transform" which can be used to store cameras, agents, or other application-specific objects.

Parameters
name A name, to be used to retrieve the transform later.
translation
rotation

The user transforms can be retrieved by name during replay playback. See Player (coming soon).

The user transform gets added to the "current" keyframe and will get saved on the next call to saveKeyframe (but not later keyframes). For "persistent" user objects, the expected usage is to call this every frame.

void esp::gfx::replay::Recorder::addLightToKeyframe(const LightInfo& lightInfo)

Add a light to the current keyframe.

Parameters
lightInfo Parameters of the light to be added to the keyframe.

void esp::gfx::replay::Recorder::writeSavedKeyframesToFile(const std::string& filepath, bool usePrettyWriter = false)

write saved keyframes to file.

Parameters
filepath
usePrettyWriter

If you prefer more readable json, set usePrettyWriter to true, but beware larger filesize.

std::vector<std::string> esp::gfx::replay::Recorder::writeIncrementalSavedKeyframesToStringArray()

write saved keyframes as individual strings ['{"keyframe": ...}', '{"keyframe": ...}', ...]

Use this function if you are using keyframes incrementally, e.g. repeated calls to this function and feeding them to a renderer. Contrast with writeSavedKeyframesToFile, which "consolidates" before discarding old keyframes to avoid losing state information.