From d07c0df6a9836376f93853c64e06b3daa03c12f1 Mon Sep 17 00:00:00 2001 From: Comment Date: Thu, 20 Feb 2014 23:37:25 +0000 Subject: making recursive descender --- offsetProject/src/ofApp.cpp | 36 +++++++++++++++++++++++++++++++++++- offsetProject/src/ofApp.h | 4 +++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'offsetProject/src') diff --git a/offsetProject/src/ofApp.cpp b/offsetProject/src/ofApp.cpp index c29d8c1..9252da1 100644 --- a/offsetProject/src/ofApp.cpp +++ b/offsetProject/src/ofApp.cpp @@ -54,7 +54,7 @@ void ofApp::setup() { extend_h=(tiles_h)*MAX_TILE_SIZE; //get number of levels - int levels=0; + levels=0; for (int i=MIN_TILE_SIZE;i<=MAX_TILE_SIZE;i*=2) { levels++; } @@ -111,8 +111,42 @@ void ofApp::update() { } } +void ofApp::checktile(int level,int levels,int levels_factor,int x,int y,int xoffset,int yoffset,int size){ + if (depthTiles[level].getPixels()[y*depthTiles[level].getHeight()+x]>level*levels_factor&&levels>level){ + for (int i=0;i<2;i++){ + for (int j=0;j<2;j++){ + checktile(level+1,levels,levels_factor,x*2+i,y*2+j,xoffset*2+(i*size),yoffset*2+(j*size),size/2); + } + } + } + else { + ofSetColor(depthTiles[level].getPixels()[(y*depthTiles[level].getHeight()+x)*3, + depthTiles[level].getPixels()[(y*depthTiles[level].getHeight()+x)*3+1, + depthTiles[level].getPixels()[(y*depthTiles[level].getHeight()+x)*3+2] + ofRect(xoffset,yoffset,size,size); + } +} + //-------------------------------------------------------------- void ofApp::draw() { + + //recursively draw pixels + //is there a way to represent a pixel as an object in this way? + + + for (int i=0;ilevel*levels_factor){ + for (int ix=0;ix<2;ix++){ + for (int iy=0;iy<2;iy++){ + //SIMILAR DEPTH CHECK AND RECURSIVE DESCENT + } + } + else //draw this square + } + } ofSetColor(255, 255, 255); diff --git a/offsetProject/src/ofApp.h b/offsetProject/src/ofApp.h index 8bde9a7..2e3ca28 100644 --- a/offsetProject/src/ofApp.h +++ b/offsetProject/src/ofApp.h @@ -42,6 +42,8 @@ public: void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void windowResized(int w, int h); + + void checktile(int level,int levels,int levels_factor,int x,int y,int xoffset,int yoffset,int size); ofxKinect kinect; @@ -54,6 +56,6 @@ public: int farThreshold; int angle; - + int levels; int extend_w,extend_h; }; -- cgit v1.2.3