Archive

Archive for the ‘touchdesigner’ Category

Cinder to touchdesigner # 2

note: I will migrate this blog to my webpage very soon thus having a proper display of the source code.

Next step on having a kind of template for porting OFW/Cinder patches into TD. So, I have the next class called ‘Lines’:


#pragma once
#include “TOP_CPlusPlusBase.h”

class Lines
{
public:
Lines();
~Lines();

virtual void draw(int _x1, int _y1, int _x2, int _y2);

int x1,x2,y1,y2;

};

the body of the class:

#include “Lines.h”

Lines::Lines(){
x1 = x2 = y2 = y1 = 0;
}

Lines::~Lines(){

}

void Lines::draw(int _x1, int _y1, int _x2, int _y2){

x1 = _x1;
y1 = _y1;
x2 = _x2;
y2 = _y2;

::glVertex2i(x1,y1);
::glVertex2i(x2,y2);
}

then i declare a vector on the Parent class:

std::vector mLines;

body:

for(unsigned int i=0;i<amount;i++){
//starting all the lines as 0 value
mLines.push_back(Lines());
}

and the calling the drawing method within the execution loop:

::glBegin(GL_LINES);
::glLineWidth(1.0f);

for(unsigned int i=0; i < amount; i++;
int _y1 = rand()% outputFormat->height;
int _x2 = rand()% outputFormat->width;
int _y2 = rand()% outputFormat->height;

mLines[i].draw(_x1, _y1, _x2, _y2);
}
::glEnd();

::glBegin(GL_LINE_LOOP);
::glVertex2i(0,0);
::glVertex2i(outputFormat -> width, outputFormat->height);
::glEnd();

next step might be to implement containers with pointers and shared pointers.

Categories: cpp, touchdesigner

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…

Categories: cinder, cpp, touchdesigner