distancinig

This commit is contained in:
micuat 2020-10-26 19:09:09 +01:00
parent 9428900252
commit c8b96e72ba
3 changed files with 33 additions and 14 deletions

View file

@ -14,6 +14,7 @@ uniform vec3 uHottest0;
uniform vec3 uHottest1;
uniform vec3 uHottest3d0;
uniform vec3 uHottest3d1;
uniform vec3 uBetween;
in vec2 texCoordVarying;
in vec3 vPos;
@ -102,8 +103,8 @@ void main()
vec3 remapedColorW = texture(warm1, palette).xyz;
vec3 remapedColorC = texture(cold2, palette).xyz;
float d = 50;
float D = 400;
float rate = smoothstep(D - d, D + d, length(vPos.x - uHottest3d1.x) + simplex3d(vPos * vec3(0.001, 0.001, 0.1)) * 100);
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 alpha = max(0, 1 - pow(vAge,4));

View file

@ -132,7 +132,7 @@ void ofApp::setupGui()
debugGui.setup("DEBUG");
debugGui.add(calibMode.setup("calib", false));
debugGui.add(dummyMode.setup("dummy", true)); // should be false
debugGui.add(dummyXY.setup("XY", {256, 256}, {0, 0}, {511, 511})); // should be false
debugGui.add(dummyXY.setup("XY", {0, 0}, {-500, -1000}, {500, 500})); // should be false
debugGui.add(debugFps.setup("FPS", "0"));
debugGui.setPosition(230, 10);
}
@ -228,8 +228,6 @@ void ofApp::updateThermal()
{
hotspot0 = hotspots.at(0).at(0);
}
if (dummyMode == false)
{
if (hotspots.size() > 1 && hotspots.at(1).size() > 0)
{
hotspot1 = hotspots.at(1).at(0);
@ -238,11 +236,6 @@ void ofApp::updateThermal()
{
hotspot1 = hotspots.at(0).at(1);
}
}
else
{
hotspot1 = ofVec3f(dummyXY);
}
hotspot3d0 = getDepthAt(hotspot0.x, hotspot0.y);
hotspot3d1 = getDepthAt(hotspot1.x, hotspot1.y);
@ -251,6 +244,29 @@ void ofApp::updateThermal()
void ofApp::update()
{
if (dummyMode == false)
{
auto &bodySkeletons = kinectDevice.getBodySkeletons();
std::vector<ofVec3f> bodies;
if (bodySkeletons.size() >= 2)
{
for (auto &skeleton : bodySkeletons)
{
auto joint = skeleton.joints[26];
bodies.push_back(toGlm(joint.position));
}
uBetween = bodies.at(0).getInterpolated(bodies.at(1), 0.5f);
}
else
{
uBetween = ofVec3f(10000000, 0, 0);
}
}
else
{
uBetween = ofVec3f(dummyXY->x, 0, dummyXY->y);
}
updateThermal();
particles.update();
@ -280,6 +296,7 @@ void ofApp::onParticlesDraw(ofxShader &shader)
shader.setUniform3f("uHottest1", hotspot1);
shader.setUniform3f("uHottest3d0", hotspot3d0);
shader.setUniform3f("uHottest3d1", hotspot3d1);
shader.setUniform3f("uBetween", uBetween);
}
void ofApp::drawMain()

View file

@ -62,6 +62,7 @@ private:
std::vector<std::vector<ofVec3f>> hotspots;
ofVec3f hotspot0, hotspot1;
ofVec3f hotspot3d0, hotspot3d1;
ofVec3f uBetween;
ofxVec2Slider registrationXY;
ofxFloatSlider registrationScale;