SceneGraph_Knob¶
This is a general purpose knob that can be used to show a hierarchical tree of primitives. It can also be used when loading a file using the “R” hotkey. In order to allow populating this menu, the following procedure needs to be followed.
A SceneReaderPlugin needs to be subclassed
A SceneReaders::PluginDescription needs to be instantiated, registering
the name of the plugin class,
the file extensions that should be handled by the plugin,
and the constructor of the plugin.
The SceneReaderPlugin::query populates the out stream
There’s two query commands, SceneGraph::kSceneGraphKnobCommand which gives the following input:
“command:scene_graph””path_to_file”
And expects the following output:
no of keys | key2 | no of items for key1 | items for key1 … | key2 | no of items for key2 | items for key2… For example, a stringstream that had two objects, with type sphere, cube and name a, b and an enabled state on and off looks like “3””name””2””a””b””type””2””sphere””cube””enabled””2””1””0”
And SceneGraph::kSceneGraphTypeCommand, which gives the following input:
“command:op_type””some_type”
And expects the following response:
“name_of_node_to_instantiate_for_some_type”
Two helper functions are provided to help serialise and deserialise primitive data into the stream:
void SceneGraph::SerialiseSceneData(const DD::Image::SceneItems& data, std::ostream &out); bool SceneGraph::createBrowser(const char* fileName, DD::Image::SceneGraph_KnobI* pSceneGraphKnob, const DD::Image::SceneItems& items);
For an example of the SceneReaderPlugin, see NukeUSDPlugins SceneReaderPlugin.h