CPlusPlus SOP

From Derivative
Jump to: navigation, search


Summary

Note: Only available in TouchDesigner Educational, TouchDesigner Commercial and TouchDesigner Pro.

The CPlusPlus SOP allows you to make custom SOP operators by writing your own plugin using C++.

See Write a CPlusPlus Plugin and the other articles in the C++ category for more detailed information on how to make .dll for use with this SOP.

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 execute() or executeVBO().

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/TouchDesigner099/Samples/CPlusPlus/SimpleShapesSOP or your custom TouchDesigner installation folder. (NOTE: On macOS it is here: TouchDesigner.app/Contents/Resources/tfs/Samples/CPlusPlus/SimpleShapesSOP)

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).

PythonIcon.pngcplusplusSOP_Class

CPlusPlus SOP on Old Wiki



Parameters - Load Page

Plugin Path plugin - The path to the plugin you want to load.

Re-Init Class reinit - When this parameter goes above 1, it will delete the instance of the class created by the plugin, and create a new one.

Re-Init Class reinitpulse -

Unload Plugin 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.



SOPs
Add • Alembic • Align • Arm • Attribute Create • Attribute • Basis • Blend • Bone Group • Boolean • Box • Bridge • Cache • Cap • Capture Region • Capture • Carve • CHOP to • Circle • Clay • Clip • Convert • Copy • CPlusPlus • Creep • Curveclay • Curvesect • DAT to • Deform • Delete • Divide • Extrude • Facet • File In • Fillet • Fit • Font • Force • Fractal • Grid • Group • Hole • In • Introduction To SOPs id• Inverse Curve • Iso Surface • Join • Joint • Kinect • Lattice • Limit • Line • Line Thick • LOD • LSystem • Magnet • Material • Merge • Metaball • Model • Noise • Null • Object Merge • OpenVR • Out • Particle • Point • Polyloft • Polypatch • Polyreduce • Polyspline • Polystitch • Primitive • Profile • Project • Rails • Ray • Rectangle • Refine • Resample • Revolve • Script • Select • Sequence Blend • Skin • SOP• Sort • Sphere • Spring • Sprite • Stitch • Subdivide • Superquad • Surfsect • Sweep • Switch • Text • Texture • Torus • Trace • Trail • Transform • Trim • Tristrip • Tube • Twist • Vertex • Wireframe