Ejemplo n.º 1
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofBackground(0);
    ofSetDepthTest(true);
    //  ofSetBackgroundAuto(false);
    
    cam.setPosition(0, 0, 1000);
    cam.lookAt( ofVec3f( 0, 0, 0 ), ofVec3f( 0, 1, 0 ) );
    
    //
    sampleRate = 44100;
    amp = 0.5;
    pan = 0.5;
    phase = 0;
    frequency = 440;
    
    //  inputバッファーサイズ
    bufSize = 256;
    
    left = new float[bufSize];
    right = new float[bufSize];
    
    ofSetVerticalSync(true);  //垂直同期信号のon/off(よくわからん)
    nBandsToGet = 1024;
    
    //  out 0, in 2
    ofSoundStreamSetup(0,2);   //  サウンドストリームの準備、左右2ch
    
    //;
    _left.init( bufSize );
    _right.init( bufSize );
    
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void testApp::setup(){

    ofSetFrameRate(30);
    ofSetDepthTest(true);
    state = 3;
    
    aa.playStems(0);
    cs.setup();
    cs.gui->setVisible(false);
    
//    vector<ofFloatColor> colors;
//    for (int i = 0; i < 13; i++) {
//        colors.push_back(ofFloatColor(ofRandomuf()));
//    }
    
//    for (int i = 0; i < 13; i++) {
//        cs.addColorRef(&colors[i]);
//    }
    
    cs.assignRandom(true);
    
    tm.setup(&aa, &cs);
    cm.setup(&tm);
    lm.setup(&cs);
    pm.setup();
    
    useLights = true;
    
    setupGUI();
    
    isShaderDirty = true;
    
	mLigDirectional.setup();
	mLigDirectional.setDirectional();
    

	mLigDirectional.setAmbientColor(ofColor::fromHsb(100, 0, 100));
	mLigDirectional.setDiffuseColor(ofColor::fromHsb(20, 120, 128));
	mLigDirectional.setSpecularColor(ofColor(255,255,255));
	
	mMatMainMaterial.setDiffuseColor(ofColor(0,0,0));
	mMatMainMaterial.setSpecularColor(ofColor(200,200,200));
	mMatMainMaterial.setShininess(64.0f);
	
    
    mCamMainCam.setupPerspective(false);
    cm.cam.setupPerspective(false);
    
	mCamMainCam.setDistance(200);
//	cm.cam.setDistance(200);
	
    updateCam = false;

	shouldRenderNormals = false;
	shouldUseFlatShading = false;

}
Ejemplo n.º 3
0
void ofxRParticleRenderer::activateBlending()
{
    if(*bAdditiveBlending)
    {
        ofEnableBlendMode(OF_BLENDMODE_ADD);
    }
    else
    {
        ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    }
    ofSetDepthTest(*bDepthTesting);
}
Ejemplo n.º 4
0
void ofxUIBaseDraws::drawFill()
{
    ofSetDepthTest(false);
    if(draw_fill)
    {
        if(image != NULL)
        {
            ofFill();
            ofSetColor(255);
            image->draw(rect->getX(), rect->getY(), rect->width, rect->height);
        }
    }
}
Ejemplo n.º 5
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    ofBackground(51,51,51);
    ofSetDepthTest(true);
    ofEnableSmoothing();
    
    //  ofEnableDepthTest();
    
    light.enable();
    light.setSpotlight();
    light.setPosition(-100, 100, 100);
    light.setAmbientColor( ofFloatColor(0.5,0.2,0.32,1.0) );
    light.setDiffuseColor( ofFloatColor(0.5,0.5,1.0) );
    light.setSpecularColor( ofFloatColor( 1.0, 1.0, 1.0) );
    
    
    for( int i = 0; i < 200; i++ )
    {
        for( int j = 0; j < 200; j++ )
        {
            mesh.addColor(ofFloatColor(0.5, 0.8, 1.0 ) );
        }
    }
}
Ejemplo n.º 6
0
void ofApp::drawScene(int sceneIndex, bool flush) {
    sceneBuffer.begin();
    
    // Enable depth testing.
    ofSetDepthTest(true);
    
    ofBackground(0, 0, 0);
    
    if (sceneIndex == 1) {
        // Draw ship.
        ofVec3f finalPosition = modelPosition + 10.f * modelPerturbation;
        ofPushMatrix();
        ofTranslate(finalPosition.x, finalPosition.y, finalPosition.z);
        ofRotate(modelRotation.x, 0, 0, 1);
        ofSetColor(255, 0, 255, 255);
        ship.draw();
        ofSetColor(255, 255, 255, 255);
        ofPopMatrix();
        
        // Draw tunnel chunks.
        static int count = 0;
        float frequency = 0.01;
        float red = sin(frequency * count + 0) * 127 + 128;
        float green = sin(frequency * count + 2) * 127 + 128;
        float blue = sin(frequency * count + 4) * 127 + 128;
        ofColor tunnelColor(red, green, blue);
        for (int i = 0; i < tunnelChunks.size(); i++) {
            ofPushMatrix();
            ofTranslate(0, 0, -5000.f * tunnelChunks[i].getAgePercent() + 200.f);
            ofColor color = tunnelColor * (1.f - tunnelChunks[i].getAgePercent());
            ofSetColor(color);
            tunnelChunks[i].draw();
            ofSetColor(255, 255, 255, 255);
            ofPopMatrix();
        }
        count++;
        
        // Draw road chunks.
        for (int i = 0; i < roadChunks.size(); i++) {
            ofPushMatrix();
            ofTranslate(0, 0, -5000.f * roadChunks[i].getAgePercent() + 200.f);
            if (flush) {
                ofEnableAlphaBlending();
                ofSetColor(0, 200.f * (1.f - roadChunks[i].getAgePercent()), 255.f * (1.f - roadChunks[i].getAgePercent()), 20);
                roadChunks[i].setMode(OF_PRIMITIVE_TRIANGLE_FAN);
                roadChunks[i].draw();
                ofSetColor(255, 255, 255, 255);
                ofDisableAlphaBlending();
            }
            ofSetColor(0, 200.f * (1.f - roadChunks[i].getAgePercent()), 255.f * (1.f - roadChunks[i].getAgePercent()), 255);
            roadChunks[i].setMode(OF_PRIMITIVE_LINE_LOOP);
            roadChunks[i].draw();
            ofSetColor(255, 255, 255, 255);
            ofPopMatrix();
        }
        
        // Draw boxes.
        for (int i = boxes.size() - 1; i >= 0; i--) {
            ofPushMatrix();
            ofTranslate(0, 0, -5000.f * boxes[i].getAgePercent() + 200.f);
            if (flush) {
                ofEnableAlphaBlending();
                ofSetColor(255.f * (1.f - boxes[i].getAgePercent()), 200.f * (1.f - boxes[i].getAgePercent()), 0, 20);
                boxes[i].setMode(OF_PRIMITIVE_TRIANGLE_FAN);
                boxes[i].draw();
                ofSetColor(255, 255, 255, 255);
                ofDisableAlphaBlending();
            }
            ofSetColor(200.f * (1.f - boxes[i].getAgePercent()), 200.f * (1.f - boxes[i].getAgePercent()), 0, 255);
            boxes[i].setMode(OF_PRIMITIVE_LINE_LOOP);
            boxes[i].draw();
            ofSetColor(255, 255, 255, 255);
            ofPopMatrix();
        }
    }
    else {
        // Draw instantaneous sound signal.
        ofSetColor(0, 255, 0, 255);
        timeMesh.draw();
        ofSetColor(255, 255, 255, 255);
        
        // Draw Fourier transformed signal.
        for (int i = 0; i < frequencyMeshes.size(); i++) {
            ofPushMatrix();
            ofTranslate(0, 0, -500.f * (1.f - frequencyMeshes[i].getAgePercent()));
            ofSetColor(0, 200.f * frequencyMeshes[i].getAgePercent(), 255.f * frequencyMeshes[i].getAgePercent(), 255);
            frequencyMeshes[i].draw();
            ofSetColor(255, 255, 255, 255);
            ofPopMatrix();
        }
    }
    
    // Disable depth testing.
    ofSetDepthTest(false);
    
    sceneBuffer.end();
    
    // Draw contents of framebuffer to output.
    if (flush) {
        sceneBuffer.getTextureReference().draw(0, 0, windowWidth, windowHeight);
    }
}