Archive

Archive for December, 2010

Trying to speak French

December 21, 2010 Leave a comment

I have a rather curious relationship with vvvv, DirectX and Windows: for me it is like studying French(my native language is Spanish), with all the ‘far away so close’ sensation on it. If you are a OSX-Unix user maybe you know what I mean!
So, I decided to make a nice partition in one of my computers and install Windows again(last time was one year ago!) with the only propose of learning how to make HLSL shaders and the play more with vvvv.
It is very funny to see how HLSL uses a rawer c-ish style, with the inclusion of some new types for expressing matrices and vectors(float4x4 and so). Besides that, the varying variables are managed quite differently altogether with the compilation of the shaders. The implementation of ‘techniques’ is something very smart and interesting.
The uniform declaration also changes a little bit. In GLSL you have something like:
uniform vec4 Color;
whereas HLSL would declare the same thing as:
float4 Color: COLOR

finally, I am not sure how much is the vvvv wrapper, but i find some close similarities inthe way jxs files are written in order to load shaders with jitter.

In the end the concepts are all the same, so I am enjoying the process of discovering the way those little phong shaders work with DirectX!

Advertisements
Categories: HLSL, vvvv

going OOP with jitter-java

December 21, 2010 1 comment

There is a big question mark over the question if jitter is OOP or not. It might be. However, for generating big amount of instances I still consider java(or c++) as the best way to go. It is possible to create interfaces or import external libraries to our jitter matrices(like processing’s traer physics).
A simple example:
I create a class called PointA

import java.util.Random;

public class PointA {
private float x,y,z,quantity;
private int direction=-1;
private Random dd1=new Random();
private int dd2=0;

PointA(){

}

PointA(float x,float y, float z, float quantity){
this.x=x;
this.y=y;
this.z=z;
this.quantity=quantity;

}

public void setup(){
dd2=dd1.nextInt(2);
if(dd2==0){
direction =-1;
}else{
direction = 1;
}
}

public void update(){

x +=quantity*direction;
if(x>0.8f || x0.8f || y<=-0.8f){
direction *=-1;
}

z=0.0f;
}

public float getXPos(){
return x;
}

public float getYPos(){
return y;
}

public float getZPos(){
return z;
}

public void draw(){

}

}

then we make it usable for the jitter matrix:


import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

import com.cycling74.max.*;
import com.cycling74.jitter.*;
import com.cycling74.jitter.JitterMatrix;
import com.cycling74.max.AttributeInfo;
import com.cycling74.max.DataTypes;
import com.cycling74.max.MaxObject;

public class MxGLBegin2a extends MaxObject{

//PointA mPoint;
int amount=50;
float[] x=new float[amount];
float[] y=new float[amount];
float[] z=new float[amount];
Random quant=new Random();
PointA[] mPoints=new PointA[amount];
JitterMatrix p1=new JitterMatrix(3,”float32″,amount);

public MxGLBegin2a(){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});

//mPoint= new PointA(0.0f,0.0f,0.0f,0.1f);

for(int i=0;i<amount;i++){
float rx=(float)Math.random()-0.5f;
float ry=(float)Math.random()-0.5f;
float rz=0.0f;
//float rq=(float)Math.random()-0.8f;
float rq=(quant.nextInt(3)*0.001f)+0.01f;;
//post("rq value is: "+rq);
mPoints[i]=new PointA(rx,ry,rz,rq);
mPoints[i].setup();
}

}

public void bang(){
int plane=0;
int dim=0;
int[] offset=new int[]{0};
int count=amount;
int arrayoffset=0;

for(int i=0;i<amount;i++){
mPoints[i].update();
x[i]=mPoints[i].getXPos();
//post("value x: is " + mPoints[i].getXPos());
y[i]=mPoints[i].getYPos();
z[i]=mPoints[i].getZPos();
}

p1.copyArrayToVectorPlanar(plane,dim,offset,x,count,arrayoffset);
plane=1;
p1.copyArrayToVectorPlanar(plane,dim,offset,y,count,arrayoffset);
plane=2;
p1.copyArrayToVectorPlanar(plane,dim,offset,z,count,arrayoffset);

outlet(0,"jit_matrix",p1.getName());
}
}

here the max patch:
———-begin_max5_patcher———-
865.3ocyX1saaBCFF93jqBKzNLKBa9IvNpamrS5tBlphLAWp6.SK1QIcU8de
Fanoo0Y3zDHnD4.Fi40O9yuel77zINIkaIbGv2.+FLYxySmLQUUcESZNehSA
d6pbLW0LmayKYqKblouDMUUYYx8eEE0V4skLACWPTW56UTbd6Uj2IkkSDptB
tqxx0h1ZQuoS3z+p5j34tM0pan3oGHZMWKGrvYFvIAyxb.2zztGvhU2QYYKq
HqD5lhh7kcCHbQcYfacITdL3l563koSqKlYIDJHbNNizNrDjspGhyCkTlXYs
rAeAZhQgGIiPFYD73XjMXIVAjP0wvfOIVXjMxQ4Gnh.3NGBPt.TrIl3eVha7
9jwMxIr1e9eXx2UG8nvTf2IE8b.LIUTpJJ9iLBFdVXzQF2z4RpFn3EUW5GcZ
PYcQBoxzXO9R3qzDVzIBf5gMJL7LXqbXuU2ws2JL.oF3998n4JoByIKWUlWV
IMTZ9ZzlEFM5rYaITiCqqaeXz9XNsntuMfjEiOhfTDAEqLS8CNoXlj0BQIyv
3N7SXOd7FgPWndrn+wssbfROfFkYGz4J0kmXxgCYITQ3DwLPZEdSAVTQ2BJd
5ZJivApchwM4MLBWI3EraKXPeTeXMbOULOKeN+OD4iGvWUQHLvUZyTXymqRx
IrzkDFVdvtyKJSIfv5yey1a8Lg1fKQVp5DT1fWndYoWPPer4sZ9tgxRK27Jb
ukiw.iom7uDbR6czAqzqVQPcnHr2PkLTrRFaQpdkV6kcW8wH57F4nCF0r4md
4UDD.El.IlPC5RfFkdrZOhM7Qu4P+vSBOhxrrbhIH.OG4665kA0CkX29KY+i
EDQUI.YZqbwWhDX1N8pwQ.ruLN1OMuA5bQ9WnjJaoVYcmMRuUQOMuhb6CPUr
8dvu19yq+AIixPXSqSFmYpaXimlM9FYipCbxUS+68+Vp5v552GX7x0UqZkPq
GgL8RqNRIbAkgET46OrqQw60l6nooD0kaGbEzzlsXptmCL6YqjhsPQ096iLI
sXPUTnMPZPUjMARQCqhP1.IugWSvwklrBSvwmjF1Ubu6wc.MELrXx0FMMvq5
hFeq5VL9bKsMkBb3BlrYhCENrA3givEc91XgGO7Zpy4N2gMD2l4t2I7AgSnt
zzoXXJO4ko+CoBgdtC
———–end_max5_patcher———–

You can compile the example using your favorite IDE(Eclipse!) or directly on the terminal using the javac.
Next time I will post an example of how to use some processing native libraries with jitter.

Categories: code, jitter

Kasia’s concern

December 21, 2010 Leave a comment

Here are some photos of some concerts I presented this year with the Polish composer Kasia Glowicka.

SPOR festival(Denmark):


Musica Polonica Nova(Poland):


Gaudeamus(Netherlands):

Some wise words: I need to update my blog more ofter as projects tend to pile up!

Categories: concerts

ECPNM

December 21, 2010 Leave a comment

a small review of a concert I gave in september


http://blog.eigentijds.radio4.nl/?p=165

Categories: concerts

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

Garden of geometries

December 6, 2010 Leave a comment

Past month I finished a really nice project called ‘Electric Gardens’ with the trio ‘Electronic Hammer’:

http://www.electronichammer.com/main/index.php;

One of the premises of the project was to design an interactive system that would react to the gestures of the performers, either as audio analysis or data coming from their computers/instruments. As a result I designed a system that would keep me occupied for a while as it presents a lot of possibilities.
I designed most of the piece thinking in ‘scenes’ hosted on a system that would allow fast and simple transitions. The image is a kind of ‘modular cinema’ where each one of the parts could have their own visual ‘world’ encapsulated.
In terms of technique, I designed most of the piece using glsl shaders and lots of java classes for deforming and handling the geometries. Many of the materials were sketched using code tools( basically Cinder) and then ported to jitter, which has a more ‘performing’ profile and has a range of friendly facilities for MIDI and audio analysis. Some of the shaders( those of light models) are ports of hlsl shaders.

specular sound

specular sound

specular sound

Categories: code, cpp, jitter, openGL, shaders

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