summaryrefslogtreecommitdiff
path: root/offsetProject/src/ofApp.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2014-02-20 23:37:25 +0000
committerComment <tim@gray.(none)>2014-02-20 23:37:25 +0000
commitd07c0df6a9836376f93853c64e06b3daa03c12f1 (patch)
treeddba71bdd5bf4c4e09548d2fd0e2fa4c636b38c3 /offsetProject/src/ofApp.cpp
parent7bcc9dccf8dd50ff95aea8e461b7eb5e491c0707 (diff)
making recursive descender
Diffstat (limited to 'offsetProject/src/ofApp.cpp')
-rw-r--r--offsetProject/src/ofApp.cpp36
1 files changed, 35 insertions, 1 deletions
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;i<colourTiles[levels-1].getWidth();i++){
+ for (int j=0;j<colourTiles[levels-1].getHeight();j++){
+ int level=0;
+
+ if (depthTiles[level].getPixels()[((i*level)*depthTiles[level].getHeight())+(j*level)]>level*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);