void XBScene1::initParticles()
{
    XBScene1GUI *myGUI = (XBScene1GUI *) gui;

    emitParticles = false;
    vEmitter.setPosition(ofVec3f(ofGetWidth() / 2, ofGetHeight() / 2));
    vEmitter.setVelocity( ofVec3f(myGUI->particleVelocity->x, myGUI->particleVelocity->y, 0));
    vEmitter.velSpread = ofVec3f(myGUI->particleSpread, myGUI->particleSpread,0);
    vEmitter.life = myGUI->particleLife;
    vEmitter.lifeSpread = 5.0;
    vEmitter.numPars = myGUI->numParticles;
    vEmitter.color = ofColor(myGUI->rgbColorViolinR, myGUI->rgbColorViolinG, myGUI->rgbColorViolinB, myGUI->colorViolinA);
    vEmitter.size = myGUI->particleSize;

    xEmitter.setPosition(ofVec3f(ofGetWidth() / 2, ofGetHeight() / 2));
    xEmitter.setVelocity( ofVec3f(myGUI->particleVelocity->x, myGUI->particleVelocity->y, 0));
    xEmitter.velSpread = ofVec3f(myGUI->particleSpread, myGUI->particleSpread,0);
    xEmitter.life = myGUI->particleLife;
    xEmitter.lifeSpread = 5.0;
    xEmitter.numPars = 20;
    xEmitter.color = ofColor(myGUI->rgbColorCelloR, myGUI->rgbColorCelloG, myGUI->rgbColorCelloB, myGUI->colorCelloA);
    xEmitter.size = myGUI->particleSize;

    ofLoadImage(pTex, "resources/img/particle.png");
    pTex.setAnchorPercent(0.5, 0.5);
    
    ofLoadImage(headTexture, "resources/img/particle_3_head.png");
    headTexture.setAnchorPercent(0.5, 0.5);
}
Exemple #2
0
void ofxInkSim::setup(int width, int height,
                      string grainPath, string alumPath, string pinningPath)
{
    this->width = width;
    this->height = height;
    
    ofDisableArbTex();
    
    pxSize = ofVec2f::one() / ofVec2f(width, height);
    offset = pxSize;
    
    ofLoadImage(grain, grainPath);
    ofLoadImage(alum, alumPath);
    ofLoadImage(pinning, pinningPath);
    ofFbo::Settings settings;
    settings.width = width;
    settings.height = height;
    settings.textureTarget = GL_TEXTURE_2D;
    settings.internalformat = GL_RGBA32F_ARB;
    screen.allocate(settings);
    depositionBuffer.allocate(settings);
    disorder.allocate(settings);
    surfInk.allocate(settings);
    misc.allocate(settings);
    velDen.allocate(settings);
    flowInk.allocate(settings);
    fixInk.allocate(settings);
    dist1.allocate(settings);
    dist2.allocate(settings);
    sinkInk.allocate(settings);
    
    depositionBuffer.begin();
    ofClear(0, 0);
    depositionBuffer.end();
    
    disorder.begin();
    ofClear(0, 0);
    disorder.end();
    
    // make disorder buffer
    fillDisorderBuffer();
    
    drawMode = INKFIX;
    
    ofEnableArbTex();
    
    // debug
    bDebug = false;
}
void ofxImageSequence::loadFrame(int imageIndex)
{
	if(lastFrameLoaded == imageIndex){
		return;
	}

	if(imageIndex < 0 || imageIndex >= sequence.size()){
		ofLogError("ofxImageSequence::loadFrame") << "Calling a frame out of bounds: " << imageIndex;
		return;
	}

	if(!sequence[imageIndex].isAllocated() && !loadFailed[imageIndex]){
		if(!ofLoadImage(sequence[imageIndex], filenames[imageIndex])){
			loadFailed[imageIndex] = true;
			ofLogError("ofxImageSequence::loadFrame") << "Image failed to load: " << filenames[imageIndex];
		}
	}

	if(loadFailed[imageIndex]){
		return;
	}

	texture.loadData(sequence[imageIndex]);

	lastFrameLoaded = imageIndex;
    
    if (imageIndex > 10){
        sequence[imageIndex - 10].clear();
    }

}
void ofxImageSequence::preloadAllFrames()
{
	if(sequence.size() == 0){
		ofLogError("ofxImageSequence::loadFrame") << "Calling preloadAllFrames on unitialized image sequence.";
		return;
	}
	
	for(int i = 0; i < sequence.size(); i++){
		//threaded stuff
		if(useThread){
			if(threadLoader == NULL){
				return;
			}
            threadLoader->lock();
            bool shouldExit = threadLoader->cancelLoading;
            threadLoader->unlock();
            if(shouldExit){
                return;
            }

			ofSleepMillis(15);
		}
		curLoadFrame = i;
		if(!ofLoadImage(sequence[i], filenames[i])){
			loadFailed[i] = true;
			ofLogError("ofxImageSequence::loadFrame") << "Image failed to load: " << filenames[i];		
		}
	}
}
Exemple #5
0
	void Camera::update() {
		if(connected){
#ifdef TARGET_OSX
			if (bTryInitLiveView) {
				if (ofGetElapsedTimeMillis() - initTime > OFX_EDSDK_LIVE_DELAY) {
					bTryInitLiveView = false;
					resetLiveView();
				}
			}
#endif
		lock();
		if(liveBufferMiddle.size() > 0) {
			// decoding the jpeg in the main thread allows the capture thread to run in a tighter loop.
			ofBuffer* middleFront = liveBufferMiddle.front();
			liveBufferFront.set(middleFront->getBinaryBuffer(), middleFront->size());
			liveBufferMiddle.pop();
			unlock();
			ofLoadImage(livePixels, liveBufferFront);
            livePixels.rotate90(rotateMode90);
			if(liveTexture.getWidth() != livePixels.getWidth() ||
				 liveTexture.getHeight() != livePixels.getHeight()) {
				liveTexture.allocate(livePixels.getWidth(), livePixels.getHeight(), GL_RGB8);
			}
			liveTexture.loadData(livePixels);
			lock();
			liveDataReady = true;
			frameNew = true;
			unlock();
		} else {
			unlock();
		}
		}
	}
void CloudsVisualSystemCities::selfSetup()
{
    size = 100;
    resolution = 1;
    blockSize = 1;

    grayscottLoops = 10;
    nPingPong = 0;
    diffU=0.25;
    diffV=0.04;
    k=0.047;
    f=0.2;
    
    //  Noise
    //
    noiseShader.load("", getVisualSystemDataPath()+"shaders/noise.fs");
    
    //  GrayScott
    //
    grayscottShader.load("", getVisualSystemDataPath()+"shaders/grayscott.fs");
    
    //  Mask
    //
    maskShader.load("", getVisualSystemDataPath()+"shaders/cMask.fs");
    
    //  Points
    //
    makeGrid(100, 10);
    
    //  Post
    //
    postShader.load("",getVisualSystemDataPath()+"shaders/postprocess.fs");
    ofLoadImage(postTexture, getVisualSystemDataPath()+"images/6.jpg");
}
void ofxScrollable::load(string path, float w, float h, float f){
    width = w;
    height = h;
    
    ofFbo::allocate(width,height,GL_RGBA32F_ARB);
    
    ofPixels imagePixels;
    ofLoadImage(imagePixels, path);
    texWidth = imagePixels.getWidth();
    texHeight = imagePixels.getHeight();
    tex.loadData(imagePixels);
    tex.setAnchorPercent(0.5,0.0);
    
    fadeSize = f;
    ofFloatPixels fadePixels;
    fadePixels.allocate(width,fadeSize,OF_PIXELS_RGBA);
    int i=0;
    for(int y=0;y<(int)fadeSize;y++) {
        for(int x=0;x<(int)width;x++){
            fadePixels[i+0]=0.;
            fadePixels[i+1]=0.;
            fadePixels[i+2]=0.;
            fadePixels[i+3]=1.-(y*y)/(fadeSize*fadeSize); //QUADRATIC_EASE_IN
            i+=4;
        }
    }
    fade.loadData(fadePixels);
    time = ofGetElapsedTimef();
}
Exemple #8
0
//--------------------------------------------------------------
void ofApp::update(){

    if(client.connected) {
        // send a ping message
        string pingMessage = "ping";
        bool sentPing = client.sendMessage(pingMessage);
        if(sentPing) {
            
            // receive a header message
            string replyHeader; // this will contain the size in bytes of the image buffer
            bool receivedReply = client.receiveMessage(replyHeader, TCPPOCO_DEFAULT_MSG_SIZE);
            
            if(receivedReply) {
                
                // receive the image buffer in 2 steps
                ofBuffer buffer;
                bool receivedBufferReply = client.receiveRawBuffer(buffer, ofToInt(replyHeader));
                if(receivedBufferReply) {
                    ofLoadImage(image, buffer);
                    bufferSize = buffer.size();
                }
            }
        }
    }     

}
Exemple #9
0
void ofApp::setup()
{
    ditherThreshold.addListener(this, &ofApp::ditherChanged);
    ditherQuantWeight.addListener(this, &ofApp::ditherChanged);

    gui.setup();
    gui.add(ditherThreshold.setup("dither threshold", 0.75, 0, 1));
    gui.add(ditherQuantWeight.setup("dither quant. weight", 0.125, 0, 1));

    std::filesystem::path path = ofToDataPath("puppy.jpg", true);

    bool success = ofxIO::ImageUtils::loadHeader(header, path);

    if (!success)
    {
        ofLogError() << "Unable to load header from image.";
    }

    ofLoadImage(originalPix, path);
    originalTex.loadData(originalPix);

    grayscalePix = ofxIO::ImageUtils::toGrayscale(originalPix);
    grayscaleTex.loadData(grayscalePix);




    ofSetWindowShape(originalPix.getWidth() * 2,
                     originalPix.getHeight() * 2);
}
Exemple #10
0
GLuint ofxImGui::loadPixels(string imagePath)
{
    if(!engine) return -1;
    ofPixels pixels;
    ofLoadImage(pixels, imagePath);
    return loadPixels(pixels);
}
// selfSetup is called when the visual system is first instantiated
// This will be called during a "loading" screen, so any big images or
// geometry should be loaded here
void CloudsVisualSystemFlocking::selfSetup()
{    
    debugGridSize = 4096;
    ps = new ofxBoidSystem();
    pointSize = 5.0;
    
    redColor = 1.0;
    greenColor = 0.0;
    blueColor = 0.0;
    bUpdateVel = true;
    bUpdateAcc = true;
    bUpdatePos = true;

    resolution = 72;
    rows = resolution;
    cols = resolution;
    
    ofDisableArbTex();
    ofLoadImage(glow, getVisualSystemDataPath()+"images/glow.png");
    spriteSize = glow.getWidth();
    cout << spriteSize << endl;
    ofEnableArbTex();
    
    loadShaders();
    setupFbos();
    setupVbo();
}
Exemple #12
0
void Material::loadMipMapTexture(string inPath, float inAnisotropy ) {
    ofPixels pix;
    ofLoadImage(pix, inPath);

    _tex.allocate( pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix) );

    ofTextureData& texData = _tex.texData;

    if (texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB){
        texData.tex_t = pix.getWidth();
        texData.tex_u = pix.getHeight();
    } else {
        texData.tex_t = (float)(pix.getWidth()) / (float)texData.tex_w;
        texData.tex_u = (float)(pix.getHeight()) / (float)texData.tex_h;
    }

    ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),pix.getNumChannels());

    glBindTexture( texData.textureTarget, texData.textureID);
    glTexImage2D( texData.textureTarget, 0, texData.glTypeInternal, pix.getWidth(), pix.getHeight(), 0, ofGetGlFormat(pix), ofGetGlType(pix), pix.getPixels());
    glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(texData.textureTarget);
    glGenerateMipmap(texData.textureTarget);
    glTexParameteri( texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri( texData.textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

    // 1 means it does nothing
    if( inAnisotropy >= 1 ) {
        glTexParameterf( texData.textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, (GLfloat)inAnisotropy);
    }

    glDisable( texData.textureTarget );
}
Exemple #13
0
//--------------------------------------------------------------
void ofApp::setup(){
    
#ifdef TARGET_OPENGLES
    shaderBlurX.load("shadersES2/shaderBlurX");
    shaderBlurY.load("shadersES2/shaderBlurY");
#else
	if(ofIsGLProgrammableRenderer()){
        std::cout << "load GL3\n" << "\n";
		shaderBlurX.load("shadersGL3/shaderBlurX");
        shaderBlurY.load("shadersGL3/shaderBlurY");
	}else{
        std::cout << "load GL2\n" << "\n";
		shaderBlurX.load("shadersGL2/shaderBlurX");
        shaderBlurY.load("shadersGL2/shaderBlurY");
	}
#endif

    ofLoadImage(image, "img.jpg");
    
    fboBlurOnePass.allocate(image.getWidth(), image.getHeight());
    fboBlurTwoPass.allocate(image.getWidth(), image.getHeight());
    
//    fboBlurOnePass.allocate(ofGetWidth(), ofGetHeight());
//    fboBlurTwoPass.allocate(ofGetWidth(), ofGetHeight());
}
void SingleBrush::selfSetup(){
    ofSetCircleResolution(36);
    ofEnableAlphaBlending();
    ofDisableSmoothing();

    ofSetFullscreen(true);
    
    video.initGrabber(640, 480);
    
    colorAddShader.loadFrag(getDataPath()+"shaders/colorAdd.frag");
    noiseShader.loadFrag(getDataPath()+"shaders/noise.frag");
    absorveShader.loadFrag(getDataPath()+"shaders/absorve.frag");
    displaceShader.loadFrag(getDataPath()+"shaders/displace.frag");
    edge.loadFrag(getDataPath()+"shaders/edge.frag");
    
    ofDisableArbTex();
    ofLoadImage(brushTexture, getDataPath()+"brush.png");
    ofEnableArbTex();
    
    int width = ofGetScreenWidth();
    int height = ofGetScreenHeight();
    colorAdded.allocate(width,height);
    water.allocate(width, height,GL_RGB);
    flow.allocate(width, height);
    noise.allocate(width,height);
    canvas.allocate(width, height);
    edgeFbo.allocate(640, 480);
    
    bColorSample = true;
    
    color.set(0);
}
Exemple #15
0
void ofApp::loadImage(const char* name)
{
    ofPixels pix;
    ofLoadImage(pix, name);
    
    int height = pix.getHeight();
    int width = pix.getWidth();
    
    //now we have an empty 2D-matrix of size (0,0). Resize it with one single command:
    faceMatrix.resize(height, vector<float>(width ,0.0));
    
    //Build "distribution array" of brightness
    float sumBrightness = 0;
    for (int y=0; y<height; y++) {
        for (int x=0; x<width; x++) {
            float brightness = pix.getColor(x, y).getBrightness();
            faceMatrix[y][x] = brightness;
            sumBrightness += brightness;
        }
    }
    for (int y=0; y< height; y++) {
        for (int x=0; x< width; x++) {
            faceMatrix[y][x] = faceMatrix[y][x] / sumBrightness;
        }
    }
}
void KinectManager::fileReader(){
    
    if(ofGetElapsedTimeMillis() - lastFileReadMillis > fileReadInterval){
        
        lastFileReadMillis = ofGetElapsedTimeMillis();
        
        string path = folderName + depthName + ofToString(fileCount) + ".png";
    //    ofLog() << "reading from " << path;
        
        ifstream ifile(path.c_str());
        
        if (ifile) { //only load image if the image really exists
            ofLoadImage(depthPix, path);
            fileCount ++;
            frameCount ++;
        }else{
            fileCount = 0;
    //        ofLog() << "end of sequence, starting over";
        }
        
    }
    
    
    
}
//--------------------------------------------------------------
void ofApp::setup(){
		ofBackgroundHex(0x000000);

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofDisableArbTex();

	int camDist  = 100;
	camera.setDistance(camDist);


	ofLoadImage(texture, "dot.png");

	int total = (int)swarm.positions.size();
	vbo.setVertexData(&swarm.positions[0], total, GL_STATIC_DRAW);
	vbo.setNormalData(&swarm.sizes[0], total, GL_STATIC_DRAW);


		// load the shader
	#ifdef TARGET_OPENGLES
		cout << "shader" << endl;
        shader.load("shaders_gles/shader");
	#else
   		cout << "shader2" << endl;
        shader.load("shaders/shader");
    #endif
}
bool StopMotionController::load(const string &dirPath)
{
    mFrames.clear();
    
    ofDirectory dir;
    if (dir.listDir(dirPath) == 0) return false;
    for (auto innerData : dir)
    {
        ofLogNotice() << "load: " << dir.path();
        if (innerData.isDirectory())
        {
            ofDirectory innerDir;
            innerDir.listDir(innerData.path());
            mFrames.push_back(ofPtr<Frame>(new Frame()));
            vector<ofPixels> *imageArray = &mFrames.back()->imageArray;
            for (auto innerFile : innerDir)
            {
                imageArray->push_back(ofPixels());
                if (ofLoadImage(imageArray->back(), innerFile.getAbsolutePath()) == false)
                {
                    ofLogError() << "failed load image: " << innerFile.path();
                    imageArray->pop_back();
                }
                ofLogNotice() << "load image: " << innerFile.path();
            }
            if (imageArray->empty() == false) mFrames.back()->currentIndex = 0;
        }
    }
    if (mFrames.empty()) return false;
    mCurrentFrame = mFrames[0].get();
    return true;
}
Exemple #19
0
	ofPixels& Camera::getPhotoPixels() {
		if(needToDecodePhoto) {
			ofLoadImage(photoPixels, photoBuffer);
			needToDecodePhoto = false;
		}
		return photoPixels;
	}
void Model::setup()
{
    nInstance = 500;
    
    for (int i = 0; i < nInstance; i++)
    {
        InstanceData id;
        id.setup(i);
        instanceDatas.push_back(id);
    }
    
    shader.load("shader/astroBoy");
    
    loader.loadModel("model/astroBoy_walk.dae", true);
    loader.setPosition(0, 0, 0);
    loader.setScale(0.5, 0.5, 0.5);
    loader.setRotation(0, 180, 1, 0, 0);
    ofLoadImage(diffuseTex, "model/texss/red.tga");
    modelMatrix = loader.getModelMatrix();
    
    genMeshPieces();
    bindBoneIDAndWeightToAttribute();
    populateEveryAnimationMatrix();
    
    modelTransTexture.allocate(nInstance * 4, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT);
}
//--------------------------------------------------------------
void ofApp::setup(){
    ofLoadImage(imageTexture, "pixelSun.png");
    
    points[0].x = 100; points[0].y = 100;
    points[1].x = 600; points[1].y = 100;
    points[2].x = 600; points[2].y = 600;
    points[3].x = 100; points[3].y = 600;
}
void ofxSwipeable::load(vector<string> path, float w, float h, float f){
    vector<ofPixels> pix;
    pix.assign(path.size(),ofPixels());
    for(int i=0;i<path.size();i++){
        ofLoadImage(pix[i], path[i]);
    }
    load(pix,w,h,f);
}
Exemple #23
0
//--------------------------------------------------------------
void ofApp::setup(){

    ofDisableArbTex();
    ofLoadImage(tex, "heightmap.png");
    ofEnableArbTex();
    
    shader.load("","shader.frag");
}
Exemple #24
0
 ofPixels& Camera::getPhotoPixels() {
     if(needToDecodePhoto) {
         ofLoadImage(photoPixels, photoBuffer);
         photoPixels.rotate90(orientationMode);
         needToDecodePhoto = false;
     }
     return photoPixels;
 }
Exemple #25
0
//--------------------------------------------------------------
void ofApp::setup(){
    gui.setup("gui", "setting.xml");
    gui.add(enabled.setup("shader", false));
    gui.add(val.setup("val", 8.0, 1.0, 20.0));
    ofLoadImage(image, "img.jpg");
    shader.load("laplacian");
    fbo.allocate(ofGetWidth(), ofGetHeight());
    
}
void TexFlow::setup()
{
    cni = ofPtr<CurlNoiseInstanced>(new CurlNoiseInstanced());
    cni->setup(true, 32);
    
    ofDisableArbTex();
    ofLoadImage(Globals::testTex, "imgs/deform/23e.png");
    ofEnableArbTex();
}
//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, const std::string& path, const ofImageLoadSettings &settings){
	ofPixels pixels;
	bool loaded = ofLoadImage(pixels, path, settings);
	if(loaded){
		tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
		tex.loadData(pixels);
	}
	return loaded;
}
Exemple #28
0
GLuint ofxImGui::loadTexture(string imagePath)
{
    ofDisableArbTex();
    ofTexture* texture  = new ofTexture();
    ofLoadImage(*texture, imagePath);
    ofEnableArbTex();
    loadedTextures.push_back(texture);
    return texture->getTextureData().textureID;
}
//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, string path){
	ofPixels pixels;
	bool loaded = ofLoadImage(pixels,path);
	if(loaded){
		tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
		tex.loadData(pixels);
	}
	return loaded;
}
//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, const ofBuffer & buffer){
	ofPixels pixels;
	bool loaded = ofLoadImage(pixels,buffer);
	if(loaded){
		tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
		tex.loadData(pixels);
	}
	return loaded;
}