├── CPlusPlus ├── .gitignore ├── CHOP_Buffer.cpp ├── CHOP_Buffer.h ├── CHOP_CPlusPlusBase.h ├── CPlusPlus_Common.h ├── GL_Extensions.h ├── Info.plist ├── LICENSE ├── Laser OS CHOP.sln ├── Laser OS CHOP.vcxproj ├── Laser OS CHOP.vcxproj.filters ├── Laser_OS_CHOP.cpp ├── Laser_OS_CHOP.h ├── dllmain.cpp ├── framework.h ├── lib │ ├── include │ │ └── laserdocklib │ │ │ ├── LaserdockDevice.h │ │ │ ├── LaserdockDeviceManager.h │ │ │ ├── LaserdockSample.h │ │ │ └── Laserdocklib.h │ ├── laserdocklib.dll │ └── laserdocklib.lib ├── pch.cpp └── pch.h ├── README.md └── TouchDesigner ├── .gitignore ├── Laser_OS_Test.toe └── Plugins └── Laser OS v0.0.3 ├── Laser OS CHOP.dll └── laserdocklib.dll /CPlusPlus/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.vspscc 94 | *.vssscc 95 | .builds 96 | *.pidb 97 | *.svclog 98 | *.scc 99 | 100 | # Chutzpah Test files 101 | _Chutzpah* 102 | 103 | # Visual C++ cache files 104 | ipch/ 105 | *.aps 106 | *.ncb 107 | *.opendb 108 | *.opensdf 109 | *.sdf 110 | *.cachefile 111 | *.VC.db 112 | *.VC.VC.opendb 113 | 114 | # Visual Studio profiler 115 | *.psess 116 | *.vsp 117 | *.vspx 118 | *.sap 119 | 120 | # Visual Studio Trace Files 121 | *.e2e 122 | 123 | # TFS 2012 Local Workspace 124 | $tf/ 125 | 126 | # Guidance Automation Toolkit 127 | *.gpState 128 | 129 | # ReSharper is a .NET coding add-in 130 | _ReSharper*/ 131 | *.[Rr]e[Ss]harper 132 | *.DotSettings.user 133 | 134 | # TeamCity is a build add-in 135 | _TeamCity* 136 | 137 | # DotCover is a Code Coverage Tool 138 | *.dotCover 139 | 140 | # AxoCover is a Code Coverage Tool 141 | .axoCover/* 142 | !.axoCover/settings.json 143 | 144 | # Coverlet is a free, cross platform Code Coverage Tool 145 | coverage*.json 146 | coverage*.xml 147 | coverage*.info 148 | 149 | # Visual Studio code coverage results 150 | *.coverage 151 | *.coveragexml 152 | 153 | # NCrunch 154 | _NCrunch_* 155 | .*crunch*.local.xml 156 | nCrunchTemp_* 157 | 158 | # MightyMoose 159 | *.mm.* 160 | AutoTest.Net/ 161 | 162 | # Web workbench (sass) 163 | .sass-cache/ 164 | 165 | # Installshield output folder 166 | [Ee]xpress/ 167 | 168 | # DocProject is a documentation generator add-in 169 | DocProject/buildhelp/ 170 | DocProject/Help/*.HxT 171 | DocProject/Help/*.HxC 172 | DocProject/Help/*.hhc 173 | DocProject/Help/*.hhk 174 | DocProject/Help/*.hhp 175 | DocProject/Help/Html2 176 | DocProject/Help/html 177 | 178 | # Click-Once directory 179 | publish/ 180 | 181 | # Publish Web Output 182 | *.[Pp]ublish.xml 183 | *.azurePubxml 184 | # Note: Comment the next line if you want to checkin your web deploy settings, 185 | # but database connection strings (with potential passwords) will be unencrypted 186 | *.pubxml 187 | *.publishproj 188 | 189 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 190 | # checkin your Azure Web App publish settings, but sensitive information contained 191 | # in these scripts will be unencrypted 192 | PublishScripts/ 193 | 194 | # NuGet Packages 195 | *.nupkg 196 | # NuGet Symbol Packages 197 | *.snupkg 198 | # The packages folder can be ignored because of Package Restore 199 | **/[Pp]ackages/* 200 | # except build/, which is used as an MSBuild target. 201 | !**/[Pp]ackages/build/ 202 | # Uncomment if necessary however generally it will be regenerated when needed 203 | #!**/[Pp]ackages/repositories.config 204 | # NuGet v3's project.json files produces more ignorable files 205 | *.nuget.props 206 | *.nuget.targets 207 | 208 | # Microsoft Azure Build Output 209 | csx/ 210 | *.build.csdef 211 | 212 | # Microsoft Azure Emulator 213 | ecf/ 214 | rcf/ 215 | 216 | # Windows Store app package directories and files 217 | AppPackages/ 218 | BundleArtifacts/ 219 | Package.StoreAssociation.xml 220 | _pkginfo.txt 221 | *.appx 222 | *.appxbundle 223 | *.appxupload 224 | 225 | # Visual Studio cache files 226 | # files ending in .cache can be ignored 227 | *.[Cc]ache 228 | # but keep track of directories ending in .cache 229 | !?*.[Cc]ache/ 230 | 231 | # Others 232 | ClientBin/ 233 | ~$* 234 | *~ 235 | *.dbmdl 236 | *.dbproj.schemaview 237 | *.jfm 238 | *.pfx 239 | *.publishsettings 240 | orleans.codegen.cs 241 | 242 | # Including strong name files can present a security risk 243 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 244 | #*.snk 245 | 246 | # Since there are multiple workflows, uncomment next line to ignore bower_components 247 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 248 | #bower_components/ 249 | 250 | # RIA/Silverlight projects 251 | Generated_Code/ 252 | 253 | # Backup & report files from converting an old project file 254 | # to a newer Visual Studio version. Backup files are not needed, 255 | # because we have git ;-) 256 | _UpgradeReport_Files/ 257 | Backup*/ 258 | UpgradeLog*.XML 259 | UpgradeLog*.htm 260 | ServiceFabricBackup/ 261 | *.rptproj.bak 262 | 263 | # SQL Server files 264 | *.mdf 265 | *.ldf 266 | *.ndf 267 | 268 | # Business Intelligence projects 269 | *.rdl.data 270 | *.bim.layout 271 | *.bim_*.settings 272 | *.rptproj.rsuser 273 | *- [Bb]ackup.rdl 274 | *- [Bb]ackup ([0-9]).rdl 275 | *- [Bb]ackup ([0-9][0-9]).rdl 276 | 277 | # Microsoft Fakes 278 | FakesAssemblies/ 279 | 280 | # GhostDoc plugin setting file 281 | *.GhostDoc.xml 282 | 283 | # Node.js Tools for Visual Studio 284 | .ntvs_analysis.dat 285 | node_modules/ 286 | 287 | # Visual Studio 6 build log 288 | *.plg 289 | 290 | # Visual Studio 6 workspace options file 291 | *.opt 292 | 293 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 294 | *.vbw 295 | 296 | # Visual Studio LightSwitch build output 297 | **/*.HTMLClient/GeneratedArtifacts 298 | **/*.DesktopClient/GeneratedArtifacts 299 | **/*.DesktopClient/ModelManifest.xml 300 | **/*.Server/GeneratedArtifacts 301 | **/*.Server/ModelManifest.xml 302 | _Pvt_Extensions 303 | 304 | # Paket dependency manager 305 | .paket/paket.exe 306 | paket-files/ 307 | 308 | # FAKE - F# Make 309 | .fake/ 310 | 311 | # CodeRush personal settings 312 | .cr/personal 313 | 314 | # Python Tools for Visual Studio (PTVS) 315 | __pycache__/ 316 | *.pyc 317 | 318 | # Cake - Uncomment if you are using it 319 | # tools/** 320 | # !tools/packages.config 321 | 322 | # Tabs Studio 323 | *.tss 324 | 325 | # Telerik's JustMock configuration file 326 | *.jmconfig 327 | 328 | # BizTalk build output 329 | *.btp.cs 330 | *.btm.cs 331 | *.odx.cs 332 | *.xsd.cs 333 | 334 | # OpenCover UI analysis results 335 | OpenCover/ 336 | 337 | # Azure Stream Analytics local run output 338 | ASALocalRun/ 339 | 340 | # MSBuild Binary and Structured Log 341 | *.binlog 342 | 343 | # NVidia Nsight GPU debugger configuration file 344 | *.nvuser 345 | 346 | # MFractors (Xamarin productivity tool) working folder 347 | .mfractor/ 348 | 349 | # Local History for Visual Studio 350 | .localhistory/ 351 | 352 | # BeatPulse healthcheck temp database 353 | healthchecksdb 354 | 355 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 356 | MigrationBackup/ 357 | 358 | # Ionide (cross platform F# VS Code tools) working folder 359 | .ionide/ 360 | 361 | # Fody - auto-generated XML schema 362 | FodyWeavers.xsd 363 | -------------------------------------------------------------------------------- /CPlusPlus/CHOP_Buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 - LaserDock Limited 3 | * Written by Tim Greiser - Prim8 Technology Consulting, LLC 4 | * Contains related libraries from Derivative Inc. & Laser Dock Limited 5 | */ 6 | #include "pch.h" 7 | 8 | #include 9 | 10 | using namespace std; 11 | 12 | CHOP_Buffer::CHOP_Buffer(uint16_t maxSamples) { 13 | _max = maxSamples; 14 | } 15 | 16 | CHOP_Buffer::~CHOP_Buffer() { 17 | } 18 | 19 | bool CHOP_Buffer::fillSamples(const OP_CHOPInput* cinput, CHOP_Output* output, LaserdockSample* samples, double scaleX, double scaleY, 20 | double scaleRed, double scaleGreen, double scaleBlue) { 21 | 22 | int max = cinput->numSamples > _max ? _max : cinput->numSamples; 23 | //cout << "fillSamples" << _max << cinput->numSamples << output->numSamples << endl; 24 | for (int iY = 0; iY < cinput->numSamples; iY++) { 25 | 26 | float xval = float(cinput->getChannelData(0)[iY] * scaleX); 27 | float yval = float(cinput->getChannelData(1)[iY] * scaleY); 28 | float rval = float(cinput->getChannelData(2)[iY] * scaleRed); 29 | float gval = float(cinput->getChannelData(3)[iY] * scaleGreen); 30 | float bval = float(cinput->getChannelData(4)[iY] * scaleBlue); 31 | 32 | if (iY < max && iY < cinput->numSamples) { 33 | if (output->numSamples > iY) { 34 | output->channels[0][iY] = xval; 35 | output->channels[1][iY] = yval; 36 | output->channels[2][iY] = rval; 37 | output->channels[3][iY] = gval; 38 | output->channels[4][iY] = bval; 39 | } 40 | 41 | uint8_t red = GetUInt8(rval); 42 | samples[iY].x = float_to_laserdock_xy(xval); 43 | samples[iY].y = float_to_laserdock_xy(yval); 44 | uint8_t green = 0x00FF & GetUInt8(gval); 45 | samples[iY].rg = (0x00FF & GetUInt8(rval)) | (green << 8); 46 | samples[iY].b = 0x00FF & GetUInt8(bval); 47 | } 48 | } 49 | return true; 50 | } -------------------------------------------------------------------------------- /CPlusPlus/CHOP_Buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | 5 | #include 6 | 7 | class CHOP_Buffer { 8 | public: 9 | CHOP_Buffer(uint16_t maxSamples); 10 | ~CHOP_Buffer(); 11 | 12 | bool fillSamples(const OP_CHOPInput* cinput, CHOP_Output* output, LaserdockSample* samples, double scaleX, double scaleY, double scaleRed, double scaleGreen, double scaleBlue); 13 | uint8_t GetUInt8(float f) const; 14 | 15 | private: 16 | uint16_t _max; 17 | }; 18 | 19 | inline uint8_t CHOP_Buffer::GetUInt8(float f) const { 20 | if (f < 0) f = 0; 21 | if (f > 1) f = 1; 22 | return static_cast(f * 255); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /CPlusPlus/CHOP_CPlusPlusBase.h: -------------------------------------------------------------------------------- 1 | /* Shared Use License: This file is owned by Derivative Inc. (Derivative) 2 | * and can only be used, and/or modified for use, in conjunction with 3 | * Derivative's TouchDesigner software, and only if you are a licensee who has 4 | * accepted Derivative's TouchDesigner license or assignment agreement 5 | * (which also govern the use of this file). You may share or redistribute 6 | * a modified version of this file provided the following conditions are met: 7 | * 8 | * 1. The shared file or redistribution must retain the information set out 9 | * above and this list of conditions. 10 | * 2. Derivative's name (Derivative Inc.) or its trademarks may not be used 11 | * to endorse or promote products derived from this file without specific 12 | * prior written permission from Derivative. 13 | */ 14 | 15 | /* 16 | * Produced by: 17 | * 18 | * Derivative Inc 19 | * 401 Richmond Street West, Unit 386 20 | * Toronto, Ontario 21 | * Canada M5V 3A8 22 | * 416-591-3555 23 | * 24 | * NAME: CHOP_CPlusPlusBase.h 25 | * 26 | * 27 | * Do not edit this file directly! 28 | * Make a subclass of CHOP_CPlusPlusBase instead, and add your own 29 | * data/functions. 30 | 31 | * Derivative Developers:: Make sure the virtual function order 32 | * stays the same, otherwise changes won't be backwards compatible 33 | */ 34 | 35 | #ifndef __CHOP_CPlusPlusBase__ 36 | #define __CHOP_CPlusPlusBase__ 37 | 38 | #include "CPlusPlus_Common.h" 39 | 40 | 41 | class CHOP_CPlusPlusBase; 42 | 43 | // Define for the current API version that this sample code is made for. 44 | // To upgrade to a newer version, replace the files 45 | // CHOP_CPlusPlusBase.h 46 | // CPlusPlus_Common.h 47 | // from the samples folder in a newer TouchDesigner installation. 48 | // You may need to upgrade your plugin code in that case, to match 49 | // the new API requirements 50 | const int CHOPCPlusPlusAPIVersion = 8; 51 | 52 | struct CHOP_PluginInfo 53 | { 54 | public: 55 | 56 | // Must be set to CHOPCPlusPlusAPIVersion in FillCHOPPluginInfo 57 | int32_t apiVersion = 0; 58 | 59 | int32_t reserved[100]; 60 | 61 | 62 | // Information used to describe this plugin as a custom OP. 63 | OP_CustomOPInfo customOPInfo; 64 | 65 | 66 | int32_t reserved2[20]; 67 | 68 | }; 69 | 70 | 71 | 72 | // These are the definitions for the C-functions that are used to 73 | // load the library and create instances of the object you define 74 | typedef void(__cdecl* FILLCHOPPLUGININFO)(CHOP_PluginInfo* info); 75 | typedef CHOP_CPlusPlusBase* (__cdecl* CREATECHOPINSTANCE)(const OP_NodeInfo*); 76 | typedef void(__cdecl* DESTROYCHOPINSTANCE)(CHOP_CPlusPlusBase*); 77 | 78 | 79 | class CHOP_GeneralInfo 80 | { 81 | public: 82 | // Set this to true if you want the CHOP to cook every frame, even 83 | // if none of it's inputs/parameters are changing 84 | // DEFAULT: false 85 | 86 | bool cookEveryFrame; 87 | 88 | // Set this to true if you want the CHOP to cook every frame, but only 89 | // if someone asks for it to cook. So if nobody is using the output from 90 | // the CHOP, it won't cook. This is difereent from 'cookEveryFrame' 91 | // since that will cause it to cook every frame no matter what. 92 | 93 | bool cookEveryFrameIfAsked; 94 | 95 | // Set this to true if you will be outputting a timeslice 96 | // Outputting a timeslice means the number of samples in the CHOP will 97 | // be determined by the number of frames that have elapsed since the last 98 | // time TouchDesigner cooked (it will be more than one in cases where it's 99 | // running slower than the target cook rate), the playbar framerate and 100 | // the sample rate of the CHOP. 101 | // For example if you are outputting the CHOP 120hz sample rate, 102 | // TouchDesigner is running at 60 hz cookrate, and you missed a frame last cook 103 | // then on this cook the number of sampels of the output of this CHOP will 104 | // be 4 samples. I.e (120 / 60) * number of playbar frames to output. 105 | // If this isn't set then you specify the number of sample in the CHOP using 106 | // the getOutputInfo() function 107 | // DEFAULT: false 108 | 109 | bool timeslice; 110 | 111 | // If you are returning 'false' from getOutputInfo, this index will 112 | // specify the CHOP input whos attribues you will match 113 | // (channel names, length, sample rate etc.) 114 | // DEFAULT : 0 115 | 116 | int32_t inputMatchIndex; 117 | 118 | 119 | int32_t reserved[20]; 120 | }; 121 | 122 | 123 | 124 | class CHOP_OutputInfo 125 | { 126 | public: 127 | 128 | // The number of channels you want to output 129 | 130 | int32_t numChannels; 131 | 132 | 133 | // If you arn't outputting a timeslice, specify the number of samples here 134 | 135 | int32_t numSamples; 136 | 137 | 138 | // if you arn't outputting a timeslice, specify the start index 139 | // of the channels here. This is the 'Start' you see when you 140 | // middle click on a CHOP 141 | 142 | uint32_t startIndex; 143 | 144 | 145 | // Specify the sample rate of the channel data 146 | // DEFAULT : whatever the timeline FPS is ($FPS) 147 | 148 | float sampleRate; 149 | 150 | 151 | void* reserved1; 152 | 153 | 154 | int32_t reserved[20]; 155 | 156 | }; 157 | 158 | 159 | 160 | 161 | 162 | class CHOP_Output 163 | { 164 | public: 165 | CHOP_Output(int32_t nc, int32_t l, float s, uint32_t st, 166 | float** cs, const char** ns) : 167 | numChannels(nc), 168 | numSamples(l), 169 | sampleRate(s), 170 | startIndex(st), 171 | channels(cs), 172 | names(ns) 173 | { 174 | } 175 | 176 | // Info about what you are expected to output 177 | const int32_t numChannels; 178 | const int32_t numSamples; 179 | const float sampleRate; 180 | const uint32_t startIndex; 181 | 182 | // This is an array of const char* that tells you the channel names 183 | // of the channels you are providing values for. It's 'numChannels' long. 184 | // E.g names[3] is the name of the 4th channel 185 | const char** const names; 186 | 187 | // This is an array of float arrays that is already allocated for you. 188 | // Fill it with the data you want outputted for this CHOP. 189 | // The length of the array is 'numChannels', 190 | // While the length of each of the array entries is 'numSamples'. 191 | // For example channels[1][10] will point to the 11th sample in the 2nd 192 | // channel 193 | float** const channels; 194 | 195 | 196 | 197 | int32_t reserved[20]; 198 | }; 199 | 200 | 201 | 202 | /***** FUNCTION CALL ORDER DURING INITIALIZATION ******/ 203 | /* 204 | When the TOP loads the dll the functions will be called in this order 205 | 206 | setupParameters(OP_ParameterManager* m); 207 | 208 | */ 209 | 210 | /***** FUNCTION CALL ORDER DURING A COOK ******/ 211 | /* 212 | 213 | When the CHOP cooks the functions will be called in this order 214 | 215 | getGeneralInfo() 216 | getOutputInfo() 217 | if getOutputInfo() returns true 218 | { 219 | getChannelName() once for each channel needed 220 | } 221 | execute() 222 | getNumInfoCHOPChans() 223 | for the number of chans returned getNumInfoCHOPChans() 224 | { 225 | getInfoCHOPChan() 226 | } 227 | getInfoDATSize() 228 | for the number of rows/cols returned by getInfoDATSize() 229 | { 230 | getInfoDATEntries() 231 | } 232 | getInfoPopupString() 233 | getWarningString() 234 | getErrorString() 235 | */ 236 | 237 | /*** DO NOT EDIT THIS CLASS, MAKE A SUBCLASS OF IT INSTEAD ***/ 238 | class CHOP_CPlusPlusBase 239 | { 240 | protected: 241 | CHOP_CPlusPlusBase() 242 | { 243 | } 244 | 245 | virtual ~CHOP_CPlusPlusBase() 246 | { 247 | } 248 | 249 | public: 250 | 251 | 252 | // BEGIN PUBLIC INTERFACE 253 | 254 | // Some general settings can be assigned here (if you override it) 255 | virtual void 256 | getGeneralInfo(CHOP_GeneralInfo*, const OP_Inputs* inputs, void* reserved1) 257 | { 258 | } 259 | 260 | 261 | // This function is called so the class can tell the CHOP how many 262 | // channels it wants to output, how many samples etc. 263 | // Return true if you specify the output here. 264 | // Return false if you want the output to be set by matching 265 | // the channel names, numSamples, sample rate etc. of one of your inputs 266 | // The input that is used is chosen by setting the 'inputMatchIndex' 267 | // memeber in CHOP_OutputInfo 268 | // The CHOP_OutputInfo class is pre-filled with what the CHOP would 269 | // output if you return false, so you can just tweak a few settings 270 | // and return true if you want 271 | virtual bool 272 | getOutputInfo(CHOP_OutputInfo*, const OP_Inputs* inputs, void* reserved1) 273 | { 274 | return false; 275 | } 276 | 277 | 278 | // This function will be called after getOutputInfo() asking for 279 | // the channel names. It will get called once for each channel name 280 | // you need to specify. If you returned 'false' from getOutputInfo() 281 | // it won't be called. 282 | virtual void 283 | getChannelName(int32_t index, OP_String* name, 284 | const OP_Inputs* inputs, void* reserved1) 285 | { 286 | name->setString("chan1"); 287 | } 288 | 289 | 290 | // In this function you do whatever you want to fill the output channels 291 | // which are already allocated for you in 'outputs' 292 | virtual void execute(CHOP_Output* outputs, 293 | const OP_Inputs* inputs, 294 | void* reserved1) = 0; 295 | 296 | 297 | // Override these methods if you want to output values to the Info CHOP/DAT 298 | // returning 0 means you dont plan to output any Info CHOP channels 299 | virtual int32_t 300 | getNumInfoCHOPChans(void* reserved1) 301 | { 302 | return 0; 303 | } 304 | 305 | // Specify the name and value for Info CHOP channel 'index', 306 | // by assigning something to 'name' and 'value' members of the 307 | // OP_InfoCHOPChan class pointer that is passed in. 308 | virtual void 309 | getInfoCHOPChan(int32_t index, OP_InfoCHOPChan* chan, void* reserved1) 310 | { 311 | } 312 | 313 | 314 | // Return false if you arn't returning data for an Info DAT 315 | // Return true if you are. 316 | // Set the members of the CHOP_InfoDATSize class to specify 317 | // the dimensions of the Info DAT 318 | virtual bool 319 | getInfoDATSize(OP_InfoDATSize* infoSize, void* reserved1) 320 | { 321 | return false; 322 | } 323 | 324 | // You are asked to assign values to the Info DAT 1 row or column at a time 325 | // The 'byColumn' variable in 'getInfoDATSize' is how you specify 326 | // if it is by column or by row. 327 | // 'index' is the row/column index 328 | // 'nEntries' is the number of entries in the row/column 329 | // Strings should be UTF-8 encoded. 330 | virtual void 331 | getInfoDATEntries(int32_t index, int32_t nEntries, 332 | OP_InfoDATEntries* entries, 333 | void* reserved1) 334 | { 335 | } 336 | 337 | // You can use this function to put the node into a warning state 338 | // by calling setSting() on 'warning' with a non empty string. 339 | // Leave 'warning' unchanged to not go into warning state. 340 | virtual void 341 | getWarningString(OP_String* warning, void* reserved1) 342 | { 343 | } 344 | 345 | // You can use this function to put the node into a error state 346 | // by calling setSting() on 'error' with a non empty string. 347 | // Leave 'error' unchanged to not go into error state. 348 | virtual void 349 | getErrorString(OP_String* error, void* reserved1) 350 | { 351 | } 352 | 353 | // Use this function to return some text that will show up in the 354 | // info popup (when you middle click on a node) 355 | // call setString() on info and give it some info if desired. 356 | virtual void 357 | getInfoPopupString(OP_String* info, void* reserved1) 358 | { 359 | } 360 | 361 | 362 | // Override these methods if you want to define specfic parameters 363 | virtual void 364 | setupParameters(OP_ParameterManager* manager, void* reserved1) 365 | { 366 | } 367 | 368 | 369 | // This is called whenever a pulse parameter is pressed 370 | virtual void 371 | pulsePressed(const char* name, void* reserved1) 372 | { 373 | } 374 | 375 | // END PUBLIC INTERFACE 376 | 377 | 378 | private: 379 | 380 | // Reserved for future features 381 | virtual int32_t reservedFunc6() { return 0; } 382 | virtual int32_t reservedFunc7() { return 0; } 383 | virtual int32_t reservedFunc8() { return 0; } 384 | virtual int32_t reservedFunc9() { return 0; } 385 | virtual int32_t reservedFunc10() { return 0; } 386 | virtual int32_t reservedFunc11() { return 0; } 387 | virtual int32_t reservedFunc12() { return 0; } 388 | virtual int32_t reservedFunc13() { return 0; } 389 | virtual int32_t reservedFunc14() { return 0; } 390 | virtual int32_t reservedFunc15() { return 0; } 391 | virtual int32_t reservedFunc16() { return 0; } 392 | virtual int32_t reservedFunc17() { return 0; } 393 | virtual int32_t reservedFunc18() { return 0; } 394 | virtual int32_t reservedFunc19() { return 0; } 395 | virtual int32_t reservedFunc20() { return 0; } 396 | 397 | int32_t reserved[400]; 398 | 399 | }; 400 | 401 | static_assert(offsetof(CHOP_PluginInfo, apiVersion) == 0, "Incorrect Alignment"); 402 | static_assert(offsetof(CHOP_PluginInfo, customOPInfo) == 408, "Incorrect Alignment"); 403 | static_assert(sizeof(CHOP_PluginInfo) == 944, "Incorrect Size"); 404 | 405 | static_assert(offsetof(CHOP_GeneralInfo, cookEveryFrame) == 0, "Incorrect Alignment"); 406 | static_assert(offsetof(CHOP_GeneralInfo, cookEveryFrameIfAsked) == 1, "Incorrect Alignment"); 407 | static_assert(offsetof(CHOP_GeneralInfo, timeslice) == 2, "Incorrect Alignment"); 408 | static_assert(offsetof(CHOP_GeneralInfo, inputMatchIndex) == 4, "Incorrect Alignment"); 409 | static_assert(sizeof(CHOP_GeneralInfo) == 88, "Incorrect Size"); 410 | 411 | static_assert(offsetof(CHOP_OutputInfo, numChannels) == 0, "Incorrect Alignment"); 412 | static_assert(offsetof(CHOP_OutputInfo, numSamples) == 4, "Incorrect Alignment"); 413 | static_assert(offsetof(CHOP_OutputInfo, startIndex) == 8, "Incorrect Alignment"); 414 | static_assert(offsetof(CHOP_OutputInfo, sampleRate) == 12, "Incorrect Alignment"); 415 | static_assert(offsetof(CHOP_OutputInfo, reserved1) == 16, "Incorrect Alignment"); 416 | static_assert(sizeof(CHOP_OutputInfo) == 104, "Incorrect Size"); 417 | 418 | static_assert(offsetof(CHOP_Output, numChannels) == 0, "Incorrect Alignment"); 419 | static_assert(offsetof(CHOP_Output, numSamples) == 4, "Incorrect Alignment"); 420 | static_assert(offsetof(CHOP_Output, sampleRate) == 8, "Incorrect Alignment"); 421 | static_assert(offsetof(CHOP_Output, startIndex) == 12, "Incorrect Alignment"); 422 | static_assert(offsetof(CHOP_Output, names) == 16, "Incorrect Alignment"); 423 | static_assert(offsetof(CHOP_Output, channels) == 24, "Incorrect Alignment"); 424 | static_assert(sizeof(CHOP_Output) == 112, "Incorrect Size"); 425 | #endif 426 | -------------------------------------------------------------------------------- /CPlusPlus/CPlusPlus_Common.h: -------------------------------------------------------------------------------- 1 | /* Shared Use License: This file is owned by Derivative Inc. (Derivative) 2 | * and can only be used, and/or modified for use, in conjunction with 3 | * Derivative's TouchDesigner software, and only if you are a licensee who has 4 | * accepted Derivative's TouchDesigner license or assignment agreement 5 | * (which also govern the use of this file). You may share or redistribute 6 | * a modified version of this file provided the following conditions are met: 7 | * 8 | * 1. The shared file or redistribution must retain the information set out 9 | * above and this list of conditions. 10 | * 2. Derivative's name (Derivative Inc.) or its trademarks may not be used 11 | * to endorse or promote products derived from this file without specific 12 | * prior written permission from Derivative. 13 | */ 14 | 15 | /******* 16 | Derivative Developers: Make sure the virtual function order 17 | stays the same, otherwise changes won't be backwards compatible 18 | ********/ 19 | 20 | 21 | #ifndef __CPlusPlus_Common 22 | #define __CPlusPlus_Common 23 | 24 | 25 | #ifdef _WIN32 26 | #define NOMINMAX 27 | #include 28 | #include 29 | #include "GL_Extensions.h" 30 | #define DLLEXPORT __declspec (dllexport) 31 | #else 32 | #include 33 | #define DLLEXPORT 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #ifndef PyObject_HEAD 41 | struct _object; 42 | typedef _object PyObject; 43 | #endif 44 | 45 | struct cudaArray; 46 | 47 | enum class OP_CPUMemPixelType : int32_t 48 | { 49 | // 8-bit per color, BGRA pixels. This is preferred for 4 channel 8-bit data 50 | BGRA8Fixed = 0, 51 | // 8-bit per color, RGBA pixels. Only use this one if absolutely nesseary. 52 | RGBA8Fixed, 53 | // 32-bit float per color, RGBA pixels 54 | RGBA32Float, 55 | 56 | // Single and double channel options 57 | // Fixed 58 | R8Fixed, 59 | RG8Fixed, 60 | // Float 61 | R32Float, 62 | RG32Float, 63 | }; 64 | 65 | class OP_String; 66 | 67 | // Used to describe this Plugin so it can be used as a custom OP. 68 | // Can be filled in as part of the Fill*PluginInfo() callback 69 | class OP_CustomOPInfo 70 | { 71 | public: 72 | // For this plugin to be treated as a Custom OP, all of the below fields 73 | // must be filled in correctly. Otherwise the .dll can only be used 74 | // when manually loaded into the C++ TOP 75 | 76 | // The type name of the node, this needs to be unique from all the other 77 | // TOP plugins loaded on the system. The name must start with an upper case 78 | // character (A-Z), and the rest should be lower case 79 | // Only the characters a-z and 0-9 are allowed in the opType. 80 | // Spaces are not allowed 81 | OP_String* opType; 82 | 83 | // The english readable label for the node. This is what is show in the 84 | // OP Create Menu dialog. 85 | // Spaces and other special characters are allowed. 86 | // This can be a UTF-8 encoded string for non-english langauge label 87 | OP_String* opLabel; 88 | 89 | // This should be three letters (upper or lower case), or numbers, which 90 | // are used to create an icon for this Custom OP. 91 | OP_String* opIcon; 92 | 93 | // The minimum number of wired inputs required for this OP to function. 94 | int32_t minInputs = 0; 95 | 96 | // The maximum number of connected inputs allowed for this OP. If this plugin 97 | // always requires 1 input, then set both min and max to 1. 98 | int32_t maxInputs = 0; 99 | 100 | // The name of the author 101 | OP_String* authorName; 102 | 103 | // The email of the author 104 | OP_String* authorEmail; 105 | 106 | // Major version should be used to differentiate between drastically different 107 | // versions of this Custom OP. In particular changes that arn't backwards 108 | // compatible. 109 | // A project file will compare the major version of OPs saved in it with the 110 | // major version of the plugin installed on the system, and expect them to be 111 | // the same. 112 | int32_t majorVersion = 0; 113 | 114 | // Minor version is used to denote upgrades to a plugin. It should be increased 115 | // when new features are added to a plugin that would cause loading up a project 116 | // with an older version of the plguin to behavior incorrectly. For example 117 | // if new parameters are added to the plugin. 118 | // A project file will expect the plugin installed on the system to be greater than 119 | // or equal to the plugin version the project was created with. Assuming 120 | // the majorVersion is the same. 121 | int32_t minorVersion = 1; 122 | 123 | // If this Custom OP is using CPython objects (PyObject* etc.) obtained via 124 | // getParPython() calls, this needs to be set to the Python 125 | // version this plugin is compiled against. 126 | // 127 | // This ensures when TD's Python version is upgraded the plugins will 128 | // error cleanly. This should be set to PY_VERSION as defined in 129 | // patchlevel.h from the Python include folder. (E.g, "3.5.1") 130 | // It should be left unchanged if CPython isn't being used in this plugin. 131 | OP_String* pythonVersion; 132 | 133 | int32_t reserved[98]; 134 | }; 135 | 136 | 137 | class OP_NodeInfo 138 | { 139 | public: 140 | // The full path to the operator 141 | 142 | const char* opPath; 143 | 144 | // A unique ID representing the operator, no two operators will ever 145 | // have the same ID in a single TouchDesigner instance. 146 | 147 | uint32_t opId; 148 | 149 | // This is the handle to the main TouchDesigner window. 150 | // It's possible this will be 0 the first few times the operator cooks, 151 | // incase it cooks while TouchDesigner is still loading up 152 | 153 | #ifdef _WIN32 154 | HWND mainWindowHandle; 155 | #endif 156 | 157 | int32_t reserved[19]; 158 | }; 159 | 160 | 161 | class OP_DATInput 162 | { 163 | public: 164 | const char* opPath; 165 | uint32_t opId; 166 | 167 | int32_t numRows; 168 | int32_t numCols; 169 | bool isTable; 170 | 171 | // data, referenced by (row,col), which will be a const char* for the 172 | // contents of the cell 173 | // E.g getCell(1,2) will be the contents of the cell located at (1,2) 174 | // The string will be in UTF-8 encoding. 175 | const char* 176 | getCell(int32_t row, int32_t col) const 177 | { 178 | return cellData[row * numCols + col]; 179 | } 180 | 181 | const char** cellData; 182 | 183 | // The number of times this node has cooked 184 | int64_t totalCooks; 185 | 186 | int32_t reserved[18]; 187 | }; 188 | 189 | 190 | class OP_TOPInput 191 | { 192 | public: 193 | const char* opPath; 194 | uint32_t opId; 195 | 196 | int32_t width; 197 | int32_t height; 198 | 199 | // You can use OP_Inputs::getTOPDataInCPUMemory() to download the 200 | // data from a TOP input into CPU memory easily. 201 | 202 | // The OpenGL Texture index for this TOP. 203 | // This is only valid when accessed from C++ TOPs. 204 | // Other C++ OPs will have this value set to 0 (invalid). 205 | GLuint textureIndex; 206 | 207 | // The OpenGL Texture target for this TOP. 208 | // E.g GL_TEXTURE_2D, GL_TEXTURE_CUBE, 209 | // GL_TEXTURE_2D_ARRAY 210 | GLenum textureType; 211 | 212 | // Depth for 3D and 2D_ARRAY textures, undefined 213 | // for other texture types 214 | uint32_t depth; 215 | 216 | // contains the internalFormat for the texture 217 | // such as GL_RGBA8, GL_RGBA32F, GL_R16 218 | GLint pixelFormat; 219 | 220 | int32_t reserved1; 221 | 222 | // When the TOP_ExecuteMode is CUDA, this will be filled in 223 | cudaArray* cudaInput; 224 | 225 | // The number of times this node has cooked 226 | int64_t totalCooks; 227 | 228 | int32_t reserved[14]; 229 | }; 230 | 231 | class OP_String 232 | { 233 | protected: 234 | OP_String() 235 | { 236 | } 237 | 238 | virtual ~OP_String() 239 | { 240 | } 241 | 242 | public: 243 | 244 | // val is expected to be UTF-8 encoded 245 | virtual void setString(const char* val) = 0; 246 | 247 | 248 | int32_t reserved[20]; 249 | 250 | }; 251 | 252 | 253 | class OP_CHOPInput 254 | { 255 | public: 256 | 257 | const char* opPath; 258 | uint32_t opId; 259 | 260 | int32_t numChannels; 261 | int32_t numSamples; 262 | double sampleRate; 263 | double startIndex; 264 | 265 | 266 | 267 | // Retrieve a float array for a specific channel. 268 | // 'i' ranges from 0 to numChannels-1 269 | // The returned arrray contains 'numSamples' samples. 270 | // e.g: getChannelData(1)[10] will refer to the 11th sample in the 2nd channel 271 | 272 | const float* 273 | getChannelData(int32_t i) const 274 | { 275 | return channelData[i]; 276 | } 277 | 278 | 279 | // Retrieve the name of a specific channel. 280 | // 'i' ranges from 0 to numChannels-1 281 | // For example getChannelName(1) is the name of the 2nd channel 282 | 283 | const char* 284 | getChannelName(int32_t i) const 285 | { 286 | return nameData[i]; 287 | } 288 | 289 | const float** channelData; 290 | const char** nameData; 291 | 292 | // The number of times this node has cooked 293 | int64_t totalCooks; 294 | 295 | int32_t reserved[18]; 296 | }; 297 | 298 | 299 | class OP_ObjectInput 300 | { 301 | public: 302 | 303 | const char* opPath; 304 | uint32_t opId; 305 | 306 | // Use these methods to calculate object transforms 307 | double worldTransform[4][4]; 308 | double localTransform[4][4]; 309 | 310 | // The number of times this node has cooked 311 | int64_t totalCooks; 312 | 313 | int32_t reserved[18]; 314 | }; 315 | 316 | 317 | // The type of data the attribute holds 318 | enum class AttribType : int32_t 319 | { 320 | // One or more floats 321 | Float = 0, 322 | 323 | // One or more integers 324 | Int, 325 | }; 326 | 327 | // Right now we only support point attributes. 328 | enum class AttribSet : int32_t 329 | { 330 | Invalid, 331 | Point = 0, 332 | }; 333 | 334 | // The type of the primitives, currently only Polygon type 335 | // is supported 336 | enum class PrimitiveType : int32_t 337 | { 338 | Invalid, 339 | Polygon = 0, 340 | }; 341 | 342 | 343 | class Vector 344 | { 345 | public: 346 | Vector() 347 | { 348 | x = 0.0f; 349 | y = 0.0f; 350 | z = 0.0f; 351 | } 352 | 353 | Vector(float xx, float yy, float zz) 354 | { 355 | x = xx; 356 | y = yy; 357 | z = zz; 358 | } 359 | 360 | // inplace operators 361 | inline Vector& 362 | operator*=(const float scalar) 363 | { 364 | x *= scalar; 365 | y *= scalar; 366 | z *= scalar; 367 | return *this; 368 | } 369 | 370 | inline Vector& 371 | operator/=(const float scalar) 372 | { 373 | x /= scalar; 374 | y /= scalar; 375 | z /= scalar; 376 | return *this; 377 | } 378 | 379 | inline Vector& 380 | operator-=(const Vector& trans) 381 | { 382 | x -= trans.x; 383 | y -= trans.y; 384 | z -= trans.z; 385 | return *this; 386 | } 387 | 388 | inline Vector& 389 | operator+=(const Vector& trans) 390 | { 391 | x += trans.x; 392 | y += trans.y; 393 | z += trans.z; 394 | return *this; 395 | } 396 | 397 | // non-inplace operations: 398 | inline Vector 399 | operator*(const float scalar) 400 | { 401 | Vector temp(*this); 402 | temp.x *= scalar; 403 | temp.y *= scalar; 404 | temp.z *= scalar; 405 | return temp; 406 | } 407 | 408 | inline Vector 409 | operator/(const float scalar) 410 | { 411 | Vector temp(*this); 412 | temp.x /= scalar; 413 | temp.y /= scalar; 414 | temp.z /= scalar; 415 | return temp; 416 | } 417 | 418 | inline Vector 419 | operator-(const Vector& trans) 420 | { 421 | Vector temp(*this); 422 | temp.x -= trans.x; 423 | temp.y -= trans.y; 424 | temp.z -= trans.z; 425 | return temp; 426 | } 427 | 428 | inline Vector 429 | operator+(const Vector& trans) 430 | { 431 | Vector temp(*this); 432 | temp.x += trans.x; 433 | temp.y += trans.y; 434 | temp.z += trans.z; 435 | return temp; 436 | } 437 | 438 | //------ 439 | float 440 | dot(const Vector &v) const 441 | { 442 | return x * v.x + y * v.y + z * v.z; 443 | } 444 | 445 | inline float 446 | length() 447 | { 448 | return sqrtf(dot(*this)); 449 | } 450 | 451 | inline float 452 | normalize() 453 | { 454 | float dn = x * x + y * y + z * z; 455 | if (dn > FLT_MIN && dn != 1.0F) 456 | { 457 | dn = sqrtf(dn); 458 | (*this) /= dn; 459 | } 460 | return dn; 461 | } 462 | 463 | float x; 464 | float y; 465 | float z; 466 | }; 467 | 468 | class Position 469 | { 470 | public: 471 | Position() 472 | { 473 | x = 0.0f; 474 | y = 0.0f; 475 | z = 0.0f; 476 | } 477 | 478 | Position(float xx, float yy, float zz) 479 | { 480 | x = xx; 481 | y = yy; 482 | z = zz; 483 | } 484 | 485 | // in-place operators 486 | inline Position& operator*=(const float scalar) 487 | { 488 | x *= scalar; 489 | y *= scalar; 490 | z *= scalar; 491 | return *this; 492 | } 493 | 494 | inline Position& operator/=(const float scalar) 495 | { 496 | x /= scalar; 497 | y /= scalar; 498 | z /= scalar; 499 | return *this; 500 | } 501 | 502 | inline Position& operator-=(const Vector& trans) 503 | { 504 | x -= trans.x; 505 | y -= trans.y; 506 | z -= trans.z; 507 | return *this; 508 | } 509 | 510 | inline Position& operator+=(const Vector& trans) 511 | { 512 | x += trans.x; 513 | y += trans.y; 514 | z += trans.z; 515 | return *this; 516 | } 517 | 518 | // non-inplace operators 519 | inline Position operator*(const float scalar) 520 | { 521 | Position temp(*this); 522 | temp.x *= scalar; 523 | temp.y *= scalar; 524 | temp.z *= scalar; 525 | return temp; 526 | } 527 | 528 | inline Position operator/(const float scalar) 529 | { 530 | Position temp(*this); 531 | temp.x /= scalar; 532 | temp.y /= scalar; 533 | temp.z /= scalar; 534 | return temp; 535 | } 536 | 537 | inline Position operator+(const Vector& trans) 538 | { 539 | Position temp(*this); 540 | temp.x += trans.x; 541 | temp.y += trans.y; 542 | temp.z += trans.z; 543 | return temp; 544 | } 545 | 546 | inline Position operator-(const Vector& trans) 547 | { 548 | Position temp(*this); 549 | temp.x -= trans.x; 550 | temp.y -= trans.y; 551 | temp.z -= trans.z; 552 | return temp; 553 | } 554 | 555 | float x; 556 | float y; 557 | float z; 558 | }; 559 | 560 | 561 | class Color 562 | { 563 | public: 564 | Color () 565 | { 566 | r = 1.0f; 567 | g = 1.0f; 568 | b = 1.0f; 569 | a = 1.0f; 570 | } 571 | 572 | Color (float rr, float gg, float bb, float aa) 573 | { 574 | r = rr; 575 | g = gg; 576 | b = bb; 577 | a = aa; 578 | } 579 | 580 | float r; 581 | float g; 582 | float b; 583 | float a; 584 | }; 585 | 586 | 587 | class TexCoord 588 | { 589 | public: 590 | TexCoord() 591 | { 592 | u = 0.0f; 593 | v = 0.0f; 594 | w = 0.0f; 595 | } 596 | 597 | TexCoord(float uu, float vv, float ww) 598 | { 599 | u = uu; 600 | v = vv; 601 | w = ww; 602 | } 603 | 604 | float u; 605 | float v; 606 | float w; 607 | }; 608 | 609 | class BoundingBox 610 | { 611 | public: 612 | BoundingBox(float minx, float miny, float minz, 613 | float maxx, float maxy, float maxz) : 614 | minX(minx), minY(miny), minZ(minz), maxX(maxx), maxY(maxy), maxZ(maxz) 615 | { 616 | } 617 | 618 | BoundingBox(const Position& min, const Position& max) 619 | { 620 | minX = min.x; 621 | maxX = max.x; 622 | minY = min.y; 623 | maxY = max.y; 624 | minZ = min.z; 625 | maxZ = max.z; 626 | } 627 | 628 | BoundingBox(const Position& center, float x, float y, float z) 629 | { 630 | minX = center.x - x; 631 | maxX = center.x + x; 632 | minY = center.y - y; 633 | maxY = center.y + y; 634 | minZ = center.z - z; 635 | maxZ = center.z + z; 636 | } 637 | 638 | // enlarge the bounding box by the input point Position 639 | void 640 | enlargeBounds(const Position& pos) 641 | { 642 | if (pos.x < minX) 643 | minX = pos.x; 644 | if (pos.x > maxX) 645 | maxX = pos.x; 646 | if (pos.y < minY) 647 | minY = pos.y; 648 | if (pos.y > maxY) 649 | maxY = pos.y; 650 | if (pos.z < minZ) 651 | minZ = pos.z; 652 | if (pos.z > maxZ) 653 | maxZ = pos.z; 654 | } 655 | 656 | // enlarge the bounding box by the input bounding box: 657 | void 658 | enlargeBounds(const BoundingBox &box) 659 | { 660 | if (box.minX < minX) 661 | minX = box.minX; 662 | if (box.maxX > maxX) 663 | maxX = box.maxX; 664 | if (box.minY < minY) 665 | minY = box.minY; 666 | if (box.maxY > maxY) 667 | maxY = box.maxY; 668 | if (box.minZ < minZ) 669 | minZ = box.minZ; 670 | if (box.maxZ > maxZ) 671 | maxZ = box.maxZ; 672 | } 673 | 674 | // returns the bounding box length in x axis: 675 | float 676 | sizeX() 677 | { 678 | return maxX - minX; 679 | } 680 | 681 | // returns the bounding box length in y axis: 682 | float 683 | sizeY() 684 | { 685 | return maxY - minY; 686 | } 687 | 688 | // returns the bounding box length in z axis: 689 | float 690 | sizeZ() 691 | { 692 | return maxZ - minZ; 693 | } 694 | 695 | bool 696 | getCenter(Position* pos) 697 | { 698 | if (!pos) 699 | return false; 700 | pos->x = (minX + maxX) / 2.0f; 701 | pos->y = (minY + maxY) / 2.0f; 702 | pos->z = (minZ + maxZ) / 2.0f; 703 | return true; 704 | } 705 | 706 | // verifies if the input position (pos) is inside the current bounding box or not: 707 | bool 708 | isInside(const Position& pos) 709 | { 710 | if (pos.x >= minX && pos.x <= maxX && 711 | pos.y >= minY && pos.y <= maxY && 712 | pos.z >= minZ && pos.z <= maxZ) 713 | return true; 714 | else 715 | return false; 716 | } 717 | 718 | 719 | float minX; 720 | float minY; 721 | float minZ; 722 | 723 | float maxX; 724 | float maxY; 725 | float maxZ; 726 | 727 | }; 728 | 729 | 730 | class SOP_NormalInfo 731 | { 732 | public: 733 | 734 | SOP_NormalInfo() 735 | { 736 | numNormals = 0; 737 | attribSet = AttribSet::Point; 738 | normals = nullptr; 739 | } 740 | 741 | int32_t numNormals; 742 | AttribSet attribSet; 743 | const Vector* normals; 744 | }; 745 | 746 | class SOP_ColorInfo 747 | { 748 | public: 749 | 750 | SOP_ColorInfo() 751 | { 752 | numColors = 0; 753 | attribSet = AttribSet::Point; 754 | colors = nullptr; 755 | } 756 | 757 | int32_t numColors; 758 | AttribSet attribSet; 759 | const Color* colors; 760 | }; 761 | 762 | class SOP_TextureInfo 763 | { 764 | public: 765 | 766 | SOP_TextureInfo() 767 | { 768 | numTextures = 0; 769 | attribSet = AttribSet::Point; 770 | textures = nullptr; 771 | numTextureLayers = 0; 772 | } 773 | 774 | int32_t numTextures; 775 | AttribSet attribSet; 776 | const TexCoord* textures; 777 | int32_t numTextureLayers; 778 | }; 779 | 780 | 781 | 782 | // CustomAttribInfo, all the required data for each custom attribute 783 | // this info can be queried by calling getCustomAttribute() which accepts 784 | // two types of argument: 785 | // 1) a valid index of a custom attribute 786 | // 2) a valid name of a custom attribute 787 | class SOP_CustomAttribInfo 788 | { 789 | public: 790 | 791 | SOP_CustomAttribInfo() 792 | { 793 | name = nullptr; 794 | numComponents = 0; 795 | attribType = AttribType::Float; 796 | } 797 | 798 | SOP_CustomAttribInfo(const char* n, int32_t numComp, const AttribType& type) 799 | { 800 | name = n; 801 | numComponents = numComp; 802 | attribType = type; 803 | } 804 | 805 | const char* name; 806 | int32_t numComponents; 807 | AttribType attribType; 808 | }; 809 | 810 | // SOP_CustomAttribData, all the required data for each custom attribute 811 | // this info can be queried by calling getCustomAttribute() which accepts 812 | // a valid name of a custom attribute 813 | class SOP_CustomAttribData : public SOP_CustomAttribInfo 814 | { 815 | public: 816 | 817 | SOP_CustomAttribData() 818 | { 819 | name = nullptr; 820 | numComponents = 0; 821 | attribType = AttribType::Float; 822 | floatData = nullptr; 823 | intData = nullptr; 824 | } 825 | 826 | SOP_CustomAttribData(const char* n, int32_t numComp, const AttribType& type) 827 | { 828 | name = n; 829 | numComponents = numComp; 830 | attribType = type; 831 | floatData = nullptr; 832 | intData = nullptr; 833 | } 834 | 835 | const float* floatData; 836 | const int32_t* intData; 837 | 838 | }; 839 | 840 | // SOP_PrimitiveInfo, all the required data for each primitive 841 | // this info can be queried by calling getPrimitive() which accepts 842 | // a valid index of a primitive as an input argument 843 | class SOP_PrimitiveInfo 844 | { 845 | public: 846 | 847 | SOP_PrimitiveInfo() 848 | { 849 | pointIndices = nullptr; 850 | numVertices = 0; 851 | type = PrimitiveType::Invalid; 852 | pointIndicesOffset = 0; 853 | } 854 | 855 | // number of vertices of this prim 856 | int32_t numVertices; 857 | 858 | // all the indices of the vertices of the primitive. This array has 859 | // numVertices entries in it 860 | const int32_t* pointIndices; 861 | 862 | // The type of this primitive 863 | PrimitiveType type; 864 | 865 | // the offset of the this primitive's point indices in the index array 866 | // returned from getAllPrimPointIndices() 867 | int32_t pointIndicesOffset; 868 | 869 | }; 870 | 871 | 872 | 873 | 874 | class OP_SOPInput 875 | { 876 | public: 877 | 878 | virtual ~OP_SOPInput() 879 | { 880 | } 881 | 882 | 883 | 884 | const char* opPath; 885 | uint32_t opId; 886 | 887 | 888 | // Returns the total number of points 889 | virtual int32_t getNumPoints() const = 0; 890 | 891 | // The total number of vertices, across all primitives. 892 | virtual int32_t getNumVertices() const = 0; 893 | 894 | // The total number of primitives 895 | virtual int32_t getNumPrimitives() const = 0; 896 | 897 | // The total number of custom attributes 898 | virtual int32_t getNumCustomAttributes() const = 0; 899 | 900 | // Returns an array of point positions. This array is getNumPoints() long. 901 | virtual const Position* getPointPositions() const = 0; 902 | 903 | // Returns an array of normals. 904 | // 905 | // Returns nullptr if no normals are present 906 | virtual const SOP_NormalInfo* getNormals() const = 0; 907 | 908 | // Returns an array of colors. 909 | // Returns nullptr if no colors are present 910 | virtual const SOP_ColorInfo* getColors() const = 0; 911 | 912 | // Returns an array of texture coordinates. 913 | // If multiple texture coordinate layers are present, they will be placed 914 | // interleaved back-to-back. 915 | // E.g layer0 followed by layer1 followed by layer0 etc. 916 | // 917 | // Returns nullptr if no texture layers are present 918 | virtual const SOP_TextureInfo* getTextures() const = 0; 919 | 920 | // Returns the custom attribute data with an input index 921 | virtual const SOP_CustomAttribData* getCustomAttribute(int32_t customAttribIndex) const = 0; 922 | 923 | // Returns the custom attribute data with its name 924 | virtual const SOP_CustomAttribData* getCustomAttribute(const char* customAttribName) const = 0; 925 | 926 | // Returns true if the SOP has a normal attribute of the given source 927 | // attribute 'N' 928 | virtual bool hasNormals() const = 0; 929 | 930 | // Returns true if the SOP has a color the given source 931 | // attribute 'Cd' 932 | virtual bool hasColors() const = 0; 933 | 934 | // Returns the SOP_PrimitiveInfo with primIndex 935 | const SOP_PrimitiveInfo 936 | getPrimitive(int32_t primIndex) const 937 | { 938 | return myPrimsInfo[primIndex]; 939 | } 940 | 941 | // Returns the full list of all the point indices for all primitives. 942 | // The primitives are stored back to back in this array. 943 | // This is a faster but harder way to work with primitives than 944 | // getPrimPointIndices() 945 | const int32_t* 946 | getAllPrimPointIndices() 947 | { 948 | return myPrimPointIndices; 949 | } 950 | 951 | SOP_PrimitiveInfo* myPrimsInfo; 952 | const int32_t* myPrimPointIndices; 953 | 954 | // The number of times this node has cooked 955 | int64_t totalCooks; 956 | 957 | int32_t reserved[98]; 958 | }; 959 | 960 | 961 | 962 | enum class OP_TOPInputDownloadType : int32_t 963 | { 964 | // The texture data will be downloaded and and available on the next frame. 965 | // Except for the first time this is used, getTOPDataInCPUMemory() 966 | // will return the texture data on the CPU from the previous frame. 967 | // The first getTOPDataInCPUMemory() is called it will be nullptr. 968 | // ** This mode should be used is most cases for performance reasons ** 969 | Delayed = 0, 970 | 971 | // The texture data will be downloaded immediately and be available 972 | // this frame. This can cause a large stall though and should be avoided 973 | // in most cases 974 | Instant, 975 | }; 976 | 977 | class OP_TOPInputDownloadOptions 978 | { 979 | public: 980 | OP_TOPInputDownloadOptions() 981 | { 982 | downloadType = OP_TOPInputDownloadType::Delayed; 983 | verticalFlip = false; 984 | cpuMemPixelType = OP_CPUMemPixelType::BGRA8Fixed; 985 | } 986 | 987 | OP_TOPInputDownloadType downloadType; 988 | 989 | // Set this to true if you want the image vertically flipped in the 990 | // downloaded data 991 | bool verticalFlip; 992 | 993 | // Set this to how you want the pixel data to be give to you in CPU 994 | // memory. BGRA8Fixed should be used for 4 channel 8-bit data if possible 995 | OP_CPUMemPixelType cpuMemPixelType; 996 | 997 | }; 998 | 999 | class OP_TimeInfo 1000 | { 1001 | public: 1002 | 1003 | // same as global Python value absTime.frame. Counts up forever 1004 | // since the application started. In rootFPS units. 1005 | int64_t absFrame; 1006 | 1007 | // The timeline frame number for this cook 1008 | double frame; 1009 | 1010 | // The timeline FPS/rate this node is cooking at. 1011 | // If the component this node is located in has Component Time, it's FPS 1012 | // may be different than the Root FPS 1013 | double rate; 1014 | 1015 | // The frame number for the root timeline. Different than frame 1016 | // if the node is in a component that has component time. 1017 | double rootFrame; 1018 | 1019 | // The Root FPS/Rate the file is running at. 1020 | double rootRate; 1021 | 1022 | // The number of frames that have elapsed since the last cook occured. 1023 | // This can be more than one if frames were dropped. 1024 | // If this is the first time this node is cooking, this will be 0.0 1025 | // This is in 'rate' units, not 'rootRate' units. 1026 | double deltaFrames; 1027 | 1028 | // The number of milliseconds that have elapsed since the last cook. 1029 | // Note that this isn't done via CPU timers, but is instead 1030 | // simply deltaFrames * milliSecondsPerFrame 1031 | double deltaMS; 1032 | 1033 | 1034 | 1035 | int32_t reserved[40]; 1036 | }; 1037 | 1038 | 1039 | class OP_Inputs 1040 | { 1041 | public: 1042 | // NOTE: When writting a TOP, none of these functions should 1043 | // be called inside a beginGLCommands()/endGLCommands() section 1044 | // as they may require GL themselves to complete execution. 1045 | 1046 | // Inputs that are wired into the node. Note that since some inputs 1047 | // may not be connected this number doesn't mean that that the first N 1048 | // inputs are connected. For example on a 3 input node if the 3rd input 1049 | // is only one connected, this will return 1, and getInput*(0) and (1) 1050 | // will return nullptr. 1051 | virtual int32_t getNumInputs() const = 0; 1052 | 1053 | // Will return nullptr when the input has nothing connected to it. 1054 | // only valid for C++ TOP operators 1055 | virtual const OP_TOPInput* getInputTOP(int32_t index) const = 0; 1056 | // Only valid for C++ CHOP operators 1057 | virtual const OP_CHOPInput* getInputCHOP(int32_t index) const = 0; 1058 | // getInputSOP() declared later on in the class 1059 | // getInputDAT() declared later on in the class 1060 | 1061 | // these are defined by parameters. 1062 | // may return nullptr when invalid input 1063 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 1064 | virtual const OP_DATInput* getParDAT(const char *name) const = 0; 1065 | virtual const OP_TOPInput* getParTOP(const char *name) const = 0; 1066 | virtual const OP_CHOPInput* getParCHOP(const char *name) const = 0; 1067 | virtual const OP_ObjectInput* getParObject(const char *name) const = 0; 1068 | // getParSOP() declared later on in the class 1069 | 1070 | // these work on any type of parameter and can be interchanged 1071 | // for menu types, int returns the menu selection index, string returns the item 1072 | 1073 | // returns the requested value, index may be 0 to 4. 1074 | virtual double getParDouble(const char* name, int32_t index = 0) const = 0; 1075 | 1076 | // for multiple values: returns True on success/false otherwise 1077 | virtual bool getParDouble2(const char* name, double &v0, double &v1) const = 0; 1078 | virtual bool getParDouble3(const char* name, double &v0, double &v1, double &v2) const = 0; 1079 | virtual bool getParDouble4(const char* name, double &v0, double &v1, double &v2, double &v3) const = 0; 1080 | 1081 | 1082 | // returns the requested value 1083 | virtual int32_t getParInt(const char* name, int32_t index = 0) const = 0; 1084 | 1085 | // for multiple values: returns True on success/false otherwise 1086 | virtual bool getParInt2(const char* name, int32_t &v0, int32_t &v1) const = 0; 1087 | virtual bool getParInt3(const char* name, int32_t &v0, int32_t &v1, int32_t &v2) const = 0; 1088 | virtual bool getParInt4(const char* name, int32_t &v0, int32_t &v1, int32_t &v2, int32_t &v3) const = 0; 1089 | 1090 | // returns the requested value 1091 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 1092 | // return value usable for life of parameter 1093 | // The returned string will be in UTF-8 encoding. 1094 | virtual const char* getParString(const char* name) const = 0; 1095 | 1096 | 1097 | // this is similar to getParString, but will return an absolute path if it exists, with 1098 | // slash direction consistent with O/S requirements. 1099 | // to get the original parameter value, use getParString 1100 | // return value usable for life of parameter 1101 | // The returned string will be in UTF-8 encoding. 1102 | virtual const char* getParFilePath(const char* name) const = 0; 1103 | 1104 | // returns true on success 1105 | // from_name and to_name must be Object parameters 1106 | virtual bool getRelativeTransform(const char* from_name, const char* to_name, double matrix[4][4]) const = 0; 1107 | 1108 | 1109 | // disable or enable updating of the parameter 1110 | virtual void enablePar(const char* name, bool onoff) const = 0; 1111 | 1112 | 1113 | // these are defined by paths. 1114 | // may return nullptr when invalid input 1115 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 1116 | virtual const OP_DATInput* getDAT(const char *path) const = 0; 1117 | virtual const OP_TOPInput* getTOP(const char *path) const = 0; 1118 | virtual const OP_CHOPInput* getCHOP(const char *path) const = 0; 1119 | virtual const OP_ObjectInput* getObject(const char *path) const = 0; 1120 | 1121 | 1122 | // This function can be used to retrieve the TOPs texture data in CPU 1123 | // memory. You must pass the OP_TOPInput object you get from 1124 | // getParTOP/getInputTOP into this, not a copy you've made 1125 | // 1126 | // Fill in a OP_TOPIputDownloadOptions class with the desired options set 1127 | // 1128 | // Returns the data, which will be valid until the end of execute() 1129 | // Returned value may be nullptr in some cases, such as the first call 1130 | // to this with options->downloadType == OP_TOP_DOWNLOAD_DELAYED. 1131 | virtual void* getTOPDataInCPUMemory(const OP_TOPInput *top, 1132 | const OP_TOPInputDownloadOptions *options) const = 0; 1133 | 1134 | 1135 | virtual const OP_SOPInput* getParSOP(const char *name) const = 0; 1136 | // only valid for C++ SOP operators 1137 | virtual const OP_SOPInput* getInputSOP(int32_t index) const = 0; 1138 | virtual const OP_SOPInput* getSOP(const char *path) const = 0; 1139 | 1140 | // only valid for C++ DAT operators 1141 | virtual const OP_DATInput* getInputDAT(int32_t index) const = 0; 1142 | 1143 | // To use Python in your Plugin you need to fill the 1144 | // customOPInfo.pythonVersion member in Fill*PluginInfo. 1145 | // 1146 | // The returned object does NOT have it's reference count incremented. 1147 | // So increment it if you want to hold onto the object, and only 1148 | // decement it if you've incremented it. 1149 | virtual PyObject* getParPython(const char* name) const = 0; 1150 | 1151 | 1152 | // Returns a class whose members gives you information about timing 1153 | // such as FPS and delta-time since the last cook. 1154 | // See OP_TimeInfo for more information 1155 | virtual const OP_TimeInfo* getTimeInfo() const = 0; 1156 | 1157 | }; 1158 | 1159 | class OP_InfoCHOPChan 1160 | { 1161 | public: 1162 | OP_String* name; 1163 | float value; 1164 | 1165 | int32_t reserved[10]; 1166 | }; 1167 | 1168 | 1169 | class OP_InfoDATSize 1170 | { 1171 | public: 1172 | 1173 | // Set this to the size you want the table to be 1174 | 1175 | int32_t rows; 1176 | int32_t cols; 1177 | 1178 | // Set this to true if you want to return DAT entries on a column 1179 | // by column basis. 1180 | // Otherwise set to false, and you'll be expected to set them on 1181 | // a row by row basis. 1182 | // DEFAULT : false 1183 | 1184 | bool byColumn; 1185 | 1186 | int32_t reserved[10]; 1187 | }; 1188 | 1189 | 1190 | class OP_InfoDATEntries 1191 | { 1192 | public: 1193 | 1194 | // This is an array of OP_String* pointers which you are expected to assign 1195 | // values to. 1196 | // e.g values[1]->setString("myColumnName"); 1197 | // The string should be in UTF-8 encoding. 1198 | OP_String** values; 1199 | 1200 | int32_t reserved[10]; 1201 | }; 1202 | 1203 | 1204 | class OP_NumericParameter 1205 | { 1206 | public: 1207 | 1208 | OP_NumericParameter(const char* iname = nullptr) 1209 | { 1210 | name = iname; 1211 | label = page = nullptr; 1212 | 1213 | for (int i = 0; i<4; i++) 1214 | { 1215 | defaultValues[i] = 0.0; 1216 | 1217 | minSliders[i] = 0.0; 1218 | maxSliders[i] = 1.0; 1219 | 1220 | minValues[i] = 0.0; 1221 | maxValues[i] = 1.0; 1222 | 1223 | clampMins[i] = false; 1224 | clampMaxes[i] = false; 1225 | } 1226 | } 1227 | 1228 | // Any char* values passed are copied immediately by the append parameter functions, 1229 | // and do not need to be retained by the calling function. 1230 | // Must begin with capital letter, and contain no spaces 1231 | const char* name; 1232 | const char* label; 1233 | const char* page; 1234 | 1235 | double defaultValues[4]; 1236 | double minValues[4]; 1237 | double maxValues[4]; 1238 | 1239 | bool clampMins[4]; 1240 | bool clampMaxes[4]; 1241 | 1242 | double minSliders[4]; 1243 | double maxSliders[4]; 1244 | 1245 | int32_t reserved[20]; 1246 | 1247 | }; 1248 | 1249 | 1250 | class OP_StringParameter 1251 | { 1252 | public: 1253 | 1254 | OP_StringParameter(const char* iname = nullptr) 1255 | { 1256 | name = iname; 1257 | label = page = nullptr; 1258 | defaultValue = nullptr; 1259 | } 1260 | 1261 | // Any char* values passed are copied immediately by the append parameter functions, 1262 | // and do not need to be retained by the calling function. 1263 | 1264 | // Must begin with capital letter, and contain no spaces 1265 | const char* name; 1266 | const char* label; 1267 | const char* page; 1268 | 1269 | // This should be in UTF-8 encoding. 1270 | const char* defaultValue; 1271 | 1272 | int32_t reserved[20]; 1273 | }; 1274 | 1275 | 1276 | enum class OP_ParAppendResult : int32_t 1277 | { 1278 | Success = 0, 1279 | InvalidName, // invalid or duplicate name 1280 | InvalidSize, // size out of range 1281 | }; 1282 | 1283 | 1284 | class OP_ParameterManager 1285 | { 1286 | 1287 | public: 1288 | 1289 | // Returns PARAMETER_APPEND_SUCCESS on succesful 1290 | 1291 | virtual OP_ParAppendResult appendFloat(const OP_NumericParameter &np, int32_t size = 1) = 0; 1292 | virtual OP_ParAppendResult appendInt(const OP_NumericParameter &np, int32_t size = 1) = 0; 1293 | 1294 | virtual OP_ParAppendResult appendXY(const OP_NumericParameter &np) = 0; 1295 | virtual OP_ParAppendResult appendXYZ(const OP_NumericParameter &np) = 0; 1296 | 1297 | virtual OP_ParAppendResult appendUV(const OP_NumericParameter &np) = 0; 1298 | virtual OP_ParAppendResult appendUVW(const OP_NumericParameter &np) = 0; 1299 | 1300 | virtual OP_ParAppendResult appendRGB(const OP_NumericParameter &np) = 0; 1301 | virtual OP_ParAppendResult appendRGBA(const OP_NumericParameter &np) = 0; 1302 | 1303 | virtual OP_ParAppendResult appendToggle(const OP_NumericParameter &np) = 0; 1304 | virtual OP_ParAppendResult appendPulse(const OP_NumericParameter &np) = 0; 1305 | 1306 | virtual OP_ParAppendResult appendString(const OP_StringParameter &sp) = 0; 1307 | virtual OP_ParAppendResult appendFile(const OP_StringParameter &sp) = 0; 1308 | virtual OP_ParAppendResult appendFolder(const OP_StringParameter &sp) = 0; 1309 | 1310 | virtual OP_ParAppendResult appendDAT(const OP_StringParameter &sp) = 0; 1311 | virtual OP_ParAppendResult appendCHOP(const OP_StringParameter &sp) = 0; 1312 | virtual OP_ParAppendResult appendTOP(const OP_StringParameter &sp) = 0; 1313 | virtual OP_ParAppendResult appendObject(const OP_StringParameter &sp) = 0; 1314 | // appendSOP() located further down in the class 1315 | 1316 | 1317 | // Any char* values passed are copied immediately by the append parameter functions, 1318 | // and do not need to be retained by the calling function. 1319 | virtual OP_ParAppendResult appendMenu(const OP_StringParameter &sp, 1320 | int32_t nitems, const char **names, 1321 | const char **labels) = 0; 1322 | 1323 | // Any char* values passed are copied immediately by the append parameter functions, 1324 | // and do not need to be retained by the calling function. 1325 | virtual OP_ParAppendResult appendStringMenu(const OP_StringParameter &sp, 1326 | int32_t nitems, const char **names, 1327 | const char **labels) = 0; 1328 | 1329 | virtual OP_ParAppendResult appendSOP(const OP_StringParameter &sp) = 0; 1330 | 1331 | // To use Python in your Plugin you need to fill the 1332 | // customOPInfo.pythonVersion member in Fill*PluginInfo. 1333 | virtual OP_ParAppendResult appendPython(const OP_StringParameter &sp) = 0; 1334 | 1335 | 1336 | }; 1337 | 1338 | static_assert(offsetof(OP_CustomOPInfo, opType) == 0, "Incorrect Alignment"); 1339 | static_assert(offsetof(OP_CustomOPInfo, opLabel) == 8, "Incorrect Alignment"); 1340 | static_assert(offsetof(OP_CustomOPInfo, opIcon) == 16, "Incorrect Alignment"); 1341 | static_assert(offsetof(OP_CustomOPInfo, minInputs) == 24, "Incorrect Alignment"); 1342 | static_assert(offsetof(OP_CustomOPInfo, maxInputs) == 28, "Incorrect Alignment"); 1343 | static_assert(offsetof(OP_CustomOPInfo, authorName) == 32, "Incorrect Alignment"); 1344 | static_assert(offsetof(OP_CustomOPInfo, authorEmail) == 40, "Incorrect Alignment"); 1345 | static_assert(offsetof(OP_CustomOPInfo, majorVersion) == 48, "Incorrect Alignment"); 1346 | static_assert(offsetof(OP_CustomOPInfo, minorVersion) == 52, "Incorrect Alignment"); 1347 | static_assert(sizeof(OP_CustomOPInfo) == 456, "Incorrect Size"); 1348 | 1349 | static_assert(offsetof(OP_NodeInfo, opPath) == 0, "Incorrect Alignment"); 1350 | static_assert(offsetof(OP_NodeInfo, opId) == 8, "Incorrect Alignment"); 1351 | #ifdef _WIN32 1352 | static_assert(offsetof(OP_NodeInfo, mainWindowHandle) == 16, "Incorrect Alignment"); 1353 | static_assert(sizeof(OP_NodeInfo) == 104, "Incorrect Size"); 1354 | #else 1355 | static_assert(sizeof(OP_NodeInfo) == 88, "Incorrect Size"); 1356 | #endif 1357 | 1358 | static_assert(offsetof(OP_DATInput, opPath) == 0, "Incorrect Alignment"); 1359 | static_assert(offsetof(OP_DATInput, opId) == 8, "Incorrect Alignment"); 1360 | static_assert(offsetof(OP_DATInput, numRows) == 12, "Incorrect Alignment"); 1361 | static_assert(offsetof(OP_DATInput, numCols) == 16, "Incorrect Alignment"); 1362 | static_assert(offsetof(OP_DATInput, isTable) == 20, "Incorrect Alignment"); 1363 | static_assert(offsetof(OP_DATInput, cellData) == 24, "Incorrect Alignment"); 1364 | static_assert(offsetof(OP_DATInput, totalCooks) == 32, "Incorrect Alignment"); 1365 | static_assert(sizeof(OP_DATInput) == 112, "Incorrect Size"); 1366 | 1367 | static_assert(offsetof(OP_TOPInput, opPath) == 0, "Incorrect Alignment"); 1368 | static_assert(offsetof(OP_TOPInput, opId) == 8, "Incorrect Alignment"); 1369 | static_assert(offsetof(OP_TOPInput, width) == 12, "Incorrect Alignment"); 1370 | static_assert(offsetof(OP_TOPInput, height) == 16, "Incorrect Alignment"); 1371 | static_assert(offsetof(OP_TOPInput, textureIndex) == 20, "Incorrect Alignment"); 1372 | static_assert(offsetof(OP_TOPInput, textureType) == 24, "Incorrect Alignment"); 1373 | static_assert(offsetof(OP_TOPInput, depth) == 28, "Incorrect Alignment"); 1374 | static_assert(offsetof(OP_TOPInput, pixelFormat) == 32, "Incorrect Alignment"); 1375 | static_assert(offsetof(OP_TOPInput, cudaInput) == 40, "Incorrect Alignment"); 1376 | static_assert(offsetof(OP_TOPInput, totalCooks) == 48, "Incorrect Alignment"); 1377 | static_assert(sizeof(OP_TOPInput) == 112, "Incorrect Size"); 1378 | 1379 | static_assert(offsetof(OP_CHOPInput, opPath) == 0, "Incorrect Alignment"); 1380 | static_assert(offsetof(OP_CHOPInput, opId) == 8, "Incorrect Alignment"); 1381 | static_assert(offsetof(OP_CHOPInput, numChannels) == 12, "Incorrect Alignment"); 1382 | static_assert(offsetof(OP_CHOPInput, numSamples) == 16, "Incorrect Alignment"); 1383 | static_assert(offsetof(OP_CHOPInput, sampleRate) == 24, "Incorrect Alignment"); 1384 | static_assert(offsetof(OP_CHOPInput, startIndex) == 32, "Incorrect Alignment"); 1385 | static_assert(offsetof(OP_CHOPInput, channelData) == 40, "Incorrect Alignment"); 1386 | static_assert(offsetof(OP_CHOPInput, nameData) == 48, "Incorrect Alignment"); 1387 | static_assert(offsetof(OP_CHOPInput, totalCooks) == 56, "Incorrect Alignment"); 1388 | static_assert(sizeof(OP_CHOPInput) == 136, "Incorrect Size"); 1389 | 1390 | static_assert(offsetof(OP_ObjectInput, opPath) == 0, "Incorrect Alignment"); 1391 | static_assert(offsetof(OP_ObjectInput, opId) == 8, "Incorrect Alignment"); 1392 | static_assert(offsetof(OP_ObjectInput, worldTransform) == 16, "Incorrect Alignment"); 1393 | static_assert(offsetof(OP_ObjectInput, localTransform) == 144, "Incorrect Alignment"); 1394 | static_assert(offsetof(OP_ObjectInput, totalCooks) == 272, "Incorrect Alignment"); 1395 | static_assert(sizeof(OP_ObjectInput) == 352, "Incorrect Size"); 1396 | 1397 | static_assert(offsetof(Position, x) == 0, "Incorrect Alignment"); 1398 | static_assert(offsetof(Position, y) == 4, "Incorrect Alignment"); 1399 | static_assert(offsetof(Position, z) == 8, "Incorrect Alignment"); 1400 | static_assert(sizeof(Position) == 12, "Incorrect Size"); 1401 | 1402 | static_assert(offsetof(Vector, x) == 0, "Incorrect Alignment"); 1403 | static_assert(offsetof(Vector, y) == 4, "Incorrect Alignment"); 1404 | static_assert(offsetof(Vector, z) == 8, "Incorrect Alignment"); 1405 | static_assert(sizeof(Vector) == 12, "Incorrect Size"); 1406 | 1407 | static_assert(offsetof(Color, r) == 0, "Incorrect Alignment"); 1408 | static_assert(offsetof(Color, g) == 4, "Incorrect Alignment"); 1409 | static_assert(offsetof(Color, b) == 8, "Incorrect Alignment"); 1410 | static_assert(offsetof(Color, a) == 12, "Incorrect Alignment"); 1411 | static_assert(sizeof(Color) == 16, "Incorrect Size"); 1412 | 1413 | static_assert(offsetof(TexCoord, u) == 0, "Incorrect Alignment"); 1414 | static_assert(offsetof(TexCoord, v) == 4, "Incorrect Alignment"); 1415 | static_assert(offsetof(TexCoord, w) == 8, "Incorrect Alignment"); 1416 | static_assert(sizeof(TexCoord) == 12, "Incorrect Size"); 1417 | 1418 | static_assert(offsetof(SOP_NormalInfo, numNormals) == 0, "Incorrect Alignment"); 1419 | static_assert(offsetof(SOP_NormalInfo, attribSet) == 4, "Incorrect Alignment"); 1420 | static_assert(offsetof(SOP_NormalInfo, normals) == 8, "Incorrect Alignment"); 1421 | static_assert(sizeof(SOP_NormalInfo) == 16, "Incorrect Size"); 1422 | 1423 | static_assert(offsetof(SOP_ColorInfo, numColors) == 0, "Incorrect Alignment"); 1424 | static_assert(offsetof(SOP_ColorInfo, attribSet) == 4, "Incorrect Alignment"); 1425 | static_assert(offsetof(SOP_ColorInfo, colors) == 8, "Incorrect Alignment"); 1426 | static_assert(sizeof(SOP_ColorInfo) == 16, "Incorrect Size"); 1427 | 1428 | static_assert(offsetof(SOP_TextureInfo, numTextures) == 0, "Incorrect Alignment"); 1429 | static_assert(offsetof(SOP_TextureInfo, attribSet) == 4, "Incorrect Alignment"); 1430 | static_assert(offsetof(SOP_TextureInfo, textures) == 8, "Incorrect Alignment"); 1431 | static_assert(offsetof(SOP_TextureInfo, numTextureLayers) == 16, "Incorrect Alignment"); 1432 | static_assert(sizeof(SOP_TextureInfo) == 24, "Incorrect Size"); 1433 | 1434 | static_assert(offsetof(SOP_CustomAttribData, name) == 0, "Incorrect Alignment"); 1435 | static_assert(offsetof(SOP_CustomAttribData, numComponents) == 8, "Incorrect Alignment"); 1436 | static_assert(offsetof(SOP_CustomAttribData, attribType) == 12, "Incorrect Alignment"); 1437 | static_assert(offsetof(SOP_CustomAttribData, floatData) == 16, "Incorrect Alignment"); 1438 | static_assert(offsetof(SOP_CustomAttribData, intData) == 24, "Incorrect Alignment"); 1439 | static_assert(sizeof(SOP_CustomAttribData) == 32, "Incorrect Size"); 1440 | 1441 | static_assert(offsetof(SOP_PrimitiveInfo, numVertices) == 0, "Incorrect Alignment"); 1442 | static_assert(offsetof(SOP_PrimitiveInfo, pointIndices) == 8, "Incorrect Alignment"); 1443 | static_assert(offsetof(SOP_PrimitiveInfo, type) == 16, "Incorrect Alignment"); 1444 | static_assert(offsetof(SOP_PrimitiveInfo, pointIndicesOffset) == 20, "Incorrect Alignment"); 1445 | static_assert(sizeof(SOP_PrimitiveInfo) == 24, "Incorrect Size"); 1446 | 1447 | static_assert(sizeof(OP_SOPInput) == 440, "Incorrect Size"); 1448 | 1449 | static_assert(offsetof(OP_TOPInputDownloadOptions, downloadType) == 0, "Incorrect Alignment"); 1450 | static_assert(offsetof(OP_TOPInputDownloadOptions, verticalFlip) == 4, "Incorrect Alignment"); 1451 | static_assert(offsetof(OP_TOPInputDownloadOptions, cpuMemPixelType) == 8, "Incorrect Alignment"); 1452 | static_assert(sizeof(OP_TOPInputDownloadOptions) == 12, "Incorrect Size"); 1453 | 1454 | static_assert(offsetof(OP_InfoCHOPChan, name) == 0, "Incorrect Alignment"); 1455 | static_assert(offsetof(OP_InfoCHOPChan, value) == 8, "Incorrect Alignment"); 1456 | static_assert(sizeof(OP_InfoCHOPChan) == 56, "Incorrect Size"); 1457 | 1458 | static_assert(offsetof(OP_InfoDATSize, rows) == 0, "Incorrect Alignment"); 1459 | static_assert(offsetof(OP_InfoDATSize, cols) == 4, "Incorrect Alignment"); 1460 | static_assert(offsetof(OP_InfoDATSize, byColumn) == 8, "Incorrect Alignment"); 1461 | static_assert(sizeof(OP_InfoDATSize) == 52, "Incorrect Size"); 1462 | 1463 | static_assert(offsetof(OP_InfoDATEntries, values) == 0, "Incorrect Alignment"); 1464 | static_assert(sizeof(OP_InfoDATEntries) == 48, "Incorrect Size"); 1465 | 1466 | static_assert(offsetof(OP_NumericParameter, name) == 0, "Incorrect Alignment"); 1467 | static_assert(offsetof(OP_NumericParameter, label) == 8, "Incorrect Alignment"); 1468 | static_assert(offsetof(OP_NumericParameter, page) == 16, "Incorrect Alignment"); 1469 | static_assert(offsetof(OP_NumericParameter, defaultValues) == 24, "Incorrect Alignment"); 1470 | static_assert(offsetof(OP_NumericParameter, minValues) == 56, "Incorrect Alignment"); 1471 | static_assert(offsetof(OP_NumericParameter, maxValues) == 88, "Incorrect Alignment"); 1472 | static_assert(offsetof(OP_NumericParameter, clampMins) == 120, "Incorrect Alignment"); 1473 | static_assert(offsetof(OP_NumericParameter, clampMaxes) == 124, "Incorrect Alignment"); 1474 | static_assert(offsetof(OP_NumericParameter, minSliders) == 128, "Incorrect Alignment"); 1475 | static_assert(offsetof(OP_NumericParameter, maxSliders) == 160, "Incorrect Alignment"); 1476 | static_assert(sizeof(OP_NumericParameter) == 272, "Incorrect Size"); 1477 | 1478 | static_assert(offsetof(OP_StringParameter, name) == 0, "Incorrect Alignment"); 1479 | static_assert(offsetof(OP_StringParameter, label) == 8, "Incorrect Alignment"); 1480 | static_assert(offsetof(OP_StringParameter, page) == 16, "Incorrect Alignment"); 1481 | static_assert(offsetof(OP_StringParameter, defaultValue) == 24, "Incorrect Alignment"); 1482 | static_assert(sizeof(OP_StringParameter) == 112, "Incorrect Size"); 1483 | static_assert(sizeof(OP_TimeInfo) == 216, "Incorrect Size"); 1484 | #endif 1485 | -------------------------------------------------------------------------------- /CPlusPlus/GL_Extensions.h: -------------------------------------------------------------------------------- 1 | // Stub file for simpler CHOP usage than an OpenGLTOP 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /CPlusPlus/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | NSHumanReadableCopyright 22 | Copyright © 2020 Prim8 Technology Consulting, LLC. All rights reserved. 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CPlusPlus/LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /CPlusPlus/Laser OS CHOP.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Laser OS CHOP", "Laser OS CHOP.vcxproj", "{1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | MinSizeRel|x64 = MinSizeRel|x64 13 | MinSizeRel|x86 = MinSizeRel|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | RelWithDebInfo|x64 = RelWithDebInfo|x64 17 | RelWithDebInfo|x86 = RelWithDebInfo|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Debug|x64.ActiveCfg = Debug|x64 21 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Debug|x64.Build.0 = Debug|x64 22 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Debug|x86.ActiveCfg = Debug|x64 23 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Debug|x86.Build.0 = Debug|x64 24 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.MinSizeRel|x64.ActiveCfg = Release|x64 25 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.MinSizeRel|x64.Build.0 = Release|x64 26 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.MinSizeRel|x86.ActiveCfg = Release|Win32 27 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.MinSizeRel|x86.Build.0 = Release|Win32 28 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Release|x64.ActiveCfg = Release|x64 29 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Release|x64.Build.0 = Release|x64 30 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Release|x86.ActiveCfg = Release|Win32 31 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.Release|x86.Build.0 = Release|Win32 32 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.RelWithDebInfo|x64.ActiveCfg = Release|x64 33 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.RelWithDebInfo|x64.Build.0 = Release|x64 34 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 35 | {1CCC3208-53BC-4E6B-A8F5-A4BFD159C197}.RelWithDebInfo|x86.Build.0 = Release|Win32 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {39304A1C-3277-49C5-B69C-5F812B5E74B4} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /CPlusPlus/Laser OS CHOP.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {1ccc3208-53bc-4e6b-a8f5-a4bfd159c197} 25 | LaserOSCHOP 26 | 10.0 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v142 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v142 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v142 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v142 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;LASEROSCHOP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 90 | true 91 | Use 92 | pch.h 93 | D:\Code\laserdocklib\lib\include;D:\Code\laserdocklib;%(AdditionalIncludeDirectories) 94 | 1Byte 95 | 96 | 97 | Windows 98 | true 99 | false 100 | 101 | 102 | 103 | 104 | Level3 105 | true 106 | true 107 | true 108 | WIN32;NDEBUG;LASEROSCHOP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 109 | true 110 | Use 111 | pch.h 112 | D:\Code\laserdocklib\lib\include;D:\Code\laserdocklib;%(AdditionalIncludeDirectories) 113 | 1Byte 114 | 115 | 116 | Windows 117 | true 118 | true 119 | true 120 | false 121 | 122 | 123 | 124 | 125 | Level3 126 | true 127 | _DEBUG;LASEROSCHOP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 128 | true 129 | Use 130 | pch.h 131 | D:\Code\laserdocklib\lib\include;D:\Code\laserdocklib;%(AdditionalIncludeDirectories) 132 | 133 | 134 | Windows 135 | true 136 | false 137 | lib/laserdocklib.lib;%(AdditionalDependencies) 138 | 139 | 140 | 141 | 142 | Level3 143 | true 144 | true 145 | true 146 | NDEBUG;LASEROSCHOP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 147 | true 148 | Use 149 | pch.h 150 | D:\Code\laserdocklib\lib\include;D:\Code\laserdocklib;%(AdditionalIncludeDirectories) 151 | 152 | 153 | Windows 154 | true 155 | true 156 | true 157 | false 158 | lib/laserdocklib.lib;%(AdditionalDependencies) 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | Create 179 | Create 180 | Create 181 | Create 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /CPlusPlus/Laser OS CHOP.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | -------------------------------------------------------------------------------- /CPlusPlus/Laser_OS_CHOP.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 - LaserDock Limited 3 | * Written by Tim Greiser - Prim8 Technology Consulting, LLC 4 | * Contains related libraries from Derivative Inc. & Laser Dock Limited 5 | */ 6 | #include "Laser_OS_CHOP.h" 7 | 8 | #include "pch.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | typedef bool (LaserdockDevice::* ReadMethodPtr)(uint32_t*); 17 | 18 | LaserdockSample* samples; 19 | uint16_t _max; 20 | 21 | void print_string(string str) { 22 | 23 | std::cout << str << endl; 24 | 25 | } 26 | 27 | void print_uint32(string name, LaserdockDevice* d, ReadMethodPtr method) { 28 | 29 | uint32_t n = 0; 30 | bool pass = (d->*method)(&n); 31 | if (!pass) { 32 | print_string("Failed to read " + name); 33 | return; 34 | } 35 | std::cout << name << ": " << n << endl; 36 | 37 | } 38 | 39 | Laser_OS_CHOP::Laser_OS_CHOP(const OP_NodeInfo* info, uint16_t maxSamples) { 40 | } 41 | 42 | Laser_OS_CHOP::~Laser_OS_CHOP() { 43 | print_string("Shutting down"); 44 | } 45 | 46 | void 47 | Laser_OS_CHOP::connect(int id, double pointRate) { 48 | std::cout << "connected " << id << endl; 49 | std::vector > devices = LaserdockDeviceManager::getInstance().get_laserdock_devices(); 50 | if (devices.size() > id) { 51 | device = devices[id].release(); 52 | } 53 | if (!device) { 54 | std::cout << "Device not found!"; 55 | } 56 | else { 57 | std::cout << "Initialized.\n"; 58 | } 59 | 60 | print_uint32("Firmware major version", device, &LaserdockDevice::version_major_number); 61 | print_uint32("Firmware minor version", device, &LaserdockDevice::version_minor_number); 62 | print_uint32("Max Dac Rate", device, &LaserdockDevice::max_dac_rate); 63 | print_uint32("Min Dac Value", device, &LaserdockDevice::min_dac_value); 64 | print_uint32("Max Dac Value", device, &LaserdockDevice::max_dac_value); 65 | device->set_dac_rate(pointRate); 66 | print_uint32("Current Dac Rate", device, &LaserdockDevice::dac_rate); 67 | 68 | bool isClearRingbuffer = device->clear_ringbuffer(); 69 | if (isClearRingbuffer) { 70 | print_string("Clearing ringbuffer"); 71 | } 72 | else { 73 | print_string("Clearing ringbuffer not ok"); 74 | } 75 | 76 | bool enabled = false; 77 | 78 | if (!device->enable_output()) { 79 | print_string("Failed enabling output state"); 80 | } 81 | 82 | if (!device->get_output(&enabled)) { 83 | print_string("Failed reading output state"); 84 | } 85 | else { 86 | if (!enabled) { 87 | print_string("Could not initialize device for output."); 88 | } 89 | } 90 | 91 | } 92 | 93 | void 94 | Laser_OS_CHOP::disconnect() { 95 | if (device) { 96 | device->disable_output(); 97 | bool isClearRingbuffer = device->clear_ringbuffer(); 98 | device = NULL; 99 | } 100 | } 101 | 102 | void 103 | Laser_OS_CHOP::getGeneralInfo(CHOP_GeneralInfo* ginfo, const OP_Inputs* inputs, void* reserved1) { 104 | ginfo->cookEveryFrame = true; 105 | ginfo->timeslice = false; 106 | ginfo->inputMatchIndex = 0; 107 | } 108 | 109 | bool 110 | Laser_OS_CHOP::getOutputInfo(CHOP_OutputInfo* info, const OP_Inputs* inputs, void* reserved1) { 111 | if (inputs->getNumInputs() > 0) { 112 | return false; 113 | } 114 | return true; 115 | } 116 | 117 | void 118 | Laser_OS_CHOP::getChannelName(int32_t index, OP_String* name, const OP_Inputs* inputs, void* reserved1) 119 | { 120 | // unless getOutputInfo sets up channels, this won't be called. 121 | name->setString("chan1"); 122 | } 123 | 124 | int32_t 125 | Laser_OS_CHOP::getNumInfoCHOPChans(void* reserved1) { 126 | return 0; 127 | } 128 | 129 | void 130 | Laser_OS_CHOP::getInfoCHOPChan(int32_t index, 131 | OP_InfoCHOPChan* chan, 132 | void* reserved1) { 133 | 134 | } 135 | bool 136 | Laser_OS_CHOP::getInfoDATSize(OP_InfoDATSize* infoSize, void* reserved1) 137 | { 138 | infoSize->rows = 2; 139 | infoSize->cols = 2; 140 | infoSize->byColumn = false; 141 | return true; 142 | } 143 | 144 | void 145 | Laser_OS_CHOP::getInfoDATEntries(int32_t index, 146 | int32_t nEntries, 147 | OP_InfoDATEntries* entries, 148 | void* reserved1) 149 | { 150 | 151 | char tempBuffer[4096]; 152 | 153 | if (index == 0) 154 | { 155 | // Set the value for the first column 156 | entries->values[0]->setString("executeCount"); 157 | 158 | // Set the value for the second column 159 | #ifdef _WIN32 160 | sprintf_s(tempBuffer, "%d", myExecuteCount); 161 | #else // macOS 162 | snprintf(tempBuffer, sizeof(tempBuffer), "%d", myExecuteCount); 163 | #endif 164 | entries->values[1]->setString(tempBuffer); 165 | } 166 | 167 | } 168 | 169 | void 170 | Laser_OS_CHOP::setupParameters(OP_ParameterManager* manager, void* reserved1) 171 | { 172 | // enable 173 | { 174 | OP_NumericParameter np; 175 | 176 | np.name = "Enable"; 177 | np.label = "Enable Laser Output"; 178 | 179 | OP_ParAppendResult res = manager->appendToggle(np); 180 | assert(res == OP_ParAppendResult::Success); 181 | } 182 | // device 183 | { 184 | print_string("get_devices"); 185 | std::vector > devices = LaserdockDeviceManager::getInstance().get_laserdock_devices(); 186 | OP_StringParameter sp; 187 | 188 | sp.name = "Device"; 189 | sp.label = "Device"; 190 | 191 | size_t numDevices = devices.size(); 192 | std::vector names; 193 | std::vector labels; 194 | 195 | std::vector names_strs; 196 | std::vector labels_strs; 197 | 198 | names_strs.push_back("None"); 199 | labels_strs.push_back(""); 200 | 201 | int iX = 1; 202 | for (const std::unique_ptr& device : devices) { 203 | int dsize = 64; 204 | char* d = (char*) malloc(sizeof(char) * dsize); 205 | int dc = device->sdescription(d, dsize); 206 | printf("%s\n", d); 207 | int nsize = 16; 208 | char* name = (char*) malloc(sizeof(char) * nsize); 209 | sprintf_s(name, nsize, "Wicked%d", iX); 210 | names_strs.push_back(name); 211 | labels_strs.push_back(d); 212 | free(d); 213 | } 214 | 215 | // Convert to a vector of c-style strings 216 | for (const auto& string : names_strs) names.push_back(string.c_str()); 217 | for (const auto& string : labels_strs) labels.push_back(string.c_str()); 218 | 219 | sp.defaultValue = names[0]; 220 | OP_ParAppendResult res = manager->appendMenu(sp, names.size(), names.data(), labels.data()); 221 | assert(res == OP_ParAppendResult::Success); 222 | } 223 | // scaleX 224 | { 225 | OP_NumericParameter np; 226 | 227 | np.name = "Scalex"; 228 | np.label = "Scale X"; 229 | np.defaultValues[0] = 0.5; 230 | np.minSliders[0] = -0.0; 231 | np.maxSliders[0] = 2.0; 232 | 233 | OP_ParAppendResult res = manager->appendFloat(np); 234 | assert(res == OP_ParAppendResult::Success); 235 | } 236 | // scaleY 237 | { 238 | OP_NumericParameter np; 239 | 240 | np.name = "Scaley"; 241 | np.label = "Scale Y"; 242 | np.defaultValues[0] = 0.5; 243 | np.minSliders[0] = -0.0; 244 | np.maxSliders[0] = 2.0; 245 | 246 | OP_ParAppendResult res = manager->appendFloat(np); 247 | assert(res == OP_ParAppendResult::Success); 248 | } 249 | // red 250 | { 251 | OP_NumericParameter np; 252 | 253 | np.name = "Red"; 254 | np.label = "Red Level"; 255 | np.defaultValues[0] = 1.0; 256 | np.minSliders[0] = 0.0; 257 | np.maxSliders[0] = 1.0; 258 | 259 | OP_ParAppendResult res = manager->appendFloat(np); 260 | assert(res == OP_ParAppendResult::Success); 261 | } 262 | // green 263 | { 264 | OP_NumericParameter np; 265 | 266 | np.name = "Green"; 267 | np.label = "Green Level"; 268 | np.defaultValues[0] = 1.0; 269 | np.minSliders[0] = 0.0; 270 | np.maxSliders[0] = 1.0; 271 | 272 | OP_ParAppendResult res = manager->appendFloat(np); 273 | assert(res == OP_ParAppendResult::Success); 274 | } 275 | // blue 276 | { 277 | OP_NumericParameter np; 278 | 279 | np.name = "Blue"; 280 | np.label = "Blue Level"; 281 | np.defaultValues[0] = 1.0; 282 | np.minSliders[0] = 0.0; 283 | np.maxSliders[0] = 1.0; 284 | 285 | OP_ParAppendResult res = manager->appendFloat(np); 286 | assert(res == OP_ParAppendResult::Success); 287 | } 288 | // intensity 289 | { 290 | OP_NumericParameter np; 291 | 292 | np.name = "Intensity"; 293 | np.label = "Intensity"; 294 | np.defaultValues[0] = 1.0; 295 | np.minSliders[0] = 0.0; 296 | np.maxSliders[0] = 1.0; 297 | 298 | OP_ParAppendResult res = manager->appendFloat(np); 299 | assert(res == OP_ParAppendResult::Success); 300 | } 301 | 302 | print_string("setupParameters"); 303 | } 304 | 305 | int connectedDev = 0; 306 | void Laser_OS_CHOP::execute(CHOP_Output* output, const OP_Inputs* inputs, void* reserved) { 307 | bool enabled = inputs->getParInt("Enable"); 308 | int dev = inputs->getParInt("Device"); 309 | if (dev != connectedDev) { 310 | device = NULL; 311 | } 312 | if (dev > 0 && inputs->getNumInputs() > 0 && enabled) { 313 | 314 | const OP_CHOPInput* in = inputs->getInputCHOP(0); 315 | if (device == NULL) { 316 | print_string("Initializing"); 317 | 318 | samples = (LaserdockSample*)calloc(sizeof(LaserdockSample), in->numSamples); 319 | _max = in->numSamples; 320 | std::cout << "Initializing - max samples " << _max << endl; 321 | 322 | print_string("enabled"); 323 | connect(dev - 1, in->sampleRate); 324 | connectedDev = dev; 325 | } 326 | //print_uint32("Ring count", device, &LaserdockDevice::ringbuffer_sample_count); 327 | //print_uint32("Ring empty count", device, &LaserdockDevice::ringbuffer_empty_sample_count); 328 | double scalex = inputs->getParDouble("Scalex"); 329 | double scaley = inputs->getParDouble("Scaley"); 330 | double intensity = inputs->getParDouble("Intensity"); 331 | 332 | CHOP_Buffer* cbuffer = new CHOP_Buffer(_max); 333 | cbuffer->fillSamples(in, output, samples, scalex, scaley, inputs->getParDouble("Red") * intensity, inputs->getParDouble("Green") * intensity, 334 | inputs->getParDouble("Blue") * intensity); 335 | device->send_samples(samples, _max); 336 | } else if (!enabled) { 337 | disconnect(); 338 | } 339 | } 340 | 341 | -------------------------------------------------------------------------------- /CPlusPlus/Laser_OS_CHOP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | #include 5 | 6 | class Laser_OS_CHOP : public CHOP_CPlusPlusBase 7 | { 8 | public: 9 | Laser_OS_CHOP(const OP_NodeInfo* info, uint16_t maxSamples); 10 | virtual ~Laser_OS_CHOP(); 11 | 12 | void connect(int id, double pointRate); 13 | void disconnect(); 14 | 15 | virtual void getGeneralInfo(CHOP_GeneralInfo*, const OP_Inputs*, void*) override; 16 | virtual bool getOutputInfo(CHOP_OutputInfo*, const OP_Inputs*, void*) override; 17 | virtual void getChannelName(int32_t index, OP_String* name, const OP_Inputs*, void* reserved) override; 18 | 19 | virtual void execute(CHOP_Output*, 20 | const OP_Inputs*, 21 | void* reserved) override; 22 | 23 | 24 | virtual int32_t getNumInfoCHOPChans(void* reserved1) override; 25 | virtual void getInfoCHOPChan(int index, 26 | OP_InfoCHOPChan* chan, 27 | void* reserved1) override; 28 | 29 | virtual bool getInfoDATSize(OP_InfoDATSize* infoSize, void* resereved1) override; 30 | virtual void getInfoDATEntries(int32_t index, 31 | int32_t nEntries, 32 | OP_InfoDATEntries* entries, 33 | void* reserved1) override; 34 | 35 | virtual void setupParameters(OP_ParameterManager* manager, void* reserved1) override; 36 | 37 | private: 38 | 39 | const OP_NodeInfo* myNodeInfo; 40 | 41 | int myExecuteCount; 42 | 43 | // This is the DAC we are connecting to 44 | LaserdockDevice* device; 45 | 46 | }; -------------------------------------------------------------------------------- /CPlusPlus/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 - LaserDock Limited 3 | * Written by Tim Greiser - Prim8 Technology Consulting, LLC 4 | * Contains related libraries from Derivative Inc. & Laser Dock Limited 5 | */ 6 | #include "pch.h" 7 | 8 | using namespace std; 9 | 10 | typedef bool (LaserdockDevice::* ReadMethodPtr)(uint32_t*); 11 | 12 | extern "C" { 13 | 14 | DLLEXPORT 15 | void FillCHOPPluginInfo(CHOP_PluginInfo* info) { 16 | info->apiVersion = CHOPCPlusPlusAPIVersion; 17 | info->customOPInfo.opType->setString("Laseros"); 18 | info->customOPInfo.opLabel->setString("Laser OS"); 19 | info->customOPInfo.authorName->setString("Tim Greiser"); 20 | info->customOPInfo.authorEmail->setString("tim@prim8.net"); 21 | info->customOPInfo.minInputs = 0; 22 | info->customOPInfo.maxInputs = 1; 23 | } 24 | 25 | DLLEXPORT 26 | // Initialize the CHOP. 27 | CHOP_CPlusPlusBase* CreateCHOPInstance(const OP_NodeInfo* info) { 28 | // calculate number of samples 29 | uint16_t maxSamples = 500; 30 | return new Laser_OS_CHOP(info, maxSamples); 31 | } 32 | 33 | DLLEXPORT 34 | void DestroyCHOPInstance(CHOP_CPlusPlusBase* instance) { 35 | delete (Laser_OS_CHOP*)instance; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /CPlusPlus/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 4 | // Windows Header Files 5 | #include 6 | -------------------------------------------------------------------------------- /CPlusPlus/lib/include/laserdocklib/LaserdockDevice.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Guoping Huang on 8/8/16. 3 | // 4 | 5 | #ifndef LASERDOCKLIB_LASERDOCKDEVICE_H 6 | #define LASERDOCKLIB_LASERDOCKDEVICE_H 7 | 8 | #include 9 | 10 | #include 11 | 12 | uint16_t LASERDOCKLIB_EXPORT float_to_laserdock_xy(float var); 13 | uint16_t LASERDOCKLIB_EXPORT laserdock_sample_flip(uint16_t); 14 | 15 | #ifdef ANDROID 16 | class _jobject; 17 | typedef _jobject* jobject; 18 | #endif 19 | 20 | struct libusb_device; 21 | class LaserdockDevicePrivate; 22 | struct LaserdockSample; 23 | 24 | class LASERDOCKLIB_EXPORT LaserdockDevice { 25 | 26 | public: 27 | 28 | enum Status { UNKNOWN, INITIALIZED }; 29 | 30 | explicit LaserdockDevice(libusb_device *usbdevice); 31 | #ifdef ANDROID 32 | explicit LaserdockDevice(libusb_device *usbdevice, jobject obj); 33 | #endif 34 | virtual ~LaserdockDevice(); 35 | 36 | Status status() const; 37 | 38 | bool enable_output(); 39 | bool disable_output(); 40 | bool get_output(bool * enabled); 41 | 42 | bool dac_rate(uint32_t *rate); 43 | bool set_dac_rate(uint32_t rate); 44 | bool max_dac_rate(uint32_t *rate); 45 | bool min_dac_value(uint32_t *value); 46 | bool max_dac_value(uint32_t *value); 47 | 48 | bool sample_element_count(uint32_t *count); 49 | bool iso_packet_sample_count(uint32_t *count); 50 | bool bulk_packet_sample_count(uint32_t *count); 51 | 52 | bool version_major_number(uint32_t *major); 53 | bool version_minor_number(uint32_t *minor); 54 | 55 | bool clear_ringbuffer(); 56 | bool ringbuffer_sample_count(uint32_t *count); 57 | bool ringbuffer_empty_sample_count(uint32_t *count); 58 | 59 | bool runner_mode_enable(bool); 60 | bool runner_mode_run(bool); 61 | bool runner_mode_load(LaserdockSample *samples, uint16_t position, uint16_t count); 62 | 63 | bool send(unsigned char * data, uint32_t length); 64 | bool send_samples(LaserdockSample * samples, uint32_t count); 65 | 66 | bool flixpX(); 67 | bool flixpY(); 68 | 69 | void setFlipX(bool); 70 | void setFlipY(bool); 71 | 72 | bool usb_send(unsigned char *data, int length); 73 | unsigned char *usb_get(unsigned char * data, int length); 74 | 75 | void print() const; 76 | int sdescription(char* buff, int bufferSize); 77 | 78 | private: 79 | std::unique_ptr d; 80 | }; 81 | 82 | #endif //LASERDOCKLIB_LASERDOCKDEVICE_H 83 | -------------------------------------------------------------------------------- /CPlusPlus/lib/include/laserdocklib/LaserdockDeviceManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Guoping Huang on 9/6/16. 3 | // 4 | 5 | #ifndef LASERDOCKLIB_LASERDOCKDEVICEMANAGER_H 6 | #define LASERDOCKLIB_LASERDOCKDEVICEMANAGER_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | class LaserdockDevice; 14 | class LaserdockDeviceManagerPrivate; 15 | 16 | class LASERDOCKLIB_EXPORT LaserdockDeviceManager 17 | { 18 | public: 19 | static LaserdockDeviceManager& getInstance(); 20 | 21 | std::vector > get_laserdock_devices(); 22 | 23 | // helper methods 24 | void print_laserdock_devices(); 25 | LaserdockDevice *get_next_available_device(); 26 | 27 | private: 28 | explicit LaserdockDeviceManager(); 29 | virtual ~LaserdockDeviceManager(); 30 | 31 | private: 32 | std::unique_ptr d; 33 | }; 34 | 35 | #endif //LASERDOCKLIB_LASERDOCKDEVICEMANAGER_H 36 | -------------------------------------------------------------------------------- /CPlusPlus/lib/include/laserdocklib/LaserdockSample.h: -------------------------------------------------------------------------------- 1 | #ifndef LASERDOCKLIB_LASERDOCKSAMPLE_H 2 | #define LASERDOCKLIB_LASERDOCKSAMPLE_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | struct LASERDOCKLIB_EXPORT LaserdockSample 9 | { 10 | uint16_t rg; //lower byte is red, top byte is green 11 | uint16_t b; //lower byte is blue 12 | uint16_t x; // 0..4095 13 | uint16_t y; // 0..4095 14 | }; 15 | 16 | #endif //LASERDOCKLIB_LASERDOCKSAMPLE_H 17 | -------------------------------------------------------------------------------- /CPlusPlus/lib/include/laserdocklib/Laserdocklib.h: -------------------------------------------------------------------------------- 1 | #ifndef LASERDOCKLIB_LASERDOCKLIB_H 2 | #define LASERDOCKLIB_LASERDOCKLIB_H 3 | 4 | #ifdef _WIN32 5 | #define LASERDOCKLIB_EXPORT __declspec(dllexport) 6 | #else 7 | #define LASERDOCKLIB_EXPORT 8 | #endif 9 | 10 | #endif //LASERDOCKLIB_LASERDOCKLIB_H 11 | -------------------------------------------------------------------------------- /CPlusPlus/lib/laserdocklib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wickedlasers/Laser_OS_TouchDesigner/fb66f1a34397877ace28f210ee1f9405f1e4ecde/CPlusPlus/lib/laserdocklib.dll -------------------------------------------------------------------------------- /CPlusPlus/lib/laserdocklib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wickedlasers/Laser_OS_TouchDesigner/fb66f1a34397877ace28f210ee1f9405f1e4ecde/CPlusPlus/lib/laserdocklib.lib -------------------------------------------------------------------------------- /CPlusPlus/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /CPlusPlus/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | 12 | #include 13 | #include 14 | 15 | #include "CHOP_CPlusPlusBase.h" 16 | #include "CHOP_Buffer.h" 17 | #include "Laser_OS_CHOP.h" 18 | 19 | #endif //PCH_H 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laser OS TouchDesigner 2 | 3 | [TouchDesigner](https://derivative.ca/) is a node based programming environment for creative coding. This plugin provides driver support for LaserCube and LaserDock within TouchDesigner. 4 | 5 | Currently Supported: Windows 64 bit 6 | 7 | ## Intro to TouchDesigner 8 | 9 | TouchDesigner is a patch-based environment for creative coding. It has a unique workflow where you can visualize the signal at each step along the signal path. I would suggest getting aquainted with the basics of the environment before you try controlling lasers. Laser programming will primarily use the CHOP domain along with possibly SOP or TOP. 10 | 11 | I recommend these two tutorials from Programming for People to start out. 12 | - https://www.youtube.com/watch?v=SgA2BhF4w4o 13 | - https://www.youtube.com/watch?v=E4ZUzJK2ZQ4 14 | 15 | ## Prerequisites 16 | 17 | 1) Download and install **[TouchDesigner](https://derivative.ca/download)**. 18 | 2) You need a LaserDock and ILDA laser, or a LaserCube - along with all appropriate cabling. 19 | 3) Be careful with your laser. You should know the procedures and equipment needed for safe operation. 20 | 21 | ## Get Started 22 | 23 | 1) Download the latest zip file from the **[releases page](https://github.com/Wickedlasers/Laser_OS_TouchDesigner/releases/)** 24 | 2) Unzip, and inside the folder, run the file Laser_OS_Test.toe 25 | 3) When TouchDesigner starts, you will see a security notice about loading the Laser OS CHOP plugin. Click 'OK' in order to load the plugin. 26 | 4) If you look around you will see the network that creates a circle inside a triangle, and causes the scene to rotate, and then output to the laser. In the lower right, look for the Laseros1 Operator and select it. You should see the properties window in the upper right, press P on the keyboard if you don't see it. Select your Laser OS device and use the toggle to Enable Laser Output when it is safe to do so. 27 | 28 | ![Enable Laser Output](http://prim8.net/files/Wickedlasers/enable_output.png) 29 | 30 | ## Installing the Plugin 31 | 32 | You can run a TouchDesigner .toe file from the same location as the Laser OS **Plugins** directory, or you can install your plugins to use in all TouchDesigner projects on your computer. 33 | 34 | To install on your system, copy the contents of **Plugins** into: 35 | 36 | - Windows - Documents\Derivative\Plugins, usually C:\Users\\Documents\Derivative\Plugins 37 | 38 | For more information, please see: 39 | 40 | ## Using the Plugin 41 | 42 | Once the plugin is installed and approved to load, it will appear in the **OP Create Dialog** under the **Custom** tab. 43 | 44 | ![OP Create Dialog](http://prim8.net/files/Wickedlasers/op_create.png) 45 | 46 | This operator expects one CHOP as an input, and that CHOP should have 5 channels. The names are not important, but they must be in the order: **X, Y, Red, Green Blue**. The sample rate of your channels should match the laser point rate you wish to send. 47 | 48 | Range of valid inputs are: 49 | - X / Y: -1 to +1 50 | - Red / Green / Blue: 0 to +1 51 | 52 | You need a fairly fast computer to get good performance. If the laser is flickering when running TD in the editor, try switching to Perform mode to optimize performance. 53 | 54 | **NOTE** there is a bug effecting Perform mode in some versions of TouchDesigner. If your laser does not output in Perform mode you can attach a Null CHOP to the output of Laseros1 and mark it as Cook Type: Always. More details about the bug are available on the [TD forum](https://forum.derivative.ca/t/fixed-c-cookeveryframe-and-perform-mode/141521). 55 | 56 | ![Perform mode workaround](http://prim8.net/files/Wickedlasers/cook_always.png) 57 | 58 | ## Learning Resources 59 | 60 | There are many examples of different techniques available from . Any of these examples will be able to run on Laser OS with a minimal change. Add the Laser OS CHOP next to the ether_dream_controls, and wire it up from the same source. With this method, most examples for Ether-Dream or Helios DACs can be made compatible. 61 | 62 | ![Example](http://prim8.net/files/Wickedlasers/example.png) 63 | -------------------------------------------------------------------------------- /TouchDesigner/.gitignore: -------------------------------------------------------------------------------- 1 | Backup/ 2 | Plugins/Plugins.json 3 | Laser_OS_Test.*.toe 4 | -------------------------------------------------------------------------------- /TouchDesigner/Laser_OS_Test.toe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wickedlasers/Laser_OS_TouchDesigner/fb66f1a34397877ace28f210ee1f9405f1e4ecde/TouchDesigner/Laser_OS_Test.toe -------------------------------------------------------------------------------- /TouchDesigner/Plugins/Laser OS v0.0.3/Laser OS CHOP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wickedlasers/Laser_OS_TouchDesigner/fb66f1a34397877ace28f210ee1f9405f1e4ecde/TouchDesigner/Plugins/Laser OS v0.0.3/Laser OS CHOP.dll -------------------------------------------------------------------------------- /TouchDesigner/Plugins/Laser OS v0.0.3/laserdocklib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wickedlasers/Laser_OS_TouchDesigner/fb66f1a34397877ace28f210ee1f9405f1e4ecde/TouchDesigner/Plugins/Laser OS v0.0.3/laserdocklib.dll --------------------------------------------------------------------------------