FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Responsive Form, Games
(Moderator: REAS)
   voxels... and 2D behavior?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: voxels... and 2D behavior?  (Read 1087 times)
mKoser

WWW Email
voxels... and 2D behavior?
« on: Sep 29th, 2003, 12:20am »

After having learned the expression "voxels" from Robert (flight404) showing off.. (wow!)
i wondered if a voxel could have 2D roll-over behavior!?
 
so i spent a little time playing with this.
http://proce55ing.beyondthree.com?chapter=sketch&project=voxelgrid
 
INSTRUCTIONS:
Mouse activated "voxels"
Keyboard 1-8 sets dimension of "voxels" (i like 8!)
Keyboard Arrow-keys change direction of rotation.
 
...hmmm, kinda looks like a sketch for an airport sign.
 
 
 
- - - - - -
besides that, i have uploadet a bunch of old sketches:
http://proce55ing.beyondthree.com?chapter=sketch&project=deshape
 
http://proce55ing.beyondthree.com?chapter=sketch&project=typo_aaa
 
http://proce55ing.beyondthree.com?chapter=sketch&project=xmas_tree
 
http://proce55ing.beyondthree.com?chapter=sketch&project=unstabile_s cribble
 
http://proce55ing.beyondthree.com?chapter=sketch&project=spiralmoire
 
...more stuff to come...
 
+ mikkel
« Last Edit: Sep 29th, 2003, 12:20am by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
benelek

35160983516098 WWW Email
Re: voxels... and 2D behavior?
« Reply #1 on: Sep 29th, 2003, 4:48am »

deshape and unstabile_scribble are both very beautifully made...
 
skloopy

WWW
Re: voxels... and 2D behavior?
« Reply #2 on: Oct 2nd, 2003, 8:32pm »

just to let you know, your page doesn't work in Mac Safari
 
mKoser

WWW Email
Re: voxels... and 2D behavior?
« Reply #3 on: Oct 2nd, 2003, 8:48pm »

scloopy, damn... thanks for letting me know.
i'll - i'll fire up my mac and get Safari onto it to get it fixed
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
vent

WWW
Re: voxels... and 2D behavior?
« Reply #4 on: Oct 3rd, 2003, 1:33am »

Great stuff. unstabile_s cribble is quite addictive.
 

http://www.shapevent.com/
mKoser

WWW Email
Re: voxels... and 2D behavior?
« Reply #5 on: Oct 3rd, 2003, 2:50pm »

thank you zevan
 
- - - -  
 
regarding http://proce55ing.beyondthree.com and SAFARI, the problem was that Safari appaerently don't understande <iframe height='100%'> ... damn it, so i had to set it to a pixel-height instead! (ahh, the pleasure of cross-browser debugging!)
 
It is now working on Safari!
« Last Edit: Oct 3rd, 2003, 2:50pm by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
madmerv
Guest
Email
Re: voxels... and 2D behavior?
« Reply #6 on: Nov 12th, 2003, 8:59pm »

// Crude Voxel Renderer  
// by merv <http://www.madmerv.com>
 
// Load and display an image texture-mapped on a voxel surface.
// Bump map and image map must be same dimensions.
// Bump map is inverted (whites are low, blacks are high).
 
// Created 10 November 2003
 
float xmag, ymag = 0;
float newXmag, newYmag = 0;  
float xyzscale = 1;
float delta = 0.01;
int xRes = 640;
int yRes = 480;
int xcount;
int ycount;
color xy2;
BImage img;
BImage bump;
float vsize = .1;  // scale of the voxels
 
void svertex( float x, float y, float z )
{
     vertex( x*xyzscale, y*xyzscale, z*xyzscale );
}
 
//
// Draws a cubic prism.
//
void prism( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
  fill(1.5-xyzscale, 0, 1*xyzscale); svertex(-w+ofsx,  h+ofsy,  l+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx,  h+ofsy,  l+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx, -h+ofsy,  l+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale); svertex(-w+ofsx, -h+ofsy,  l+ofsz);
 
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx,  h+ofsy,  l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale); svertex( w+ofsx,  h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale); svertex( w+ofsx, -h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx, -h+ofsy,  l+ofsz);
 
  fill(1*xyzscale, 0, 1.5-xyzscale);   svertex( w+ofsx,  h+ofsy, -l+ofsz);
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx,  h+ofsy, -l+ofsz);
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx, -h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale);   svertex( w+ofsx, -h+ofsy, -l+ofsz);
 
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx,  h+ofsy, -l+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale);   svertex(-w+ofsx,  h+ofsy,  l+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale);   svertex(-w+ofsx, -h+ofsy,  l+ofsz);
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx, -h+ofsy, -l+ofsz);
 
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx,  h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale);   svertex( w+ofsx,  h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale);   svertex( w+ofsx,  h+ofsy,  l+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale);   svertex(-w+ofsx,  h+ofsy,  l+ofsz);
 
  fill(1.5-xyzscale, 0, 1.5-xyzscale); svertex(-w+ofsx, -h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1.5-xyzscale);   svertex( w+ofsx, -h+ofsy, -l+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);     svertex( w+ofsx, -h+ofsy,  l+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale);   svertex(-w+ofsx, -h+ofsy,  l+ofsz);
}
 
//
// Draws a cubic prism of color c.
//
void prism2( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
     
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
 
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
}
 
   
void setup()  
{  
  size(xRes, yRes);  
  noStroke();  
  colorMode(RGB, 1);  
}  
 
void loop()  
{  
  int count;
   
  background(0, 0, .2);
   
  // Load the image
//  img = loadImage("voxeltest.jpg");
//  bump = loadImage("voxeltest.jpg");
  img = loadImage("texture.gif");
  bump = loadImage("bump.gif");    
   
  push();  
 
  translate(width/2, height/2, -30);  
   
  newXmag = mouseX/float(width) * TWO_PI;
  newYmag = mouseY/float(height) * TWO_PI;
   
  float diff = xmag-newXmag;
  if (abs(diff) >  0.01) { xmag -= diff/4.0; }
   
  diff = ymag-newYmag;
  if (abs(diff) >  0.01) { ymag -= diff/4.0; }
   
  rotateX(-ymag);  
  rotateY(-xmag);  
   
  scale(50);
 
  if ((xyzscale >= 3) || (xyzscale <= 0.4)) {
    delta = -delta;
  }
    xyzscale = xyzscale + delta;
 
//  beginShape(QUADS);
//  prism( 0, 0, 0, 1, 1, 1 );
//  endShape();
   
  for ( xcount = -(img.width/2);  xcount < img.width/2; xcount++ ) {    
  for ( ycount = -(img.height/2);  ycount < img.height/2; ycount++ ) {
//  if (xcount%2>0 && ycount%2>0 && xcount*ycount != 0) {
   
  beginShape(QUADS);
  float vheight;
 
 
  fill( img.pixels[(xcount+img.width/2)+(img.width*(ycount+img.height/2))] );
 // if i use this next line instead of the following, also does not work:
 // xy2 = red(bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))]);
  xy2 = bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))];
  vheight = ((xy2 % 256)/32);
  vheight = min(vsize,vheight);
//  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
     
  endShape();
// }
  }
  }
 
   
   
  pop();  
}  
 
madmerv
Guest
Email
Re: voxels... and 2D behavior?
« Reply #7 on: Nov 12th, 2003, 9:00pm »

// Crude Voxel Renderer (Example 2)  
// by merv <http://www.madmerv.com>
 
// Load and display an image texture-mapped on a voxel surface.
// Bump map and image map must be same dimensions.  Preferably divisible by 2.
 
// Created 10 November 2003
 
float xmag, ymag = 0;
float newXmag, newYmag = 0;  
float xyzscale = 1;
float delta = 0.01;
int xRes = 640;
int yRes = 480;
int xcount;
int ycount;
color xy2;
BImage img;
BImage bump;
float vsize = .05;  // scale of the voxels
 
void svertex( float x, float y, float z )
{
     vertex( x*xyzscale, y*xyzscale, z*xyzscale );
}
 
//
// Draws a cubic prism of color c.
//
void prism2( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
     
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
 
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
}
 
   
void setup()  
{  
  size(xRes, yRes);  
  noStroke();  
  colorMode(RGB, 1);  
}  
 
void loop()  
{  
  int count;
   
  background(0, 0, .2);
   
  // Load the image
//  img = loadImage("voxeltest.jpg");
//  bump = loadImage("voxeltest.jpg");
//  img = loadImage("texture.gif");
//  bump = loadImage("bump.gif");    
  img = loadImage("marsfacetex.jpg");
  bump = loadImage("marsfacebmp.gif");    
  push();  
 
  translate(width/2, height/2, -30);  
   
  newXmag = mouseX/float(width) * TWO_PI;
  newYmag = mouseY/float(height) * TWO_PI;
   
  float diff = xmag-newXmag;
  if (abs(diff) >  0.01) { xmag -= diff/4.0; }
   
  diff = ymag-newYmag;
  if (abs(diff) >  0.01) { ymag -= diff/4.0; }
   
  rotateX(-ymag);  
  rotateY(-xmag);  
   
  scale(50);
 
  if ((xyzscale >= 3) || (xyzscale <= 0.4)) {
    delta = -delta;
  }
    xyzscale = xyzscale + delta;
 
//  beginShape(QUADS);
//  prism( 0, 0, 0, 1, 1, 1 );
//  endShape();
   
  for ( xcount = -(img.width/2);  xcount < img.width/2; xcount++ ) {    
  for ( ycount = -(img.height/2);  ycount < img.height/2; ycount++ ) {
//  if (xcount%2>0 && ycount%2>0 && xcount*ycount != 0) {
   
  beginShape(QUADS);
  float vheight;
 
  fill( img.pixels[(xcount+img.width/2)+(img.width*(ycount+img.height/2))] );
 // if i use this next line instead of the following, also does not work:
 // xy2 = red(bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))]);
  xy2 = bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))];
  vheight = ((xy2 % 256)/32);
  vheight = min(vsize,vheight);
//  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
     
  endShape();
// }
  }
  }
 
   
   
  pop();  
}  
 
madmerv
Guest
Email
Re: voxels... and 2D behavior?
« Reply #8 on: Nov 12th, 2003, 9:02pm »

// This doesn't work exactly correctly; I apologize
// I haven't yet figured out why..
 
// Crude Voxel-based Object Renderer Experiment
// by merv <http://www.madmerv.com>
 
// Utilizing 6 images, draw an object in 3d space.
// Bump map and image map must be same dimensions.  
// Preferably divisible by 2.
// Idea based loosely on Teddy3d.
 
// Images 1-3: X, Y, Z planes
// Images 4-6: Color values for corresponding X, Y, Z planes.
 
// Created 10 November 2003
 
float xmag, ymag = 0;
float newXmag, newYmag = 0;  
float xyzscale = 1;
float delta = 0.01;
int xRes = 640;
int yRes = 480;
int xcount;
int ycount;
color xy2;
BImage img;
BImage bump;
float vsize = .05;  // scale of the voxels
 
void svertex( float x, float y, float z )
{
     vertex( x*xyzscale, y*xyzscale, z*xyzscale );
}
 
 
//
// Draws a plane with special colors.
//
void plane( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
  fill(1.5-xyzscale, 0, 1*xyzscale); svertex(-w+ofsx,  h+ofsy,  1+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx,  h+ofsy,  1+ofsz);
  fill(1*xyzscale, 0, 1*xyzscale);   svertex( w+ofsx, -h+ofsy,  1+ofsz);
  fill(1.5-xyzscale, 0, 1*xyzscale); svertex(-w+ofsx, -h+ofsy,  1+ofsz);
}
 
//
// Draws a plan using the current fill color.
//
void plane2( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
  svertex(-w+ofsx,  h+ofsy,  1+ofsz);
  svertex( w+ofsx,  h+ofsy,  1+ofsz);
  svertex( w+ofsx, -h+ofsy,  1+ofsz);
  svertex(-w+ofsx, -h+ofsy,  1+ofsz);
}
 
 
//
// Draws a cubic prism of color c.
//
void prism2( float ofsx, float ofsy, float ofsz, float w, float h, float l )
{
     
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
 
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
 
    svertex(-w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy, -l+ofsz);
    svertex( w+ofsx,  h+ofsy,  l+ofsz);
    svertex(-w+ofsx,  h+ofsy,  l+ofsz);
 
    svertex(-w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy, -l+ofsz);
    svertex( w+ofsx, -h+ofsy,  l+ofsz);
    svertex(-w+ofsx, -h+ofsy,  l+ofsz);
}
 
   
void setup()  
{  
  size(xRes, yRes);  
  noStroke();  
  colorMode(RGB, 1);  
}  
 
void loop()  
{  
  int count;
   
  background(0, 0, .2);
   
  // Load the image
//  img = loadImage("voxeltest.jpg");
//  bump = loadImage("voxeltest.jpg");
//  img = loadImage("texture.gif");
//  bump = loadImage("bump.gif");    
  img = loadImage("marsfacetex.jpg");
  bump = loadImage("marsfacebmp.gif");    
  push();  
 
  translate(width/2, height/2, -30);  
   
  newXmag = mouseX/float(width) * TWO_PI;
  newYmag = mouseY/float(height) * TWO_PI;
   
  float diff = xmag-newXmag;
  if (abs(diff) >  0.01) { xmag -= diff/4.0; }
   
  diff = ymag-newYmag;
  if (abs(diff) >  0.01) { ymag -= diff/4.0; }
   
  rotateX(-ymag);  
  rotateY(-xmag);  
   
  scale(50);
 
  if ((xyzscale >= 3) || (xyzscale <= 0.4)) {
    delta = -delta;
  }
    xyzscale = xyzscale + delta;
 
//  beginShape(QUADS);
//  prism( 0, 0, 0, 1, 1, 1 );
//  endShape();
   
  for ( xcount = -(img.width/2);  xcount < img.width/2; xcount++ ) {    
  for ( ycount = -(img.height/2);  ycount < img.height/2; ycount++ ) {
//  if (xcount%2>0 && ycount%2>0 && xcount*ycount != 0) {
   
  beginShape(QUADS);
  float vheight;
 
  fill( img.pixels[(xcount+img.width/2)+(img.width*(ycount+img.height/2))] );
 // if i use this next line instead of the following, also does not work:
 // xy2 = red(bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))]);
  xy2 = bump.pixels[(xcount+bump.width/2)+(bump.width*(ycount+bump.height/2))];
  vheight = ((xy2 % 256)/32);
  vheight = min(vsize,vheight);
//  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
  prism2( vsize*xcount, vsize*ycount, (-vsize*vheight)/2, vsize, vsize, vsize*vheight);//*vheight );  
     
  endShape();
// }
  }
  }
 
   
   
  pop();  
}  
 
Pages: 1 

« Previous topic | Next topic »