Browse Source

need to fix camera

master
cailean 2 months ago
parent
commit
d339634347
  1. 4
      .vscode/c_cpp_properties.json
  2. BIN
      bin/data/new_tree.bin
  3. 92
      bin/data/ofxpimapper.xml
  4. 6
      bin/data/shaders/espDepth.frag
  5. 8
      bin/data/shaders/p_depth.vert
  6. BIN
      bin/image-to-mesh
  7. 115
      src/Bullet.cpp
  8. 19
      src/Bullet.h
  9. 2
      src/main.cpp
  10. 12
      src/network/Server.cpp
  11. 124
      src/ofApp.cpp
  12. 14
      src/ofApp.h
  13. 21
      src/utils/QuadSource.cpp
  14. 17
      src/utils/QuadSource.h

4
.vscode/c_cpp_properties.json

@ -125,7 +125,9 @@
"/usr/local/onnxruntime-linux-x64-gpu-1.19.2/include",
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxOsc/src",
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxOsc/libs/oscpack/src/osc",
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxOsc/libs/oscpack/src/ip"
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxOsc/libs/oscpack/src/ip",
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxPiMapper/**",
"/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/addons/ofxGui/src"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,

BIN
bin/data/new_tree.bin

Binary file not shown.

92
bin/data/ofxpimapper.xml

@ -0,0 +1,92 @@
<surfaces>
<surface type="1">
<vertices>
<vertex>
<x>280.000000000</x>
<y>-460.000000000</y>
</vertex>
<vertex>
<x>2200.000000000</x>
<y>-460.000000000</y>
</vertex>
<vertex>
<x>2200.000000000</x>
<y>500.000000000</y>
</vertex>
<vertex>
<x>280.000000000</x>
<y>500.000000000</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>fbo</source-type>
<source-name>stubborn_vectors</source-name>
</source>
<properties>
<perspectiveWarping>0</perspectiveWarping>
</properties>
</surface>
<surface type="1">
<vertices>
<vertex>
<x>-1210.000000000</x>
<y>-338.000000000</y>
</vertex>
<vertex>
<x>610.000000000</x>
<y>-338.000000000</y>
</vertex>
<vertex>
<x>610.000000000</x>
<y>642.000000000</y>
</vertex>
<vertex>
<x>-1210.000000000</x>
<y>642.000000000</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>none</source-type>
<source-name>none</source-name>
</source>
<properties>
<perspectiveWarping>1</perspectiveWarping>
</properties>
</surface>
</surfaces>

6
bin/data/shaders/espDepth.frag

@ -22,11 +22,11 @@ void main() {
// Choose base color based on quadrant
if (quadrant == 0) {
baseColor = vec3(1.0, 0.0, 0.0); // Red for bottom-left
baseColor = vec3(0.0, 1.0, 0.0); // Red for bottom-left
} else if (quadrant == 1) {
baseColor = vec3(0.0, 1.0, 0.0); // Green for bottom-right
baseColor = vec3(0.0, 0.0, 1.0); // Green for bottom-right
} else if (quadrant == 2) {
baseColor = vec3(0.0, 0.0, 1.0); // Blue for top-left
baseColor = vec3(1.0, 0.0, 0.0); // Blue for top-left
} else {
baseColor = vec3(1.0, 1.0, 1.0); // White for top-right
}

8
bin/data/shaders/p_depth.vert

@ -3,6 +3,7 @@
uniform mat4 modelViewProjectionMatrix;
uniform float gridSize;
uniform vec2 resolution;
uniform vec2 threshold;
uniform sampler2DRect tex1;
in vec2 texcoord;
@ -17,11 +18,14 @@ void main()
// vec4 t_sample = texture(tex0, tex_c);
float depth = texture(tex1, tex_c).r;
float depth = pow(texture(tex1, tex_c).r, 2);
// Normalize the depth value between 0 and 1 based on min/max
float normalizedDepth = (depth) / threshold.y;
vec4 displaced = position;
displaced.z = depth * 400.0;
displaced.z = normalizedDepth * 800.0;
//vec2 resolution = vec2(1280.0, 960.0);

BIN
bin/image-to-mesh

Binary file not shown.

115
src/Bullet.cpp

@ -4,7 +4,7 @@ void Bullet::setup(vector<Node>& _nodes){
/* setup camera & world */
camera_start_pos = ofVec3f(0, -3.f, -40.f);
camera_end_position = glm::vec3(ofRandom(-100, 100), ofRandom(-100, 100), ofRandom(0, 0));
camera_move_duration = 10.f;
camera_move_duration = 20.f;
camera_move_start_time = ofGetElapsedTimef();
is_camera_moving = false;
@ -14,6 +14,8 @@ void Bullet::setup(vector<Node>& _nodes){
camera.setScale(0.01);
camera.setNearClip(-10000);
camera.setFarClip(10000);
camera.disableMouseInput();
camera.removeAllInteractions();
world.setup();
world.setCamera(&camera);
@ -28,31 +30,102 @@ void Bullet::setup(vector<Node>& _nodes){
std::cout << workerThreads.size() << std::endl;
}
void Bullet::update(){
void Bullet::update(bool& is_controller_active, Node& chosen_node) {
updateRepulsionNode();
cameraBounds = getCameraBounds(camera);
world.update();
if(is_camera_moving){
float t = (ofGetElapsedTimef() - camera_move_start_time) / camera_move_duration;
if (t >= 1.0f){
t = 1.0f;
is_camera_moving = false;
}
float easedT = easeInOutCubic(t);
static bool was_controller_active = false;
static float transition_timer = 0.0f;
static glm::vec3 start_pos;
glm::vec3 current_pos = camera.getPosition();
float deltaTime = ofGetLastFrameTime();
// Detect transition from controller to inactive
if (is_controller_active != was_controller_active) {
if (!is_controller_active) {
// Starting transition to new node
transition_timer = 0.0f;
start_pos = current_pos;
}
}
glm::vec3 new_position = glm::mix(camera_start_pos, camera_end_position, easedT);
camera.setPosition(new_position);
if (!is_controller_active && &chosen_node != current_target_node) {
current_target_node = &chosen_node;
}
float baseZoom = 0.01f;
float peakZoom = 0.04f;
float zoomT = 1.0f - abs(2.0f * easedT - 1.0f); // Triangle wave using easedT
float easedZoomT = easeInOutCubic(zoomT); // Apply easing to the zoom
float currentZoom = glm::mix(baseZoom, peakZoom, easedZoomT);
camera.setScale(currentZoom);
// Update camera physics
if (is_controller_active) {
// Decelerate over 2 seconds
float deceleration_rate = 0.5f; // 1/2 = 2 seconds
camera_velocity = camera_velocity * (1.0f - deceleration_rate * deltaTime);
if (glm::length(camera_velocity) < 0.01f) {
camera_velocity = glm::vec3(0.0f);
}
// Keep base zoom when controller is active
current_zoom = current_zoom + (0.03f - current_zoom) * deltaTime * 5.0f;
} else {
//setNewCameraEndpoint();
glm::vec3 target_position = current_target_node->collider->getPosition();
// Transition period (zooming out and in)
if (transition_timer < 10.0f) { // 2 second transition
transition_timer += deltaTime;
float progress = transition_timer / 2.0f;
// Zoom curve (out and in)
float zoomProgress;
if (progress < 0.5f) {
// Zoom out during first half
zoomProgress = progress * 2.0f;
float targetZoom = glm::mix(0.03f, 0.6f, zoomProgress);
current_zoom = current_zoom + (targetZoom - current_zoom) * deltaTime * 5.0f;
} else {
// Zoom in during second half
zoomProgress = (1.0f - progress) * 2.0f;
float targetZoom = glm::mix(0.03f, 0.6f, zoomProgress);
current_zoom = current_zoom + (targetZoom - current_zoom) * deltaTime * 5.0f;
}
// Move towards target during transition
glm::vec3 ideal_pos = glm::mix(start_pos, target_position, progress);
camera_velocity = (ideal_pos - current_pos) / deltaTime;
} else {
// After transition, follow node with spring physics
float k = 2.0f;
float damping = 3.0f;
glm::vec3 displacement = target_position - current_pos;
glm::vec3 spring_force = k * displacement;
camera_velocity = camera_velocity + spring_force * deltaTime;
camera_velocity = camera_velocity * (1.0f - damping * deltaTime);
// Optional: Velocity-based zoom after transition
float speed = glm::length(camera_velocity);
float maxSpeed = 25.0f;
float speedFactor = glm::min(speed / maxSpeed, 1.0f);
float targetZoom = glm::mix(0.03f, 0.15f, speedFactor); // smaller zoom range for following
current_zoom = current_zoom + (targetZoom - current_zoom) * deltaTime * 5.0f;
}
// Clamp velocity to maximum speed
float maxSpeed = 25.0f;
float currentSpeed = glm::length(camera_velocity);
if (currentSpeed > maxSpeed) {
camera_velocity = (camera_velocity / currentSpeed) * maxSpeed;
}
}
camera.setScale(current_zoom);
// Update position using velocity
glm::vec3 new_position = current_pos + camera_velocity * deltaTime;
camera.setPosition(new_position);
was_controller_active = is_controller_active;
}
void Bullet::draw(){
@ -95,7 +168,7 @@ void Bullet::draw(){
ofPushMatrix();
shader.begin();
shader.setUniform1f("gridSize", gridSize);
shader.setUniform2f("resolution", glm::vec2(1280.0, 960.0));
shader.setUniform2f("resolution", glm::vec2((1920.0 / 3) * 2, 960.0));
shader.setUniformTexture("tex0", n.tex, 0);
n.collider->transformGL();
ofScale(n.scale);
@ -128,12 +201,10 @@ void Bullet::draw(){
void Bullet::addMesh(ofMesh _mesh, ofMesh _simple_mesh, Node& _node){
std::lock_guard<std::mutex> lock(shapeMutex);
// n.tex = _tex;
float rand = ofRandom(0.01, 0.02);
glm::vec3 random_szie(rand, rand, rand);
_node.scale = random_szie;
ofQuaternion startRot = ofQuaternion(0., 0., 0., PI);
// ofVec3f target_location = ofVec3f( ofRandom(0, 0), ofRandom(0, 0), -5 );
ofVec3f start_location = ofVec3f( ofRandom(-3000, 3000), ofRandom(-3000, 3000) -5 );
ofxBulletCustomShape* s = new ofxBulletCustomShape();
@ -146,8 +217,6 @@ void Bullet::addMesh(ofMesh _mesh, ofMesh _simple_mesh, Node& _node){
s->getRigidBody()->setActivationState(DISABLE_DEACTIVATION);
s->getRigidBody()->setRestitution(btScalar(0.5));
s->getRigidBody()->setFriction(btScalar(1.0));
//positions.push_back(target_location);
// Set how the col mesh is drawn!
_simple_mesh.setMode(OF_PRIMITIVE_LINES);

19
src/Bullet.h

@ -20,7 +20,7 @@ struct Node {
class Bullet{
public:
void setup(vector<Node>& _nodes);
void update();
void update(bool& is_camera_active, Node& chosen_node);
void draw();
void addMesh(ofMesh _mesh, ofMesh _simple_mesh, Node& _node);
float easeInOutCubic(float t);
@ -54,7 +54,11 @@ class Bullet{
bool is_camera_moving;
float camera_move_duration;
float camera_move_start_time;
float deceleration_start_time = 0.0f;
glm::vec3 initial_velocity = glm::vec3(0.0f);
bool was_camera_active = false;
float current_zoom = 0.03f;
glm::vec3 transition_start_pos;
ofLight light;
ofTexture tex;
@ -107,6 +111,13 @@ class Bullet{
}
}
void startCameraMovement(const glm::vec3& target_pos) {
camera_start_pos = camera.getPosition();
camera_end_position = target_pos;
camera_move_start_time = ofGetElapsedTimef();
is_camera_moving = true;
}
~Bullet() {
cleanup();
}
@ -129,4 +140,8 @@ class Bullet{
void workerThreadFunction(int threadId);
void updateShapeBatch(size_t start, size_t end);
bool now = true;
bool new_chosen_node;
Node* current_target_node = nullptr;
glm::vec3 camera_velocity = glm::vec3(0.0f);
};

2
src/main.cpp

@ -6,7 +6,7 @@ int main( ){
//Use ofGLFWWindowSettings for more options like multi-monitor fullscreen
ofGLWindowSettings settings;
settings.setSize(1920, 960);
settings.setSize(1920, 1080);
settings.setGLVersion(3, 2);
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN

12
src/network/Server.cpp

@ -54,7 +54,7 @@ void Server::update(ofFbo& esp_comp){
addOrUpdateClient(id, value, ip_address, true);
//std::cout << ip_address << " : " << id << std::endl;
std::cout << ip_address << " : " << id << std::endl;
}
@ -87,7 +87,7 @@ void Server::addOrUpdateClient(int client_id, float value, const std::string& ip
void Server::updateEmbedding() {
std::vector<std::string> emotionNames = {
"angry", "disgust", "fear", "happy", "sad", "surprise", "neutral"
"happy", "sad", "angry", "neutral", "fear", "surprise", "disgust"
};
for (const auto& c : clients) {
@ -98,12 +98,6 @@ void Server::updateEmbedding() {
embedding.emotions[emotionNames[c.first]] = val;
}
// Special case for neutral (index 6)
if (c.first == 6) {
embedding.emotions["fear"] = ofRandom(0.1, 0.6);
embedding.emotions["angry"] = ofRandom(0.01, 0.99);
embedding.emotions["happy"] = ofRandom(0.01, 0.99);
}
}
}
@ -121,7 +115,7 @@ void Server::printClients(){
void Server::print(){
const std::vector<std::string> emotionNames = {
"angry", "disgust", "fear", "happy", "sad", "neutral"
"happy", "sad", "angry", "neutral", "disgust", "fear", "surprise"
};
std::ostringstream ss;

124
src/ofApp.cpp

@ -4,14 +4,14 @@
void ofApp::setup(){
/* allocated fbo's */
map_fbo.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGB);
map_fbo_alpha.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGBA);
portrait_fbo.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGBA);
portrait_pre_fbo.allocate((ofGetWindowWidth() / 3) * 1, ofGetWindowHeight(), GL_RGB);
portrait_pre_fbo_alpha.allocate((ofGetWindowWidth() / 3) * 1, ofGetWindowHeight(), GL_RGBA);
comp_fbo.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGBA);
model_outptut_fbo.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGB);
map_fbo.allocate((ofGetWindowWidth() / 3) * 2, map_h, GL_RGB);
map_fbo_alpha.allocate((ofGetWindowWidth() / 3) * 2, map_h, GL_RGBA);
portrait_fbo.allocate((ofGetWindowWidth() / 3), map_h, GL_RGBA);
portrait_pre_fbo.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGB);
portrait_pre_fbo_alpha.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGBA);
comp_fbo.allocate(ofGetWindowWidth(), map_h, GL_RGBA);
model_outptut_fbo.allocate((ofGetWindowWidth() / 3) * 2, map_h, GL_RGB);
model_esp_out_fbo.allocate(128 * 2, 168 * 2, GL_RGB);
model_portrait_out_fbo.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), GL_RGB);
@ -21,10 +21,10 @@ void ofApp::setup(){
/* input images for model */
model_image_esp.allocate(128 * 2, 168 * 2, OF_IMAGE_COLOR);
model_image.allocate(ofGetWindowWidth(), ofGetWindowHeight(), OF_IMAGE_COLOR);
model_image.allocate(map_fbo.getWidth(), map_h, OF_IMAGE_COLOR);
model_image_portrait.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), OF_IMAGE_COLOR);
map_pixels.allocate(ofGetWindowWidth(), ofGetWindowHeight(), OF_PIXELS_RGB);
map_pixels.allocate(map_fbo.getWidth(), map_h, OF_PIXELS_RGB);
/* allocated ofImages in esp_images */
for(int i = 0; i < 4; i++){
@ -51,22 +51,32 @@ void ofApp::setup(){
ORTCHAR_T* modelPath = "/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/apps/myApps/image-to-mesh/bin/data/models/depth_anything_v2_vits.onnx";
ORTCHAR_T* modelPath_Small = "/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/apps/myApps/image-to-mesh/bin/data/models/depth_anything_v2_vits.onnx";
/* setup */
/* bullet setup */
bullet.setup(nodes);
/* pi mapper setup */
// mapper.registerFboSource(projection_src);
// mapper.setup();
// projection_src.setFbo(&comp_fbo);
/* onnx setup */
depth_onnx.Setup(modelPath, false, true);
depth_onnx_esp.Setup(modelPath_Small, false, true);
depth_onnx_portrait.Setup(modelPath_Small, false, true);
/* multi-thread setup */
depth_thread.setup(&model_image, &model_outptut_fbo, &depth_onnx);
depth_esp.setup(&model_image_esp, &model_esp_out_fbo, &depth_onnx_esp);
depth_portrait.setup(&model_image_portrait, &model_portrait_out_fbo, &depth_onnx_portrait);
/* camera settings for portrait */
portrait_camera.setFov(90);
//portrait_camera.setFov(90);
portrait_camera.enableOrtho();
portrait_camera.setNearClip(-10000);
portrait_camera.setFarClip(10000);
portrait_camera.setPosition(0, 150, 480);
portrait_camera.removeAllInteractions();
portrait_camera.disableMouseInput();
//portrait_camera.removeAllInteractions();
//portrait_camera.disableMouseInput();
createNodes("data/json/embeddings.json");
@ -127,7 +137,8 @@ void ofApp::update(){
std::cout << "Model did not run" << std::endl;
}
bullet.update();
//mapper.update();
bullet.update(server->is_active, server->getChosenNode());
}
//--------------------------------------------------------------
@ -176,23 +187,33 @@ void ofApp::draw(){
shaders.begin();
shaders.setUniformTexture("tex0", t, 0);
shaders.setUniformTexture("tex1", bayer, 1);
shaders.setUniform2f("resolution", ofGetWidth(), ofGetHeight());
shaders.setUniform2f("resolution", map_w, map_h);
shaders.setUniform1f("time", ofGetElapsedTimef());
shaders.setUniform1i("frame", ofGetFrameNum());
model_outptut_fbo.draw(0, 0);
portrait_fbo.draw(0, 0);
map_fbo_alpha.draw(0,0);
model_portrait_out_fbo.draw((map_w/3) * 2,0);
portrait_fbo.draw((map_w/3) * 2, 0);
shaders.end();
comp_fbo.end();
comp_fbo.getTexture().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
//mapper.draw();
comp_fbo.draw(0,60);
comp_fbo.draw(0,0);
server->print();
}
void ofApp::drawPortrait(){
Node n = server->getChosenNode();
float p_scale = 1 + ( ((1 + ofNoise(ofGetElapsedTimef() / 2)) / 2) * 2);
portrait_pre_fbo.begin();
ofClear(0, 0, 0, 0);
float scale = min(
(float)portrait_pre_fbo.getWidth() / n.img.getWidth(),
(float)portrait_pre_fbo.getHeight() / n.img.getHeight()
@ -201,14 +222,33 @@ void ofApp::drawPortrait(){
float scaledHeight = n.img.getHeight() * scale;
float xPos = (portrait_pre_fbo.getWidth() - scaledWidth) / 2;
float yPos = (portrait_pre_fbo.getHeight() - scaledHeight) / 2;
n.img.draw(xPos, yPos, scaledWidth, scaledHeight);
portrait_pre_fbo.end();
ofPushMatrix();
// Move to center of FBO
ofTranslate(portrait_pre_fbo.getWidth()/2, portrait_pre_fbo.getHeight() * 0.8);
// Apply scale
ofScale(p_scale);
// Move back by half the scaled image dimensions
ofTranslate(-scaledWidth/2, -scaledHeight/2);
// Draw at 0,0 since we've already translated
n.img.draw(0, 0, scaledWidth, scaledHeight);
ofPopMatrix();
portrait_pre_fbo.end();
portrait_pre_fbo_alpha.begin();
ofPushMatrix();
ofClear(0, 0, 0, 0);
n.img.draw(xPos, yPos, scaledWidth, scaledHeight);
ofTranslate(portrait_pre_fbo.getWidth()/2, portrait_pre_fbo.getHeight() * 0.8);
// Apply scale
ofScale(p_scale);
// Move back by half the scaled image dimensions
ofTranslate(-scaledWidth/2, -scaledHeight/2);
n.img.draw(0, 0, scaledWidth, scaledHeight);
ofPopMatrix();
portrait_pre_fbo_alpha.end();
ofPixels pix;
portrait_pre_fbo.readToPixels(pix);
model_image_portrait.setFromPixels(pix);
@ -218,6 +258,27 @@ void ofApp::drawPortraitZ(){
ofTexture tex_color = portrait_pre_fbo_alpha.getTexture();
ofTexture tex_depth = model_portrait_out_fbo.getTexture();
float minDepth = std::numeric_limits<float>::max();
float maxDepth = std::numeric_limits<float>::lowest();
ofPixels depth_pix;
tex_depth.readToPixels(depth_pix);
float max_r = 0;
// Loop through only the R channel
for(int i = 0; i < depth_pix.getWidth() * depth_pix.getHeight(); i++) {
float depth = depth_pix[i * depth_pix.getNumChannels()] / 255.0f; // Access just R channel
if(max_r < depth){
max_r = depth;
}
}
/* map bullet cam scale to portrait z-dist */
float map_camera_scale = bullet.camera.getScale().x;
float pz = ofMap(map_camera_scale, 0.01, 0.03, 300, 550);
//portrait_camera.setPosition(glm::vec3(portrait_camera.getPosition().x, portrait_camera.getPosition().y, pz));
portrait_camera.begin();
ofEnableDepthTest();
@ -240,6 +301,7 @@ void ofApp::drawPortraitZ(){
p_depth.begin();
p_depth.setUniform1f("gridSize", g_size);
p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight()));
p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r));
p_depth.setUniformTexture("tex0", tex_color, 0);
p_depth.setUniformTexture("tex1", tex_depth, 1);
ofFill();
@ -478,4 +540,24 @@ void ofApp::keyPressed(int key) {
ofLog() << "Plane Size: " << plane_size;
break;
}
//mapper.keyPressed(key);
}
void ofApp::keyReleased(int key){
//mapper.keyReleased(key);
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
//mapper.mouseDragged(x, y, button);
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
//mapper.mousePressed(x, y, button);
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
//mapper.mouseReleased(x, y, button);
}

14
src/ofApp.h

@ -12,6 +12,8 @@
#include "network/Server.h"
#include "ofxTSNE.h"
#include "utils/KDTree.hpp"
#include "utils/QuadSource.h"
#include "ofxPiMapper.h"
class ofApp : public ofBaseApp{
@ -28,6 +30,10 @@ class ofApp : public ofBaseApp{
void drawPortrait();
void drawPortraitZ();
void keyPressed(int key);
void keyReleased(int key);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseDragged(int x, int y, int button);
void exit();
ofEasyCam portrait_camera;
@ -100,6 +106,12 @@ class ofApp : public ofBaseApp{
std::vector<pointIndex> kd_result;
float g_size = 10;
float plane_size = 50;
float plane_size = 100;
/* pi mapper */
ofxPiMapper mapper;
QuadSource projection_src;
int map_h = 960;
int map_w = 1920;
};

21
src/utils/QuadSource.cpp

@ -0,0 +1,21 @@
#include "QuadSource.h"
void QuadSource::setup(){
// name
name = "stubborn_vectors";
// allocate size
allocate(1920, 960);
}
void QuadSource::update(){
}
void QuadSource::draw(){
// Fill FBO with our quads
ofClear(0);
//ofBackground(255, 120, 10);
fbo_in->draw(0, 0);
}

17
src/utils/QuadSource.h

@ -0,0 +1,17 @@
#ifndef _QUADSOURCE
#define _QUADSOURCE
#include "ofMain.h"
#include "FboSource.h"
class QuadSource : public ofx::piMapper::FboSource{
public:
void setup();
void update();
void draw();
std::vector<ofRectangle> quads;
std::vector<float> quad_speeds;
};
#endif
Loading…
Cancel
Save