Q100229: Extending Katana’s ViewerModifier plug-ins to add icon scalability
This article explains how to modify, recompile and register the ViewerModifier plug-ins so that a "viewer.default.drawOptions.locatorScale” attribute can be used to scale camera and light icons in the Viewer, without scaling the objects’ xform.
This set of steps is for Katana 2.5v4 on Linux (RHEL 6) using the Viewer Modifier Plug-in API version 2.0. For previous versions, please compile against the appropriate versions accordingly.
- Find the ViewerModifiers directory in your Katana installation directory, for example:
and copy the content of the folder into a convenient location, for example:
- Modify the source code for the CameraViewerModifier and LightViewerModifier in your local copies, which is located under the ViewerModifiers/CameraViewerModifier/src and ViewerModifiers/LightViewerModifier/src directory structure respectively.
Specifically, add these lines in the void draw(FnKat::ViewerModifierInput& input) function in both files as demonstrated in the attached example files and code below:
FnKat::FloatAttribute locatorScaleAttr = input.getGlobalAttribute(
locatorScale = locatorScaleAttr.getNearestSample(0);
- Also modify the FnKat::DoubleAttribute getLocalSpaceBoundingBox(FnKat::ViewerModifierInput& input) function in both files as demonstrated in the attached example files CameraViewerModifier.cpp and LightViewerModifier.cpp.
In both files, change the plug-in name in the REGISTER_PLUGIN call to start with a letter after L and C, for example use Z like:
REGISTER_PLUGIN(LightViewerModifier, "ZLightViewerModifier", 0, 1);
REGISTER_PLUGIN(CameraViewerModifier, "ZCameraViewerModifier", 0, 1);This is because the internal plug-in names will be ordered alphabetically and per the plug-in loading order Katana uses, the last alphabetical entry will win.
- Save the files and prepare to compile the files against the right Viewer Modifier Plug-in API version.
- To compile the plug-ins, make sure you have cmake version 3.2 or higher installed.
- In a terminal, set the KATANA_HOME environment variable to point to your Katana installation directory, for example:
- Set the CMAKE_PREFIX_PATH to point to where the file katana-config.cmake is located, for example:
export CMAKE_PREFIX_PATH = $KATANA_HOME/plugin_apis/cmake
- Navigate to the your local ViewerModifiers directory in the terminal and run the following command:
This should create a Makefile in the ViewerModifiers directory. The file may be hidden, so you might have to enable the “Show hidden files” option in your file browser to see it.
- Run the command make to build the plug-ins. This should give you a LightViewerModifier.so file and a CameraViewerModifier.so file in their respective directories.
- These .so files need to be placed in a directory called Libs inside a KATANA_RESOURCES directory. For example, place the .so files into
and add the path
To use the new plug-ins created, open Katana and in your scene use an AttributeSet node and add a float attribute called "viewer.default.drawOptions.locatorScale" on the camera or light location you'd like to scale. This will allow scaling the camera or light icon in the Viewer without altering the object’s attribute values.
We're sorry to hear that!Please tell us why.