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)
   spherical texture mapping
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: spherical texture mapping  (Read 650 times)
jaN

711039711039 WWW
spherical texture mapping
« on: Dec 10th, 2002, 7:00pm »

A rather simple working example can be found on www.superposh.com (follow the first link on the news page, the website is under heavy construction)
 
The source code can be found here... (It is extremely messy, not documented at all,slow, and most of it taken from the learning section of the P5 website. the end result still looks rather nice).  
 
 
////////////////////////////////////////////
 
float mx;
float my;
float delay = 50.0;
 
int pixelsize = 4;
float timer = 0;
 
BImage a;
int[][] aPixels = new int[128][128];
 
BImage b;
int[][] bPixels = new int[270][9];
 
boolean onetime = true;
 
void setup() {
  size(420,200);
  background(0,0,0);
  noLights();
  rectMode(CENTER_DIAMETER);
 
}
 
void drawpixel() {
  stroke(250,200,60);
  point(0,0);
}
 
void drawpixel2() {
  stroke(100);
  point(0,0);
}
 
void setImages() { // set background
  a = loadImage("mask.gif");
  image(a, 0, 0);
  for(int i=0; i<128; i++) {
    for(int j=0; j<128; j++) {
 aPixels[j][i] = pixels[i*width+j];
    }
  }
 
  b = loadImage("text.gif");
  image(b, 0, 0);
  for(int i=0; i<9; i++) {
    for(int j=0; j<270; j++) {
 bPixels[j][i] = pixels[i*width+j];
    }
  }
}
 
  float ra = -(210-mouseX)/500.0;
 
   
 
  void drawglobe(float x, float y, float globesize) {
 
  push();
 
   
 
 
 
  int s = int(globesize);
 
  float size = globesize; // scaler
 
  push(); translate(x,y,10);
 
  rotateY(ra*(timer/50.0));
  rotateZ((PI/24)*sin(timer/50.0));
 
  for(int j=-s; j<s; j=j+2) {
 
    push();
 
    translate(0,j,0);
 
    for (int i = 0; i<s*2; i++) {
 
 rotateY(PI/64);
 
 push();  translate(0,0,sqrt(size*size-j*j));
 
 if((aPixels[i][j+s]) != -1){
   drawpixel();
 
     } else { drawpixel2(); } pop();
 
     }
     pop();
   }
   pop();
   pop();
 }
 
 void drawship() {
 
   lights();
   push();
   stroke(200); fill(30);
   //scale(0.5);
   box(4);
   triangle(0,0,8,3,8,-3);   triangle(0,0,-8,3,-8,-3);
   pop();
   noLights();
 }
 
 void drawtext(float x, float y, float globesize) {
 
   push();
 
   int s = int(globesize);
 
   float size = globesize; // scaler
 
   push(); translate(x,y,10);
 
  rotateY(ra*(timer/50.0));
   rotateZ((PI/24)*sin(timer/50.0));
 
   for(int j=-4; j<5; j++) {
 
     push();
 
     translate(0,j,0);
 
     for (int i = 0; i<270; i++) {
 
  rotateY(PI/135);
 
  push();  translate(0,0,sqrt(70*70-j*j));
 
  if((bPixels[i][4+j]) != -1){
    stroke(250);
    point(0,0);
  }
 
  pop();
 
     }
     pop();
   }
   pop();
   pop();
 }
 
 
float mx_new = 210;
 
float my_new = 100;
 
 
 void loop()
 {
   if(onetime) {
     setImages();
     onetime = false;
   }
 
   
 
   if (mousePressed) {
   if(abs((210-mouseX) - mx) > 1) {
     mx = mx + ((210-mouseX) - mx)/delay;
   }
   if(abs((100-mouseY) - my) > 1) {
     my = my + ((100-mouseY) - my)/delay;
   }
 
   push(); translate(0,0,42); fill(40); rect(0,0,900,500); pop();
 
 
 
   mx_new = 210-mx;
 
   my_new = 100-my;
 
   
 
   drawglobe(mx_new,my_new,64);
 
   drawtext(mx_new,my_new,135);
 
   } else {
 
   
 
   
   push(); translate(0,0,42); fill(40); rect(0,0,900,500); pop();
 
 
 
   drawglobe(mx_new,my_new,64);
 
   drawtext(mx_new,my_new,135);    
 
   
 
   }
 
 
   timer=timer+2;
 }
 
 
///////////////////////////////////////////////
 

jaN
REAS


WWW
Re: spherical texture mapping
« Reply #1 on: Dec 11th, 2002, 7:00pm »

I think this work is very interesting, but i think people will have a hard time finding it on your site. Please make an easier way of getting to your work.  
 
gkoshra

WWW Email
Re: spherical texture mapping
« Reply #2 on: Feb 24th, 2003, 11:20am »

I think I found it, is it the thesis stuff? If so, it's all really nice.
 
vent

WWW
Re: spherical texture mapping
« Reply #3 on: Apr 22nd, 2003, 4:59am »

I couldn't find it on your site, but I took a look at some of the other stuff and was quite impressed. Excellent work.
 

http://www.shapevent.com/
pollux

WWW Email
Re: spherical texture mapping
« Reply #4 on: Apr 23rd, 2003, 4:32am »

i'm sure it is great, but couldn't find it... desoleé
 

pollux | www.frwrd.net
Pages: 1 

« Previous topic | Next topic »