diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-08-09 17:43:30 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-08-09 17:43:30 +0100 |
| commit | 668077a990bb8f09d3e34b37b63cfd58e82a50f9 (patch) | |
| tree | 6ec6bdff6e20ea8a1da57f5fd99f411a2715eec5 /rotord | |
| parent | 135823808575cc376e4c011cc9f78f15fbf5971b (diff) | |
working on noise node
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/nodes_filters.h | 43 | ||||
| -rw-r--r-- | rotord/src/nodes_maths.h | 28 |
2 files changed, 69 insertions, 2 deletions
diff --git a/rotord/src/nodes_filters.h b/rotord/src/nodes_filters.h new file mode 100644 index 0000000..c6de606 --- /dev/null +++ b/rotord/src/nodes_filters.h @@ -0,0 +1,43 @@ +#ifndef ROTOR_FILTERS +#define ROTOR_FILTERS + +#include "rotor.h" + +namespace Rotor { + class Blur: public Image_node { + public: + Blur(){}; + Blur(map<string,string> &settings) { + base_settings(settings); + size=find_setting(settings,"size",0.0f); + }; + ~Blur(){ + }; + void link_params() { + for (auto p:parameter_inputs){ + p->receiver=nullptr; + if (p->parameter=="size") p->receiver=&size; + } + }; + Blur* clone(map<string,string> &_settings) { return new Blur(_settings);}; + Image *output(const Frame_spec &frame){ + if (image_inputs.size()) { + if (image_inputs[0]->connection){ + Image *other=(((Image_node*)image_inputs[0]->connection)->get_output(frame)); + image.setup(other->w,other->h); + int ksize=max((ceil(size/2.0)*2)+1,1.0); + //nb this doesn't do the intended: create 'continuously variable' blur + cv::GaussianBlur((*other).rgb,image.rgb,cvSize(ksize,ksize),size); + return ℑ + } + } + return nullptr; + } + private: + Image image; + float size; + }; +} + + +#endif
\ No newline at end of file diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index d7aed56..16d37d3 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -2,6 +2,8 @@ #define ROTOR_MATHS #include "rotor.h" +#include <noise/noise.h> +#include <noise/mathconsts.h> namespace Rotor { #define COMPARISON_Equal 1 @@ -200,7 +202,7 @@ namespace Rotor { return 0.0f; } }; - //pseudo random repeatable hash function + //pseudo random hash function //http://create.stephan-brumme.com/fnv-hash/ const uint32_t Prime = 0x01000193; // 16777619 const uint32_t Seed = 0x811C9DC5; // 2166136261 @@ -226,12 +228,12 @@ namespace Rotor { return fnv1a(*ptr , hash); } class Random: public Signal_node { + //randomises integer while keeping fraction public: Random(){}; Random(map<string,string> &settings) { base_settings(settings); seed=(Seed+find_setting(settings,"seed",0)); - cerr<<"random:: seed "<<seed<<" ("<<Seed<<")"<<endl; }; Random* clone(map<string,string> &_settings) { return new Random(_settings);}; const float output(const Time_spec &time) { @@ -249,6 +251,28 @@ namespace Rotor { uint32_t seed; private: }; + class Noise: public Signal_node { + //fractal noise + public: + Noise(){}; + Noise(map<string,string> &settings) { + base_settings(settings); + seed=find_setting(settings,"seed",0); + }; + Noise* clone(map<string,string> &_settings) { return new Noise(_settings);}; + const float output(const Time_spec &time) { + if (inputs.size()) { + if (inputs[0]->connection) { + float o=(((Signal_node*)inputs[0]->connection)->get_output(time)); + + return o; + } + } + return 0.0f; + } + uint32_t seed; + private: + }; } #endif
\ No newline at end of file |
