Archive

Archive for the ‘cinder’ Category

Cinder to touchdesigner # 1

When I am about to start a project I always ask myself ‘spaghetti or code?’. Indeed, choosing the correct tool for the correct job/piece/toy is, from MHO, one of the most important steps of media design. However, I often find myself willing to have the benefits of one tool available into another. That has been the reason behind porting java and processing code into jitter as I can benefit a performing tool with data management resources( just to put an example). Of course working with such idea always provides interesting insights about the tools themselves, their possibilities and limitations. It also exposes the many things that I need to learn in order to implement my ideas. In other words, turns the world slightly upside down.
Today I managed to compile my first, very simple simple, TOP object for TouchDesigner. I need to admit that the most difficult past was not to deal with the internal logic of the c++ file but to compile it: TouchDesigner is only available for the windows system, meaning that I am learning how to do all this compilation management with Visual Studio c++. So far so good although I still use too many concepts from XCode in order to deal with the new IDE( which is probably not a good idea).
The TouchDesigner gl externals are quite straight forward. Basically you are calling gl commands ‘as they are’. So for a cluster of lines you would do something like this:

::glBegin(GL_LINES);
::glLineWidth(1.0f);
for(unsigned int i=0; i<amount;i++);
int x1 = rand()% outputFormat->width;
int y1 = rand()% outputFormat->height;
int x2 = rand()% outputFormat->width;
int y2 = rand()% outputFormat->height;
::glVertex2i(x1 ,y1);
::glVertex2i(x2, y2);
}
::glEnd();

pretty direct, right?

So now to plan the proper way to port my Cinder and OFW apps into TouchDesigner. Let’s see how it goes…

Advertisements
Categories: cinder, cpp, touchdesigner

Containers of pointers and native cinder types

January 20, 2011 Leave a comment

A very simple example on that topic using cinder.


#include “cinder/app/AppBasic.h”
#include “cinder/gl/gl.h”
#include “cinder/Rand.h”
#include

using namespace ci;
using namespace ci::app;
using namespace std;

static const int total= 10;
class Pointer2NativeApp : public AppBasic {
public:
void setup();
void mouseDown( MouseEvent event );
void update();
void draw();

protected:
int x,y;
int* px;
int* py;
vector mXFloats;
vector mYFloats;
vector mV2;
vector mV3;
typedef vector::iterator fIter;
typedef vector::iterator v2Iter;
};

void Pointer2NativeApp::setup(){
x=100;
y=200;

//int xxx=x;
px=&x;
py=&y;

for(unsigned int i=0;i<total;i++){
float _x=Rand::randFloat(0.0f,(float)getWindowWidth());
float _y=Rand::randFloat(0.0f,(float)getWindowHeight());
mXFloats.push_back(new float(Rand::randFloat(0.0f,(float)getWindowWidth())));
mYFloats.push_back(new float(Rand::randFloat(0.0f,(float)getWindowHeight())));
mV2.push_back(new Vec2f(_x,_y));

}

for(unsigned int i=0;i<total;i++){
float _x=Rand::randFloat(0.0f,(float)getWindowWidth());
float _y=Rand::randFloat(0.0f,(float)getWindowHeight());
float _z=Rand::randFloat(-3.0f,3.0f);
mV3.push_back(new Vec3f(_x,_y,_z));
}

// for(unsigned int i=0;i<total;i++){
// cout<<*mXFloats[i]<<endl;
// }

gl::enableWireframe();
}

void Pointer2NativeApp::mouseDown( MouseEvent event )
{
}

void Pointer2NativeApp::update(){

}

void Pointer2NativeApp::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );

gl::color(ColorA(1.0f,0.9f,0.9f,0.2f));
//cout<<*px<<endl;
gl::drawStrokedCircle(Vec2f(*px,*py),100);

// for(v2Iter v=mV2.begin();v!=mV2.end();++v){
// }

for(unsigned int i=0;i<total;i++){
gl::drawSphere(*mV3[i],20);
gl::drawStrokedCircle(*mV2[i],20);
}
}

CINDER_APP_BASIC( Pointer2NativeApp, RendererGl )

Categories: cinder, cpp

Dispersion for a Palm Top Theater

January 14, 2011 Leave a comment

I am writing my first iPhone thingie. So far it has been a lot of learning in terms of hardware and optimization. As a friend of mine said ‘you need to think that you are programming for a computer from the 90’s’. And it is correct!
The development is part of this project:

http://www.v2.nl/events/palm-top-theater

It is a rather interesting way of thinking iPhone visualization and i am looking forward for the results. Meanwhile, discovering how to write for a 90’s computer…

Categories: cinder, iPhone

more N

the same idea:

Categories: cinder, code

Noiser

I made small experiment, imported some libraries from OFW into Cinder and they work as a charm. I am wondering if someday we will see a merge of both frameworks, both amazing!
But maybe it is like the dream of watching vvvv and jitter living happily even after.
Meanwhile, some photos:


Categories: cinder, code

Clean!

December 20, 2010 Leave a comment

Look how clean cinder is, love it!

#include “cinder/app/AppBasic.h”
#include “cinder/ArcBall.h”
#include “cinder/gl/gl.h”

using namespace ci;
using namespace ci::app;
using namespace std;

const int amount = 10;

class ArcBallBiApp : public AppBasic {
public:
virtual void setup();
virtual void resize(ResizeEvent event);
virtual void mouseDown(MouseEvent event);
virtual void mouseDrag(MouseEvent event);
virtual void update();
virtual void draw();

protected:
float w,h;
float wArea,hArea;

Arcball mArcBall;
float mRad;
};

void ArcBallBiApp::setup(){
w=static_cast (getWindowWidth());
h=static_cast (getWindowHeight());
wArea=w/amount;
hArea=h/amount;

mRad=100.0f;

gl::enableAlphaBlending(true);
glBlendFunc( GL_SRC_ALPHA, GL_ONE );

}

void ArcBallBiApp::resize(ResizeEvent event){
mArcBall.setWindowSize(getWindowSize());
mArcBall.setCenter(getWindowCenter());
mArcBall.setRadius(150.0f);
}

void ArcBallBiApp::mouseDown(MouseEvent event){
mArcBall.mouseDown(event.getPos());
}

void ArcBallBiApp::mouseDrag(MouseEvent event){
mArcBall.mouseDrag(event.getPos());
}

void ArcBallBiApp::update(){

}

void ArcBallBiApp::draw(){
gl::clear( Color( 0, 0, 0 ) );

for(int i=0;i<amount;i++){
for(int j=0;j<amount;j++){
float xPos =(wArea*i)+wArea;
float yPos =(wArea*j)+hArea;
glColor4f(0.5f,0.9f,1.0f,0.5f);
gl::pushMatrices();

gl::translate(Vec3f(xPos-(wArea*0.5f),
yPos-(hArea*0.5f),0.0f));
Quatf quat=mArcBall.getQuat();
gl::rotate(quat);
gl::drawCube(Vec3f::zero(),Vec3f(50.0f,50.0f,50.0f));
gl::popMatrices();
}
}

}

CINDER_APP_BASIC( ArcBallBiApp, RendererGl )

Categories: cinder, code

How to be baroque with pointers

December 6, 2010 Leave a comment

I did a small experiment in Cinder using STL and pointers. Instead of creating a big array of objects I created a series of pointers to values:

vector<float*> x

vector<float*> y

then I generated some values for the container:

for(int i=0;i<NR_OF_DOTS_TO_STORE;i++){

float* _nx=new float(Rand::randFloat(wSize));

float* _ny=new float(Rand::randFloat(hSize));

x.push_back(_nx);

y.push_back(_ny);

}

the destructor would look like:

Particle::~Particle(){

xIter xVariable=x.begin();

while(xVariable!=x.end()){

delete(*xVariable);

++xVariable;

}

yIter yVariable=y.begin();

while(yVariable!=y.end()){

delete(*yVariable);

++yVariable;

}

}

funny enough I finished casting them because the Cinder types don’t accept pointers directly. So, instead of doing something like this at the moment of using the data:

gl::drawLine(Vec2f(x[i],y[i]),Vec2f(x[i+1],y[i+1]));

I finished with something like this:

glBegin(GL_LINES);

glVertex2f(reinterpret_cast<float>(x[i]),reinterpret_cast<float>(y[i]));

glVertex2f(x[i+1],y[i+1]);

glEnd();

in conclusion, a rather impractical way of doing things!

Categories: cinder, cpp