void RDirNode::drawFiles(Frustum &frustum, float dt) { if(frustum.boundsInFrustum(quadItemBounds)) { vec4f col = getColour(); glPushMatrix(); glTranslatef(pos.x, pos.y, 0.0); //draw files for(std::list<RFile*>::iterator it = files.begin(); it!=files.end(); it++) { RFile* f = *it; if(f->isHidden()) continue; f->draw(dt); } glPopMatrix(); } glDisable(GL_TEXTURE_2D); for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) { RDirNode* node = (*it); node->drawFiles(frustum,dt); } }
vec3f RDirNode::averageFileColour() { vec3f av; int count = 0; for(std::list<RFile*>::iterator it = files.begin(); it != files.end(); it++) { RFile* file = (*it); if(file->isHidden()) continue; av += file->getColour(); count++; } if(count>0) av *= (1.0f/(float)count); count = 0; for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end();it++) { RDirNode* child = (*it); av += child->averageFileColour(); count++; } if(count>0) av *= (1.0f/(float)count); return av; }
void RDirNode::drawFiles(float dt) const{ if(in_frustum) { vec4f col = getColour(); glPushMatrix(); glTranslatef(pos.x, pos.y, 0.0); //draw files for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) { RFile* f = *it; if(f->isHidden()) continue; f->draw(dt); } glPopMatrix(); } for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) { RDirNode* node = (*it); node->drawFiles(dt); } }
void RDirNode::updateFilePositions() { int max_files = 1; int diameter = 1; int file_no = 0; float d = 0.0; float max_size_during_cycle = 0; int files_left = visible_count; files.sort(sortBySize); for(std::list<RFile*>::iterator it = files.begin(); it!=files.end(); it++) { RFile* f = *it; if(f->isHidden()) { f->setDest(vec2(0.0,0.0)); f->setDistance(0.0f); continue; } vec2 dest = calcFileDest(max_files, file_no); f->setDest(dest); f->setDistance(d); files_left--; file_no++; if(max_size_during_cycle < f->size) { max_size_during_cycle = f->size; } if(file_no >= max_files) { diameter++; d += max_size_during_cycle; max_files = (int) std::max(1.0, diameter*PI); if(files_left<max_files) { max_files = files_left; } file_no = 0; max_size_during_cycle = gGourceFileDiameter; } } file_area = d + max_size_during_cycle; }
void RDirNode::updateFilesVBO(quadbuf& buffer, float dt) const{ if(in_frustum) { for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) { RFile* f = *it; if(f->isHidden()) continue; vec3 col = f->getColour(); float alpha = f->getAlpha(); buffer.add(f->graphic->textureid, f->getAbsolutePos() - f->dims*0.5f, f->dims, vec4(col.x, col.y, col.z, alpha)); } } for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) { RDirNode* node = (*it); node->updateFilesVBO(buffer,dt); } }
void RDirNode::updateFilePositions() { int max_files = 1; int diameter = 1; int file_no = 0; int files_left = visible_count; for(std::list<RFile*>::iterator it = files.begin(); it!=files.end(); it++) { RFile* f = *it; if(f->isHidden()) { f->setDest(vec2f(0.0,0.0)); f->setDistance(0.0f); continue; } vec2f dest = calcFileDest(max_files, file_no); float d = ((float)(diameter-1)) * gGourceFileDiameter; f->setDest(dest); f->setDistance(d); files_left--; file_no++; if(file_no>=max_files) { diameter++; max_files = (int) std::max(1.0f, diameter*PI); if(files_left<max_files) { max_files = files_left; } file_no=0; } } }
void RDirNode::calcColour() { // make branch brighter if recently accessed float brightness = std::max(0.6f, 1.0f - std::min(1.0f, since_last_node_change / 3.0f)); col = vec4f(brightness, brightness, brightness, 1.0); int fcount = 0; for(std::list<RFile*>::iterator it = files.begin(); it != files.end(); it++) { RFile* file = (*it); if(file->isHidden()) continue;; vec3f filecol = file->getColour() * brightness; float a = file->getAlpha(); col += vec4f(filecol.x, filecol.y, filecol.z, a); fcount++; } this->col /= (float) fcount + 1.0f; }
void RDirNode::printFiles() { for(std::list<RFile*>::iterator it = files.begin(); it != files.end(); it++) { RFile* file = (*it); fprintf(stderr, "%s: %s %s\n", getPath().c_str(), file->fullpath.c_str() , file->isHidden() ? "hidden " : ""); } }