summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h101
1 files changed, 100 insertions, 1 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 884d822..fa166a2 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -348,6 +348,105 @@ namespace Rotor {
return time.time/time.duration;
}
};
+#define COMPARISON_Equal 1
+#define COMPARISON_Not_equal 2
+#define COMPARISON_Greater 3
+#define COMPARISON_Less 4
+#define COMPARISON_Greater_or_equal 5
+#define COMPARISON_Less_or_equal 6
+ class Comparison: public Signal_node {
+ public:
+ Comparison(){};
+ Comparison(map<string,string> &settings) {
+ base_settings(settings);
+ value=find_setting(settings,"value",0.0f);
+ string _op=find_setting(settings,"operator","==");
+ if (_op=="==") op=COMPARISON_Equal;
+ if (_op=="!=") op=COMPARISON_Not_equal;
+ if (_op==">") op=COMPARISON_Greater;
+ if (_op=="<") op=COMPARISON_Less;
+ if (_op==">=") op=COMPARISON_Greater_or_equal;
+ if (_op=="<=") op=COMPARISON_Less_or_equal;
+ };
+ Comparison* clone(map<string,string> &_settings) { return new Comparison(_settings);};
+ const float get_output(const Time_spec &time) {
+ if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml
+ if (inputs[0]->connection) {
+ float in= (((Signal_node*)inputs[0]->connection)->get_output(time));
+ switch (op) {
+ case COMPARISON_Equal:
+ return fequal(value,in)?1.0f:0.0f;
+ break;
+ case COMPARISON_Not_equal:
+ return fequal(value,in)?0.0f:1.0f;
+ break;
+ case COMPARISON_Greater:
+ return fgreater(value,in)?1.0f:0.0f;
+ break;
+ case COMPARISON_Less:
+ return fless(value,in)?1.0f:0.0f;
+ break;
+ case COMPARISON_Greater_or_equal:
+ return fgreater_or_equal(value,in)?1.0f:0.0f;
+ break;
+ case COMPARISON_Less_or_equal:
+ return fless_or_equal(value,in)?1.0f:0.0f;
+ break;
+ }
+ }
+ }
+ return 0.0f;
+ }
+ int op;
+ float value;
+ };
+#define ARITHMETIC_plus 1
+#define ARITHMETIC_minus 2
+#define ARITHMETIC_multiply 3
+#define ARITHMETIC_divide 4
+#define ARITHMETIC_modulo 5
+ class Arithmetic: public Signal_node {
+ public:
+ Arithmetic(){};
+ Arithmetic(map<string,string> &settings) {
+ base_settings(settings);
+ value=find_setting(settings,"value",0.0f);
+ string _op=find_setting(settings,"operator","+");
+ if (_op=="+") op=ARITHMETIC_plus;
+ if (_op=="-") op=ARITHMETIC_minus;
+ if (_op=="*") op=ARITHMETIC_multiply;
+ if (_op=="/") op=ARITHMETIC_divide;
+ if (_op=="%") op=ARITHMETIC_modulo;
+ };
+ Arithmetic* clone(map<string,string> &_settings) { return new Arithmetic(_settings);};
+ const float get_output(const Time_spec &time) {
+ if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml
+ if (inputs[0]->connection) {
+ float in= (((Signal_node*)inputs[0]->connection)->get_output(time));
+ switch (op) {
+ case ARITHMETIC_plus:
+ return in+value;
+ break;
+ case ARITHMETIC_minus:
+ return in-value;
+ break;
+ case ARITHMETIC_multiply:
+ return in*value;
+ break;
+ case ARITHMETIC_divide:
+ return in/value;
+ break;
+ case ARITHMETIC_modulo:
+ return fmod(in,value);
+ break;
+ }
+ }
+ }
+ return 0.0f;
+ }
+ int op;
+ float value;
+ };
class Signal_divide: public Signal_node {
public:
Signal_divide(){};
@@ -457,7 +556,7 @@ namespace Rotor {
if (inputs.size()) {
if (image_inputs[0]->connection){
if (inputs[0]->connection) {
- if (fmoreorequal(1.0f,(((Signal_node*)inputs[0]->connection)->get_output((Time_spec)frame)))) {
+ if (fgreater_or_equal(1.0f,(((Signal_node*)inputs[0]->connection)->get_output((Time_spec)frame)))) {
Image *in=(((Image_node*)image_inputs[0]->connection)->get_output(frame));
image->setup(frame.w,frame.h);
for (int i=0;i<in->w*in->h*3;i++) {