The New API

This is a very quick introduction to the use of the new API to give a sense of the basic feel.

There are three main parts to the new API for plugin writers. The first is a new math and common-function library, the second is the API which wraps USD, and the third is for shared geometry functionality. These reside in four new libraries, libFdkBase(fdk), libFnUsdAbstraction(usg), libFnUsdEngine(usg) and libNdk(ndk). You will need to link against these libraries as well as DDImage. Each library have different namespaces and top include paths to separate conceptually different code subsections rather than sharing a single folder like DDImage. Include files for all four new libs are included like so:

#include “fdk/math/Vec3.h”

The Math Library

The math classes in DDImage are all single precision, and this often isn’t good enough for large scenes or operations like raytracing. The NDK contains a set of math classes which are templated for float, double, half and (sometimes) int. These include vectors (Vec2, Vec3, Vec4), matrices (Mat4), quaternions (Quat) and boxes (Box2, Box3). These are suffixed by f, d, h or i. Thus fdk::Vec3f is a 3-vector of floats and fdk::Quath is a quaternion of half-floats. You should use these classes in preference to the DDImage classes such as Vector4.

The USD Wrapper

The NDK has a set of classes which act as thin wrappers around USD classes. The intention of the wrappers is to insulate Nuke from dependence on a particular version of USD. We may provide the source code of lib FnUsdAbstraction so customers can build the abstraction lib for different or custom versions of USD.

The wrapper classes include:

  • Token (TfToken)

  • Path (SdfPath)

  • Attribute (UsdAttr/SdfAttributeSpec)

  • Prim (UsdPrim/SdfPrimSpec)

  • BoundablePrim, XformablePrim, PointBasedPrim, MeshPrim (UsdGeomBoundable etc.)

  • Layer (SdfLayer)

  • Stage (UsdStage)

Note that some of these, such as usg::Attribute, can wrap either a USD or SDF class. This simplifies the API while keeping it efficient - we can use the same code to set an attribute whether we’re defining a prim in a layer or changing a prim from a USD stage.