in the spirit of sharing i’ve decided to post an early version of my sketch that i showed earlier with the black lines on the white background. this is an earlier version so doesn’t have the nunchaku code included, just the painting and basic navigation with the wiimote d-pad… the code is straightforward so shouldn’t be too hard to understand. if you find it useful don’t forget to mention it.
// dom - wiitesting
import lll.wrj4P5.*;
import lll.Loc.*;
Wrj4P5 wii;
LinkedList p = new LinkedList();
int stuff = 100;
int gastuff = 1;
float factor = 1.1;
float spdx = 0.00;
float spdy = 0.00;
float spdz = 0.00;
float opac = 200;
//basic setup
void setup() {
size(800,600,P3D);
wii=new Wrj4P5(this).connect();
}
//main function
void draw() {
if (wii.isConnecting()) return;
background(222);
translate(300/2,300/2,0);
camera(150,150,50,0,0,0,1,0,-1);
p.addFirst(wii.rimokon.senced.mul(200));
if (p.size()>2500) p.removeLast();
for (int i=0;i<p.size();i++) {
Loc pt=(Loc)p.get(i);
translate(spdx,spdy,spdz);
stroke(stuff,stuff,stuff,opac);
line(pt.x/factor+(gastuff*factor),pt.y/factor+(gastuff*factor),pt.z/factor+(gastuff*factor),pt.x+1,pt.y+gastuff,pt.z+gastuff);
line(pt.x/factor+gastuff,pt.y/factor+gastuff,pt.z/factor+gastuff,pt.x+1,pt.y+gastuff,pt.z+gastuff);
line(pt.x/factor,pt.y/factor,pt.z/factor,pt.x,pt.y,pt.z);
//delay(1);
}
}
// check below for which buttons do what
void buttonPressed(RimokonEvent evt, int rid) {
if (evt.wasPressed(evt.B)) {
stuff=stuff+10;
wii.rimokon.vibrateFor(1);
}
if (evt.wasPressed(evt.A)) {
stuff=stuff-10;
//wii.rimokon.vibrateFor(10);
}
if (evt.wasPressed(evt.MINUS)) {
gastuff=gastuff-1;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.PLUS)) {
gastuff=gastuff+1;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.UP)) {
spdx=spdx+0.01;
spdy=spdy+0.01;
spdz=spdz+0.01;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.DOWN)) {
spdx=spdx-0.01;
spdy=spdy-0.01;
spdz=spdz-0.01;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.LEFT)) {
spdx=spdx+0.01;
spdy=spdy-0.01;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.RIGHT)) {
spdx=spdx-0.01;
spdy=spdy+0.01;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.ONE)) {
opac=opac-2;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.TWO)) {
opac=opac+2;
//wii.rimokon.vibrateFor(30);
}
if (evt.wasPressed(evt.HOME)) {
spdx=0.00;
spdy=0.00;
spdz=0.00;
gastuff=1;
stuff=0;
//wii.rimokon.vibrateFor(30);
}
}
enjoy.