Esempio n. 1
0
ofxWater& ofxWater::allocate(int tWidth, int tHeight){ 
    width = tWidth; 
    height = tHeight; 
    
    pingPong.allocate(width,height);
    
    initFbo(updateFbo, width, height, GL_RGB);
    initFbo(renderFbo, width, height, GL_RGB);
}
Esempio n. 2
0
int ofxLayerMask::newLayer() {
    layers.push_back(newFbo);
    initFbo(layers.back());
    masks.push_back(newMaskFbo);
    initMaskFbo(masks.back());
    return layers.size() - 1;
}
Esempio n. 3
0
GraphDrawer::GraphDrawer(std::shared_ptr<Graph> graph, const std::vector<std::unique_ptr<GraphNodeHandler>> &nodeHandlers, ci::Area windowSize) :
    g(graph),
    nodeHandlers(nodeHandlers),
	windowSize(windowSize)
{
    initFbo(windowSize);
}
Esempio n. 4
0
void ofxGuiGroup::add(ofxBaseGui * element){
	collection.push_back( element );

	element->setPosition(b.x, b.y + b.height  + spacing);

	b.height += element->getHeight() + spacing;
    
	//if(b.width<element->getWidth()) b.width = element->getWidth();
    //cout << "adding element " << element->getName() <<endl;
	ofUnregisterMouseEvents(element);
    
	ofxGuiGroup * subgroup = dynamic_cast<ofxGuiGroup*>(element);
	if(subgroup!=NULL){
		//cout << "subgroup" << endl;
		subgroup->filename = filename;
		subgroup->parent = this;
        subgroup->setSize(b.width*defaultElementIndentation,element->getHeight());
        subgroup->setWidthElements(b.width*defaultElementIndentation);
		
	}else{
		//cout << "no subgroup" << endl;
		if(parent!=NULL){
			//cout << "parent" << endl;
            element->setSize(b.width*defaultElementIndentation,element->getHeight());
			element->setPosition(b.x + b.width-element->getWidth(),element->getPosition().y);
		}
	}
    //cout << "adding element " << element->getName() <<" width : " << element->getWidth() << " " <<b.width <<  endl;
	parameters.add(element->getParameter());
	generateDraw();
    
    initFbo();
}
Esempio n. 5
0
void Particles::setupData(){

    origintype.addListener(this,&Particles::changeOrigins);
    gradNum.addListener(this,&Particles::changeGrad);
    numParticles.addListener(this,&Particles::changeNum);
    
    initFbo();
    
    updateRender.load("shaders/render.vert","shaders/render.frag");
    updatePos.load("","shaders/posUpdate.frag");
    int defaultgrad=0;
    changeGrad(defaultgrad);

}
Esempio n. 6
0
void Particles::changeNum(int & num){
    if(num!=lastnumParticles){
        initFbo();
        lastnumParticles = num;
    }
}
Esempio n. 7
0
void Particles::initFbo(){
    initFbo(*dad->scrw,*dad->scrh);
}
Esempio n. 8
0
void Particles::update(int w, int h){
    
    if(w!=lastw||h!=lasth){
        initFbo(w, h);
    }
    
    
    
    glBlendEquation(GL_ADD);
    glBlendFunc(GL_ONE, GL_ZERO);
    
    for(int i = 0 ; i < forces.size();i++){
        if(forces[i]->isActive&&forces[i]->name.find("net")!=string::npos){

            velPingPong.dst->begin();
            forces[i]->shader.begin();
            forces[i]->shader.setUniformTexture("posData",posPingPong.src->getTextureReference(), 1);
            forces[i]->shader.setUniform3f("screen",w,h,dad->zdepth);
            forces[i]->shader.setUniform1i("resolution",textureRes);
            forces[i]->updateShader();
            
            velPingPong.src->draw(0,0);
            
            forces[i]->shader.end();
            
            velPingPong.dst->end();
            velPingPong.swap();
                
                
                
//            }
        }
        else if(forces[i]->isActive ){
            int j = 0;
            vector<ofPoint> curattr = dad->attr->getType(forces[i]->attrFamilly,1,1,forces[i]->attrZone);
            if(map2blob){
//                drawBlob * vvv = (drawBlob *)dad->get("drawBlob");
//                for(int i = 0 ; i< curattr.size();i++){
//                    if(vvv->invertx)curattr[i].x = 1-curattr[i].x;
//                    if(vvv->inverty)curattr[i].y = 1-curattr[i].y;

//                    
//                }
//            dad->sH.mapN2S(curattr,vvv->screenN);
                
                
            }
            if((forces[i]->attrFamilly>-2?curattr.size()>0:1)){
                do{
                    velPingPong.dst->begin();
                    forces[i]->shader.begin();
                    forces[i]->shader.setUniformTexture("posData",posPingPong.src->getTextureReference(), 1);
                    if(forces[i]->name=="origin") 
                        forces[i]->shader.setUniformTexture("originData",origins.getTextureReference(), 2);
                    if(forces[i]->name=="fieldForce"){
                        forces[i]->shader.setUniform2f("inres",dad->inw,dad->inh);
            #ifdef syphon
                        forces[i]->shader.setUniformTexture("fieldData",dad->pipePP.src->getTextureReference(), 2);
            #endif
                            }
                    if(forces[i]->attrFamilly>=0&&curattr.size()>0&&j<curattr.size()){
                        
                        forces[i]->shader.setUniform3f("attr",curattr[j].x,curattr[j].y,curattr[j].z+0.5);
                    }
                    forces[i]->shader.setUniform3f("screen",w,h,dad->zdepth);
                    if(origintype==1)forces[i]->shader.setUniform1i("resolution",textureRes3);
                    else forces[i]->shader.setUniform1i("resolution",textureRes);
                    forces[i]->updateShader();
                    
                    velPingPong.src->draw(0,0);
                    
                    forces[i]->shader.end();
                    
                    velPingPong.dst->end();
                    velPingPong.swap();
                            j++;
                }while( forces[i]->attrFamilly>=0&&j<curattr.size());
            }
        }
//        glEnd();
    }
    
    
    
    
    
    posPingPong.dst->begin();
    updatePos.begin();  // Previus position
    updatePos.setUniformTexture("velData", velPingPong.src->getTextureReference(), 1);      // Velocity
    updatePos.setUniform1f("timestep",timeStep*1.0/FPS );
    updatePos.setUniform1i("resolution",textureRes);
    
    posPingPong.src->draw(0,0);
    
    
    
    updatePos.end();
    posPingPong.dst->end();
    
    
    posPingPong.swap();
    
    lastw = w;
    lasth = h;
    
}
Esempio n. 9
0
void GraphDrawer::resize(ci::Area newWindowSize)
{
	windowSize = newWindowSize;
    initFbo(newWindowSize);
}