-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathParameters.cpp
More file actions
123 lines (102 loc) · 3.37 KB
/
Parameters.cpp
File metadata and controls
123 lines (102 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* Shared Use License: This file is owned by Derivative Inc. (Derivative)
* and can only be used, and/or modified for use, in conjunction with
* Derivative's TouchDesigner software, and only if you are a licensee who has
* accepted Derivative's TouchDesigner license or assignment agreement
* (which also govern the use of this file). You may share or redistribute
* a modified version of this file provided the following conditions are met:
*
* 1. The shared file or redistribution must retain the information set out
* above and this list of conditions.
* 2. Derivative's name (Derivative Inc.) or its trademarks may not be used
* to endorse or promote products derived from this file without specific
* prior written permission from Derivative.
*/
// Parameters.cpp generated using the cppParsTemplateGen Palette Component.
// https://derivative.ca/UserGuide/Palette:cppParsTemplateGen
#include <string>
#include <array>
#include "CPlusPlus_Common.h"
#include "Parameters.h"
#pragma region Evals
ShapeMenuItems
Parameters::evalShape(const TD::OP_Inputs* inputs)
{
return static_cast<ShapeMenuItems>(inputs->getParInt(ShapeName));
}
TD::Color
Parameters::evalColor(const TD::OP_Inputs* inputs)
{
std::array<double, 4> vals;
inputs->getParDouble4(ColorName, vals[0], vals[1], vals[2], vals[3]);
return TD::Color((float)vals[0], (float)vals[1], (float)vals[2], (float)vals[3]);
}
bool
Parameters::evalGpudirect(const TD::OP_Inputs* inputs)
{
return inputs->getParInt(GpudirectName) ? true : false;
}
#pragma endregion
#pragma region Setup
void
Parameters::setup(TD::OP_ParameterManager* manager)
{
{
TD::OP_StringParameter p;
p.name = ShapeName;
p.label = ShapeLabel;
p.page = "Generator";
p.defaultValue = "Cube";
std::array<const char*, 4> Names =
{
"Point",
"Line",
"Square",
"Cube"
};
std::array<const char*, 4> Labels =
{
"Point",
"Line",
"Square",
"Cube"
};
TD::OP_ParAppendResult res = manager->appendMenu(p, Names.size(), Names.data(), Labels.data());
assert(res == TD::OP_ParAppendResult::Success);
}
{
TD::OP_NumericParameter p;
p.name = ColorName;
p.label = ColorLabel;
p.page = "Generator";
const int ArraySize = 4;
const std::array<double, ArraySize> DefaultValues = { 1.0, 1.0, 1.0, 1.0 };
const std::array<double, ArraySize> MinSliders = { 0.0, 0.0, 0.0, 0.0 };
const std::array<double, ArraySize> MaxSliders = { 1.0, 1.0, 1.0, 1.0 };
const std::array<double, ArraySize> MinValues = { 0.0, 0.0, 0.0, 0.0 };
const std::array<double, ArraySize> MaxValues = { 1.0, 1.0, 1.0, 1.0 };
const std::array<bool, ArraySize> ClampMins = { false, false, false, false };
const std::array<bool, ArraySize> ClampMaxes = { false, false, false, false };
for (int i = 0; i < DefaultValues.size(); ++i)
{
p.defaultValues[i] = DefaultValues[i];
p.minSliders[i] = MinSliders[i];
p.maxSliders[i] = MaxSliders[i];
p.minValues[i] = MinValues[i];
p.maxValues[i] = MaxValues[i];
p.clampMins[i] = ClampMins[i];
p.clampMaxes[i] = ClampMaxes[i];
}
TD::OP_ParAppendResult res = manager->appendRGBA(p);
assert(res == TD::OP_ParAppendResult::Success);
}
{
TD::OP_NumericParameter p;
p.name = GpudirectName;
p.label = GpudirectLabel;
p.page = "Generator";
p.defaultValues[0] = false;
TD::OP_ParAppendResult res = manager->appendToggle(p);
assert(res == TD::OP_ParAppendResult::Success);
}
}
#pragma endregion