The CPlusPlus SOP allows you to make custom SOP operators by writing your own plugin using C++.
The C++ code can be written for GPU or CPU loading. The ease of developing C++ code for either of these two options are fairly similar. Nevertheless, by setting the “
directToGPU” flag within the C++ code, only one of these modes is recognized as a valid mode. Different classes are dedicated for each of these two modes, so bear in mind that setting the “
directToGPU” flag to “
true” or “
false” requires different classes and functions to be called within either of
In CPU mode, the geometry data can be added one at a time or all at once. As well, in CPU mode the CPlusPlus SOP can use wired SOP inputs and SOP to DAT, SOP to CHOP, or SOP output OPs as well. Additionally DAT, CHOP, and TOP 'non-wired' input operators can be used as custom parameters. In this case, the custom parameters must be first handled in the C++ code to be able to accept any input from the other operators.
The GPU direct mode is similar to CPU mode, but it cannot use any output SOPs downstream or be accessed by SOP to DAT or SOP to CHOP operators. In GPU direct mode the data is added to the VBO buffers immediately which improves the performance through faster updating, however the size of the vertices and face array indices must be known prior to filling the buffers.
Example for CPlusPlus SOP as a Visual Studio project in Windows are available in
C:/Program Files/Derivative/TouchDesigner/Samples/CPlusPlus/SimpleShapesSOP or your custom TouchDesigner installation folder. (NOTE: On macOS it is here:
Custom Parameters - Custom Parameters can be automatically created by the C++ SOP
.dll. This custom parameter page can be removed, edited, or appended to from within the
setupParameters() function in SimpleShapes.cpp. The defined custom parameters can be enabled or disabled depending on whether they are valid for a specific task or not.
Geometry Data - Geometry within the C++ SOP code can be defined by any algorithm or even imported from external files. The possible geometries are triangular meshes and particle systems. Note that if your original geometry has polygons with more than 3 vertices, they must be converted to triangles with known and valid vertex indices, before being added to the list of triangles.
The geometry data for exporting to TouchDesigner can have point, normal, and texture coordinates, RGBA colors, triangle information in case of meshes and/or particle systems, as well as custom attributes with an arbitrary name, float or integer type, and up to 4 components (ie. Cd0, Cd1, Cd2, Cd3).
Parameters - Load Page
plugin - The path to the plugin you want to load.
reinit - When this parameter is On, it will delete the instance of the class created by the plugin, and create a new one.
reinitpulse - Instantly reinitialize the class.
unloadplugin - When this parameter goes above 1, it will delete the instance of the class created by the plugin and unload the plugin. If multiple SOPs have loaded the same plugin they will all need to unload it to release the file.
- Input 0 -