OpenFrameworks boid demo

Posted by Nikolaus Gradwohl Thu, 19 Aug 2010 02:42:45 GMT

I made a small boids demo in openframeworks. It is more or less a port of the boids demo i made in processing a while ago.

It's bin a while since i wrote c++ the last time, so i'm pretty sure i have forgotten to free some memory or have done something very unc++y :-)

of boids

Read more...

Tags , ,  | no comments

Tweet This! submit to reddit Digg!

feeling watched in openframeworks

Posted by Nikolaus Gradwohl Mon, 06 Apr 2009 04:47:00 GMT

I wrote another little app in openframeworks today to test of006 which came out a couple of days ago.

i always liked those little xeyes apps (and all its windows, mac, whatever clones) so i took it to the extrem and made a LOT of them - feel beeing watched :-)

eyes

Read more...

Tags ,  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

osc app using openframeworks

Posted by Nikolaus Gradwohl Fri, 06 Mar 2009 03:21:00 GMT

I have written a little demo app in openframeworks that shows how to react to osc events. Openframeworks uses ofxOsc as OSC library, which comes preinstalled in the FAT distribution.

the programm shows a square on a black background. the gray level of the square can be adjusted by sending osc messages to port 1234.

the following little ruby program sets the color to #808080

require 'osc'
msg = OSC::Message.new("/color", "i", 128 )
c = OSC::UDPSocket.new
c.send( msg, 0, "localhost", 1234 )

in the 'setup' method a osc receiver is initalized, and in the 'update' method, the messages are fetched from a queue and parsed.

I didn't generate any real complex osc messages for now, but as far as i can tell it is a very nice osc framework.

Read more...

Tags , ,  | no comments | no trackbacks

Tweet This! submit to reddit Digg!

rotating box in openframeworks

Posted by Nikolaus Gradwohl Mon, 29 Sep 2008 17:17:00 GMT

I tried to write something simmilar to my neonbox-demo in openframeworks. At first a have been a bit puzzled because there is no rotate command.

Then i remembered that openframeworks uses OpenGL for drawing so glRotatef and glTranslatef can be used for rotating the image

    ...
int ang = 0;

void testApp::setup(){
    ofSetVerticalSync( true );
    ofSetFrameRate( 25 );
}

void testApp::draw(){
    int width = ofGetWidth() / 2;
    int height = ofGetHeight() / 2;

    ofBackground( 0,0,0 );
    glPushMatrix();
    glTranslatef( width, height, 0 );
    glRotatef( ang , 0, 0, 1);

    ang++;
    if (ang == 360) {
        ang = 0;
    }

    ofFill();
    ofSetColor( 255 * ( 1 + sin( ang * 2 * PI / 360 )) / 2, 
        255 * ( 1 + sin( PI + ang * 2 * PI / 360 )) / 2, 0 );

    ofRect(  -300,  -50, 100, 100 );
    ofRect(  -100,  -100, 200, 200 );
    ofRect(  200,  -50, 100, 100 );


    glPopMatrix();
}
    ...

This time i also made a little screenshot for those who don't have openframeworks installed (yet :-) )

screenshot

Tags ,  | no comments

Tweet This! submit to reddit Digg!

OpenFrameworks Demo

Posted by Nikolaus Gradwohl Sun, 20 Jul 2008 18:02:00 GMT

this weekend i have written a little c++ program with openframeworks. This is a framework for writing creative programs. it is heavily inspired by processing.

While still in the prerelease state it has some very interesting features and it is realy fun to code with. To get to the download page one has to register for the mailinglist.

To get started copy the emptyExample folder from the apps/examples folder. in the src folder is a empty testApp.cpp and a testApp.h.

the program i have written draws little yellow squares on the screen, that get scared when they hear a sudden loud noise.

my testApp.h looks like this

#ifndef _TEST_APP
#define _TEST_APP


#include "ofMain.h"
#include "ofAddons.h"

class testApp : public ofSimpleApp{

    public:

        void setup();
        void update();
        void draw();

        void keyPressed(int key);
        void keyReleased(int key);
        void mouseMoved(int x, int y );
        void mouseDragged(int x, int y, int button);
        void mousePressed(int x, int y, int button);
        void mouseReleased();
        void audioReceived( float *input, int bufferSize, int nChannels );

        int boom;
};

#endif

my testApp.cpp looks like this

#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
    boom = 0;
    ofSetVerticalSync( true );
    ofSetFrameRate( 25 );
    ofSoundStreamSetup(0,1,this);
}   

//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground( 0,0,0 );
    int sx = 0;
    int sy = 0;
    if (boom>0) {
        ofSetColor(255,0,0);
        boom = boom -2;
    } else {
        ofSetColor(255,255,0);
    }
    ofFill();
    for ( int x=0; x < 11; x++ ) {
        for ( int y = 0; y < 7; y++ ) {
            if ( boom > 0 ) {
                sx = 10 * ofRandomf();
                sy = 10 * ofRandomf();
            }
            ofRect(sx + x*120 + 20, sy + y*120 + 20, 100, 100);
        }
    }
}

//--------------------------------------------------------------
void testApp::keyPressed  (int key){ 
}

//--------------------------------------------------------------
void testApp::keyReleased  (int key){ 
}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}

//--------------------------------------------------------------
void testApp::mouseReleased(){
}

void testApp::audioReceived (float * input, int bufferSize, int nChannels) {
    int count = 0;
    for( int i=0; i<bufferSize; i++ ) {
        if (input[i] > 0.3 || input[i] < -0.3 ) {
            count++;
        } 
    }
    if ( count > 10 ) {
        boom = 25;
    }
}

Tags ,  | no comments

Tweet This! submit to reddit Digg!