From 5ac2dfa655a6a19577b2560b3b73f7e807cd5a9a Mon Sep 17 00:00:00 2001 From: micuat Date: Sat, 31 Oct 2020 12:31:05 +0100 Subject: [PATCH] tweening one/two people but not with 3 :( --- .vscode/settings.json | 4 +++- zoneb/bin/data/settings.xml | 2 +- zoneb/bin/data/shaders/particles/draw.frag | 7 +++++-- zoneb/src/ofApp.cpp | 17 +++++++++++++++-- zoneb/src/ofApp.h | 2 ++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a8c27d7..f190762 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,8 @@ "fstream": "cpp", "deque": "cpp", "string": "cpp", - "vector": "cpp" + "vector": "cpp", + "array": "cpp", + "string_view": "cpp" } } \ No newline at end of file diff --git a/zoneb/bin/data/settings.xml b/zoneb/bin/data/settings.xml index 7c9c085..7d181ef 100644 --- a/zoneb/bin/data/settings.xml +++ b/zoneb/bin/data/settings.xml @@ -2,6 +2,6 @@ 61.2245, -12.2449 1.869 - video3 + video1 7 diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 3cc5e3a..feb88a5 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -10,6 +10,8 @@ uniform sampler2DRect warm2; uniform sampler2DRect cold1; uniform sampler2DRect cold2; +uniform float uAreThereTwoPeopleTween; + uniform vec3 uHottest0; uniform vec3 uHottest1; uniform vec3 uHottest3d0; @@ -104,8 +106,9 @@ void main() vec3 remapedColorC = texture(cold2, palette).xyz; float d = 50; float D = 600; - float rate = smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + simplex3d(vPos * vec3(0.001, 0.001, 0.1)) * 100); - vec3 remapedColor = mix(remapedColorW, remapedColorC, rate); + float rate = 1-smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + simplex3d(vPos * vec3(0.001, 0.001, 0.1)) * 100); + rate *= uAreThereTwoPeopleTween; + vec3 remapedColor = mix(remapedColorC, remapedColorW, rate); float alpha = max(0, 1 - pow(vAge,4)); vec4 color = vec4(remapedColor, alpha); diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 9e0622e..2019ba4 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -64,6 +64,9 @@ void ofApp::setupThermal() v4l2Pixels.setColor(j, i, 0); } } + + areThereTwoPeople = false; + areThereTwoPeopleTween = 0; } void ofApp::setupParticles() @@ -236,10 +239,18 @@ void ofApp::updateThermal() if (hotspots.size() > 1 && hotspots.at(1).size() > 0) { hotspot1 = hotspots.at(1).at(0); + areThereTwoPeople = true; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); } - else if (hotspots.size() > 0 && hotspots.at(0).size() > 1) + else if (dummyMode == true && (hotspots.size() > 0 && hotspots.at(0).size() > 1)) { hotspot1 = hotspots.at(0).at(1); + areThereTwoPeople = true; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); + } + else { + areThereTwoPeople = false; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1); } hotspot3d0 = getDepthAt(hotspot0.x, hotspot0.y); @@ -264,7 +275,7 @@ void ofApp::update() } else { - uBetween = ofVec3f(10000000, 0, 0); + // uBetween = ofVec3f(10000000, 0, 0); } } else @@ -293,6 +304,7 @@ void ofApp::onParticlesUpdate(ofxShader &shader) shader.setUniform3f("uHottest1", hotspot1); shader.setUniform3f("uHottest3d0", hotspot3d0); shader.setUniform3f("uHottest3d1", hotspot3d1); + shader.setUniform1f("uAreThereTwoPeopleTween", areThereTwoPeopleTween); } void ofApp::onParticlesDraw(ofxShader &shader) @@ -302,6 +314,7 @@ void ofApp::onParticlesDraw(ofxShader &shader) shader.setUniform3f("uHottest3d0", hotspot3d0); shader.setUniform3f("uHottest3d1", hotspot3d1); shader.setUniform3f("uBetween", uBetween); + shader.setUniform1f("uAreThereTwoPeopleTween", areThereTwoPeopleTween); } void ofApp::drawMain() diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index aee6b49..366e541 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -65,6 +65,8 @@ private: ofVec3f hotspot0, hotspot1; ofVec3f hotspot3d0, hotspot3d1; ofVec3f uBetween; + bool areThereTwoPeople; + float areThereTwoPeopleTween; ofxVec2Slider registrationXY; ofxFloatSlider registrationScale;