We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
cubic VR (Read 645 times)
cubic VR
Dec 7th, 2007, 4:15pm
 
hi there!

first sketch i wrote from scratch:
http://users.telenet.be/k-labs/processing/cubicVR/cubicVR5.zip

its a basic cubicVR aplication similar to quicktimeVR, 6 images are mapped on the planes of a cube.

is still need to change the controls for the camera etc... but i noticed that the edges of the planes are still visible which destroys the illusion completely...

i can't find a way of making them disappear Sad

any tips welcome.

Code:

import processing.opengl.*;
float rotx = PI/4;
float roty = PI/4;
int s = 200;
int m = 400;
PImage a, b, c, d, e, f;

void setup() {
size(400, 400, OPENGL);
a = loadImage("V01.jpg");
b = loadImage("V02.jpg");
c = loadImage("V03.jpg");
d = loadImage("V04.jpg");
e = loadImage("V05.jpg");
f = loadImage("V06.jpg");
textureMode(IMAGE);
//smooth();
noStroke();
}

void draw() {
background(255);
translate(width/2.0, height/2.0, -100);
camera(0.0, 0.0, 0.0, // eyeX, eyeY, eyeZ
10, rotx, roty, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ

// +Z "front" face
beginShape();
texture(a);
vertex(-s, -s, s, 0, 0);
vertex( s, -s, s, m, 0);
vertex( s, s, s, m, m);
vertex(-s, s, s, 0, m);
endShape();

// -Z "back" face
beginShape();
texture(c);
vertex( s, -s, -s, 0, 0);
vertex(-s, -s, -s, m, 0);
vertex(-s, s, -s, m, m);
vertex( s, s, -s, 0, m);
endShape();

// +Y "bottom" face
beginShape();
texture(f);
vertex(-s, s, s, 0, 0);
vertex( s, s, s, m, 0);
vertex( s, s, -s, m, m);
vertex(-s, s, -s, 0, m);
endShape();

// -Y "top" face
beginShape();
texture(e);
vertex(-s, -s, -s, 0, 0);
vertex( s, -s, -s, m, 0);
vertex( s, -s, s, m, m);
vertex(-s, -s, s, 0, m);
endShape();

// +X "right" face
beginShape();
texture(b);
vertex( s, -s, s, 0, 0);
vertex( s, -s, -s, m, 0);
vertex( s, s, -s, m, m);
vertex( s, s, s, 0, m);
endShape();

// -X "left" face
beginShape();
texture(d);
vertex(-s, -s, -s, 0, 0);
vertex(-s, -s, s, m, 0);
vertex(-s, s, s, m, m);
vertex(-s, s, -s, 0, m);
endShape();
}

void mouseDragged() {
float rate = 0.1;
rotx += (pmouseY-mouseY) * rate;
roty += (mouseX-pmouseX) * rate;
}


Re: cubic VR
Reply #1 - Dec 8th, 2007, 4:15pm
 
ok found it!  jsut moved the planes one pixel closer, et voila!

Smiley
Re: cubic VR
Reply #2 - Jan 2nd, 2008, 7:10pm
 
cool - is it possible to see your final version?
i have tried to move 1 pixel closer - but then
i saw a missing pixel.
Re: cubic VR
Reply #3 - Jan 4th, 2008, 2:37pm
 
Code:

import processing.opengl.*;
float rotx = PI/4;
float roty = PI/4;
int s = 200;
int m = 400;
PImage a, b, c, d, e, f;

void setup() {
size(400, 400, OPENGL);
a = loadImage("V01.jpg");
b = loadImage("V02.jpg");
c = loadImage("V03.jpg");
d = loadImage("V04.jpg");
e = loadImage("V05.jpg");
f = loadImage("V06.jpg");
textureMode(IMAGE);
//smooth();

}

void draw() {
background(255);
translate(width/2.0, height/2.0, -100);
camera(0.0, 0.0, 0.0, // eyeX, eyeY, eyeZ
10, rotx, roty, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ

// +Z "front" face
beginShape();
texture(a);
vertex(-s, -s, s-1, 0, 0);
vertex( s, -s, s-1, m, 0);
vertex( s, s, s-1, m, m);
vertex(-s, s, s-1, 0, m);
endShape();

// -Z "back" face
beginShape();
texture(c);
vertex( s, -s, -s+1, 0, 0);
vertex(-s, -s, -s+1, m, 0);
vertex(-s, s, -s+1, m, m);
vertex( s, s, -s+1, 0, m);
endShape();

// +Y "bottom" face
beginShape();
texture(f);
vertex(-s, s-1, s, 0, 0);
vertex( s, s-1, s, m, 0);
vertex( s, s-1, -s, m, m);
vertex(-s, s-1, -s, 0, m);
endShape();

// -Y "top" face
beginShape();
texture(e);
vertex(-s, -s+1, -s, 0, 0);
vertex( s, -s+1, -s, m, 0);
vertex( s, -s+1, s, m, m);
vertex(-s, -s+1, s, 0, m);
endShape();

// +X "right" face
beginShape();
texture(b);
vertex( s-1, -s, s, 0, 0);
vertex( s-1, -s, -s, m, 0);
vertex( s-1, s, -s, m, m);
vertex( s-1, s, s, 0, m);
endShape();

// -X "left" face
beginShape();
texture(d);
vertex(-s+1, -s, -s, 0, 0);
vertex(-s+1, -s, s, m, 0);
vertex(-s+1, s, s, m, m);
vertex(-s+1, s, -s, 0, m);
endShape();
}

void mouseDragged() {
float rate = 0.1;
rotx += (pmouseY-mouseY) * rate;
roty += (mouseX-pmouseX) * rate;
}

still some slight color variations, but that has to do with the original renders themselves.
the mouse drag etc could be better.
Page Index Toggle Pages: 1