From e76ed2e1f71f3de3d7b91828b8b5ce415a002474 Mon Sep 17 00:00:00 2001 From: NAOTONE Date: Wed, 9 Dec 2015 09:31:55 +0900 Subject: [PATCH] Add naotoRileyScene --- bin/data/naotoRileyScene/code.txt | 32 +++++++ .../naotoRilryScene/naotoRileyScene.cpp | 93 +++++++++++++++++++ src/scenes/naotoRilryScene/naotoRileyScene.h | 23 +++++ src/scenes/sceneManager.cpp | 2 + 4 files changed, 150 insertions(+) create mode 100644 bin/data/naotoRileyScene/code.txt create mode 100644 src/scenes/naotoRilryScene/naotoRileyScene.cpp create mode 100644 src/scenes/naotoRilryScene/naotoRileyScene.h diff --git a/bin/data/naotoRileyScene/code.txt b/bin/data/naotoRileyScene/code.txt new file mode 100644 index 0000000..785516e --- /dev/null +++ b/bin/data/naotoRileyScene/code.txt @@ -0,0 +1,32 @@ +for (int i = 0; i < num; i++) { + + ofPath path; + + int radius = height * j; + arcLength += radius*TWO_PI/num; + float theta = arcLength /radius; + + int x0 = radius*cos(theta+j+shift)+shiftX*j; + int y0 = radius*sin(theta+j+shift)+shiftY*j; + + path.moveTo(x0,y0); + + int x1 = radius*cos(theta+width+j+shift)+shiftX*j; + int y1 = radius*sin(theta+width+j+shift)+shiftY*j; + + path.lineTo(x1,y1); + + int x2 = (radius+height)*cos(theta+width+j)+shiftX*(j+1); + int y2 = (radius+height)*sin(theta+width+j)+shiftY*(j+1); + + path.lineTo(x2,y2); + + int x3 = (radius+height)*cos(theta+j)+shiftX*(j+1); + int y3 = (radius+height)*sin(theta+j)+shiftY*(j+1); + + path.lineTo(x3,y3); + + path.close(); + path.draw(); + +} \ No newline at end of file diff --git a/src/scenes/naotoRilryScene/naotoRileyScene.cpp b/src/scenes/naotoRilryScene/naotoRileyScene.cpp new file mode 100644 index 0000000..0b3c18e --- /dev/null +++ b/src/scenes/naotoRilryScene/naotoRileyScene.cpp @@ -0,0 +1,93 @@ + +#include "naotoRileyScene.h" + +void naotoRileyScene::setup(){ + height.set("height", 40, 40, 80); + width.set("width", 0.0525, 0.01, 0.075); + num.set("num", 63, 28, 78); + shiftSlider.set("shift", 0.35, -0.5, 0.5); + shiftX.set("shiftX", 0, -20, 20); + shiftY.set("shiftY", -20, -20, 20); + + parameters.add(height); + parameters.add(width); + parameters.add(num); + parameters.add(shiftSlider); + parameters.add(shiftX); + parameters.add(shiftY); + + loadCode("naotoRileyScene/code.txt"); + +} + +void naotoRileyScene::update(){ + width = width.getMin() + ofMap(cos(ofGetElapsedTimef()*.3), -1, 1, 0, 1) * (width.getMax() - width.getMin()); +} + +void naotoRileyScene::draw(){ + int frameNum = ofGetFrameNum(); + + if(frameNum % 120 ==0 || frameNum % 220 == 0 ){ + height= ofRandom(height.getMin(), height.getMax()); + } + shiftX = ofMap( ofNoise( ofGetElapsedTimef()*.3), 0, 1, shiftX.getMin(), shiftX.getMax()); + shiftY = ofMap( ofNoise( ofGetElapsedTimef()*.5), 0, 1, shiftY.getMin(), shiftY.getMax()); + + ofBackground(255); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(dimensions.width*(1.0 - ofMap(shiftX, shiftX.getMin(), shiftX.getMax(), 0.3, 0.7)), dimensions.height*(1.0 - ofMap(shiftY, shiftY.getMin(), shiftY.getMax(), 0.3, 0.7))); + ofRotate(ofGetFrameNum()*.5); + + ofFill(); + + float arcLength = 0; + for(int j = 0; j < 12; j++){ + if(j!=1){ + if(j % 2 == 0){ + shift = shiftSlider; + }else{ + shift = -shiftSlider; + } + }else{ + shift =0; + } + + for (int i = 0; i < num; i++) { + + ofPath path; + path.setColor(ofColor(0)); + + int radius = height * j; + arcLength += radius*TWO_PI/num; + float theta = arcLength /radius; + + int x0 = radius*cos(theta+j+shift)+shiftX*j; + int y0 = radius*sin(theta+j+shift)+shiftY*j; + + path.moveTo(x0,y0); + + int x1 = radius*cos(theta+width+j+shift)+shiftX*j; + int y1 = radius*sin(theta+width+j+shift)+shiftY*j; + + path.lineTo(x1,y1); + + int x2 = (radius+height+0.1)*cos(theta+width+j)+shiftX*(j+1); + int y2 = (radius+height+0.1)*sin(theta+width+j)+shiftY*(j+1); + + path.lineTo(x2,y2); + + int x3 = (radius+height+0.1)*cos(theta+j)+shiftX*(j+1); + int y3 = (radius+height+0.1)*sin(theta+j)+shiftY*(j+1); + + path.lineTo(x3,y3); + + path.close(); + path.draw(); + + } + } + + ofPopMatrix(); + +} diff --git a/src/scenes/naotoRilryScene/naotoRileyScene.h b/src/scenes/naotoRilryScene/naotoRileyScene.h new file mode 100644 index 0000000..9628121 --- /dev/null +++ b/src/scenes/naotoRilryScene/naotoRileyScene.h @@ -0,0 +1,23 @@ + +#pragma once + +#include "ofMain.h" +#include "baseScene.h" + +class naotoRileyScene : public baseScene { + +public: + + void setup(); + void update(); + void draw(); + + ofParameter height; + ofParameter width; + ofParameter num; + ofParameter shiftSlider; + ofParameter shiftX, shiftY; + + float shift; + +}; \ No newline at end of file diff --git a/src/scenes/sceneManager.cpp b/src/scenes/sceneManager.cpp index 6bec2d5..b0b106a 100644 --- a/src/scenes/sceneManager.cpp +++ b/src/scenes/sceneManager.cpp @@ -33,9 +33,11 @@ #include "cantusFirmusRiley.h" #include "chrisVeraInterruptions.h" #include "aaronMarcusHieroglyphB.h" +#include "naotoRileyScene.h" void sceneManager::setup(){ + scenes.push_back(new naotoRileyScene()); scenes.push_back(new chrisVeraInterruptions()); scenes.push_back(new johnWhitneyShader02()); scenes.push_back(new chrisRileyCascando());