From ace0b2cd8e2f85f048659e094029e57ec7ffa4cf Mon Sep 17 00:00:00 2001 From: medcelerate Date: Sat, 7 Sep 2024 13:19:03 -0400 Subject: [PATCH] Added example Tox for vectors Added support for vectors --- Example/InputOutput5ParamVector.tox | Bin 0 -> 1438 bytes FFGLTouchEngine/src/TouchEngine.cpp | 94 +++++++++++++++++++++--- FFGLTouchEngine/src/TouchEngine.h | 9 +++ FFGLTouchEngineFX/src/TouchEngineFX.cpp | 80 ++++++++++++++++++++ FFGLTouchEngineFX/src/TouchEngineFX.h | 12 +++ 5 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 Example/InputOutput5ParamVector.tox diff --git a/Example/InputOutput5ParamVector.tox b/Example/InputOutput5ParamVector.tox new file mode 100644 index 0000000000000000000000000000000000000000..98c6fe0cf130a7feb765c70a743795d213ff9a08 GIT binary patch literal 1438 zcmV;P1!4LC0003oFaQ7rkN^M@EMxT6Qv<{qmNxC1*70j6uaOW4+aX?x;`47C-w+{+ zbKx8!l{iw)BiS2?7Rf?aOO^4jn`qw|P>>lP#=sJ^ws;?#EsVs{O@oHIzENAA2Z31XFX`R48U0 z7D%j>gSC9Ir6-{eKxsmB4%t!`-Dw~cOIqJIvr53-M5w zJ!$(QEIWOgHsf9ingOGE3Mq#&Kz3Nu)Fc@kT}tVO`wu@XnuU&f`Q`*5*!A6-sk$yD zPB)OHZQ`@+OPXSgVNq0yZFnB_(2AN4y+w%FphTdSh z(D9vZt|sOLu#uvrhR^Qd_FuaBj)0A~6bHL&BP-lZUh?{Wh`Sd@3IGb-`E zH^%Fw<bm z2qY}7PlYqRzg{Hsw_8u89ybGs1Pgp05SS%T>HHLQ@S`C?E&Ni)So{4(&1qYFkUiM7 zGc0s=>=Gq0v3S{I3%EhoSumTV*SWUbe*Z*UU{re0q8{74C`i&%hAvj*^`^8<(^}hg zV2u@TS+}*ED_sFw=os?pN>DB5KxWyu|H|4JB*|y<=#N_S_epku|3YI zKLAh?a*tZU>@QE<7-icIjlBnf9xmf>Jc^qi#FZRRFPttcC8cNh*EtD~XFwr}BDNs? ztmQfAAR)}H^_yBtN3@TQIIQV#aK4eK-UZ6ssIy{vZke{B@wW1yZ~mdIn}iI|?Ro!4 zlO1+=PusUIqFmOe-&|yGN3hQY!r*+r?X;x8zeOVJPL29*RPDj}usxfp4wxbH?3^Of z^CxjU$(E3BPD|eslY5!_*p3@$)2)pi5;>F-tD0#S*Ni%@TdA2nM$u@kAAE?|jV6`TTDX(value); return FF_SUCCESS; @@ -488,6 +500,11 @@ FFResult FFGLTouchEngine::SetFloatParameter(unsigned int dwIndex, float value) { return FF_SUCCESS; } + if (type == FF_TYPE_OPTION) { + ParameterMapInt[dwIndex] = static_cast(value); + return FF_SUCCESS; + } + ParameterMapFloat[dwIndex] = value; @@ -706,6 +723,8 @@ void FFGLTouchEngine::ConstructBaseParameters() { SetOptionParamInfo(i, (std::string("Parameter") + std::to_string(i)).c_str(), 10, 0); SetParamVisibility(i, false, false); } + + return; } @@ -776,6 +795,63 @@ void FFGLTouchEngine::GetAllParameters() case TELinkTypeDouble: { if (linkInfo->intent == TELinkIntentColorRGBA || linkInfo->intent == TELinkIntentPositionXYZW || linkInfo->intent == TELinkIntentSizeWH) { + std::string Suffix; + switch (linkInfo->intent) { + case TELinkIntentColorRGBA: + Suffix = "RGBA"; + break; + case TELinkIntentPositionXYZW: + Suffix = "XYZW"; + break; + case TELinkIntentSizeWH: + Suffix = "WH"; + break; + } + + double value[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueCurrent, value, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + + double max[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueUIMaximum, max, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + double min[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueUIMinimum, min, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + + VectorParameterInfo info; + info.count = linkInfo->count; + info.identifier = linkInfo->identifier; + + + + for (uint32_t i = 0; i < linkInfo->count; i++) { + uint32_t ParamID = Parameters.size() + OffsetParamsByType; + Parameters.push_back(std::make_pair(std::string(linkInfo->identifier) + (char)0x03 + std::to_string(i), ParamID)); + ActiveParams.insert(ParamID); + ActiveVectorParams.insert(ParamID); + info.children[i] = ParamID; + + ParameterMapType[ParamID] = FF_TYPE_STANDARD; + + SetParamDisplayName(ParamID, linkInfo->label + std::string(".") + Suffix[i], true); + + SetParamRange(ParamID, min[i], max[i]); + RaiseParamEvent(ParamID, FF_EVENT_FLAG_VALUE); + SetParamVisibility(ParamID, true, true); + } + + VectorParameters.push_back(info); + continue; } uint32_t ParamID = Parameters.size() + OffsetParamsByType; diff --git a/FFGLTouchEngine/src/TouchEngine.h b/FFGLTouchEngine/src/TouchEngine.h index 9a15852..81c1eb8 100644 --- a/FFGLTouchEngine/src/TouchEngine.h +++ b/FFGLTouchEngine/src/TouchEngine.h @@ -16,6 +16,12 @@ #include "Thumbnail.h" +typedef struct { + std::string identifier; + uint8_t count; + FFUInt32 children[4]; +} VectorParameterInfo; + class FFGLTouchEngine : public CFFGLPlugin { public: @@ -74,6 +80,9 @@ class FFGLTouchEngine : public CFFGLPlugin std::unordered_map ParameterMapString; std::unordered_map ParameterMapBool; + std::set ActiveVectorParams; + std::vector VectorParameters; + //Texture Name std::string OutputOpName; diff --git a/FFGLTouchEngineFX/src/TouchEngineFX.cpp b/FFGLTouchEngineFX/src/TouchEngineFX.cpp index db4b31c..94929cd 100644 --- a/FFGLTouchEngineFX/src/TouchEngineFX.cpp +++ b/FFGLTouchEngineFX/src/TouchEngineFX.cpp @@ -255,6 +255,10 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL) for (auto& param : Parameters) { FFUInt32 type = ParameterMapType[param.second]; + if (ActiveVectorParams.find(param.second) != ActiveVectorParams.end()) { + continue; + } + if (type == FF_TYPE_STANDARD) { TEResult result = TEInstanceLinkSetDoubleValue(instance, param.first.c_str(), &ParameterMapFloat[param.second], 1); if (result != TEResultSuccess) @@ -292,8 +296,24 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL) } } + } + + for (auto& param : VectorParameters) { + double values[4] = { 0,0,0,0 }; + + for (uint8_t i = 0; i < param.count; i++) { + values[i] = ParameterMapFloat[param.children[i]]; + } + TEResult result = TEInstanceLinkSetDoubleValue(instance, param.identifier.c_str(), values, param.count); + if (result != TEResultSuccess) + { + isTouchFrameBusy = false; + return FailAndLog("Failed to set int value"); + } + } + TouchObject TETextureToReceive; if (hasVideoInput) { @@ -608,6 +628,7 @@ FFResult FFGLTouchEngineFX::SetFloatParameter(unsigned int dwIndex, float value) FFUInt32 type = ParameterMapType[dwIndex]; + if (type == FF_TYPE_INTEGER) { ParameterMapInt[dwIndex] = static_cast(value); return FF_SUCCESS; @@ -960,6 +981,8 @@ void FFGLTouchEngineFX::ResetBaseParameters() { hasVideoInput = false; hasVideoOutput = false; ActiveParams.clear(); + ActiveVectorParams.clear(); + VectorParameters.clear(); ParameterMapFloat.clear(); ParameterMapInt.clear(); ParameterMapString.clear(); @@ -1024,6 +1047,63 @@ void FFGLTouchEngineFX::GetAllParameters() case TELinkTypeDouble: { if (linkInfo->intent == TELinkIntentColorRGBA || linkInfo->intent == TELinkIntentPositionXYZW || linkInfo->intent == TELinkIntentSizeWH) { + std::string Suffix; + switch (linkInfo->intent) { + case TELinkIntentColorRGBA: + Suffix = "RGBA"; + break; + case TELinkIntentPositionXYZW: + Suffix = "XYZW"; + break; + case TELinkIntentSizeWH: + Suffix = "WH"; + break; + } + + double value[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueCurrent, value, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + + double max[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueUIMaximum, max, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + double min[4] = { 0, 0, 0, 0 }; + result = TEInstanceLinkGetDoubleValue(instance, linkInfo->identifier, TELinkValueUIMinimum, min, linkInfo->count); + if (result != TEResultSuccess) + { + continue; + } + + VectorParameterInfo info; + info.count = linkInfo->count; + info.identifier = linkInfo->identifier; + + + + for (uint32_t i = 0; i < linkInfo->count; i++) { + uint32_t ParamID = Parameters.size() + OffsetParamsByType; + Parameters.push_back(std::make_pair(std::string(linkInfo->identifier) + (char)0x03 + std::to_string(i), ParamID)); + ActiveParams.insert(ParamID); + ActiveVectorParams.insert(ParamID); + info.children[i] = ParamID; + + ParameterMapType[ParamID] = FF_TYPE_STANDARD; + + SetParamDisplayName(ParamID, linkInfo->label + std::string(".") + Suffix[i], true); + + SetParamRange(ParamID, min[i], max[i]); + RaiseParamEvent(ParamID, FF_EVENT_FLAG_VALUE); + SetParamVisibility(ParamID, true, true); + } + + VectorParameters.push_back(info); + continue; } uint32_t ParamID = Parameters.size() + OffsetParamsByType; diff --git a/FFGLTouchEngineFX/src/TouchEngineFX.h b/FFGLTouchEngineFX/src/TouchEngineFX.h index 6f5ca09..4ecd5e9 100644 --- a/FFGLTouchEngineFX/src/TouchEngineFX.h +++ b/FFGLTouchEngineFX/src/TouchEngineFX.h @@ -14,6 +14,11 @@ #include "SpoutGL/SpoutSender.h" #include "Thumbnail.h" +typedef struct { + std::string identifier; + uint8_t count; + FFUInt32 children[4]; +} VectorParameterInfo; class FFGLTouchEngineFX : public CFFGLPlugin { @@ -75,6 +80,13 @@ class FFGLTouchEngineFX : public CFFGLPlugin std::unordered_map ParameterMapFloat; std::unordered_map ParameterMapString; std::unordered_map ParameterMapBool; + + //First check if it is a vector parameter + + std::set ActiveVectorParams; + std::vector VectorParameters; + + //Texture Name std::string OutputOpName;