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
Links in OpenGL (Read 536 times)
Links in OpenGL
Dec 30th, 2007, 4:19pm
 
Hi Guys. I need your help. I want create links on my PImages. The problem is that the coordinates of the PImages change with the X and Y Rotation. I have no idea.

Thank you for your help!

Here the online example:
http://www.sebastiankatsura.com/



And here's the code:



import processing.opengl.*;

float a_rotspeed;
float b_rotspeed;

PImage brille,sebo,ikarus,shishi;

void setup(){
 brille = loadImage("brille.png");
 sebo = loadImage("sebo.jpg");
 ikarus = loadImage("ikarus1.gif");
 shishi = loadImage("shishi.gif");
 
 size(500,500,OPENGL);
 background(255);
 frameRate(130);
}

//BILDER-----------------------------------------------------

void brille(){  
 pushMatrix();
 image(brille,0,0);
 translate(0,0,0);

 popMatrix();
}

void sebo(){    
 pushMatrix();
 translate(100,0,-10);
 rotateY(PI/2);
 image(sebo,0,0);
 popMatrix();
}

void ikarus(){    
 pushMatrix();
 translate(20,-50,-150);
 rotateY(PI/-2);
 //rotateX(PI);
 image(ikarus,0,0);
 popMatrix();
}

void shishi(){

 //rotateX(PI);
 //rotateY(PI);
 //rotateZ(PI/2);
 pushMatrix();
 translate(-120,-50,10);
 image(shishi,0,0);
 popMatrix();
}

//-------------------------------------------------

void draw(){

 noFill();
 background(255);
 //ANFANG BOX UND BEWEGUNG---------------------
 pushMatrix();
 translate(width/2,height/2);
 rotateX(a_rotspeed);
 rotateY(b_rotspeed);
 stroke(150,80);
 box(250);
 //ENDE BOX UND BEWEGUNG-----------------------

 brille();
 sebo();
 ikarus();
 shishi();
 popMatrix();

 if (mouseX<100&&mouseY>100&&mouseY<400){
   b_rotspeed-=0.03;
   
 }
 else if (mouseX>400&&mouseY>100&&mouseY<400){
   b_rotspeed+=0.03;
 }
 if (mouseX>100&&mouseX<400&&mouseY<100){
   a_rotspeed+=0.03;
 }
 else if (mouseX>100&&mouseX<400&&mouseY>400){
   a_rotspeed-=0.03;
 }

}

Re: Links in OpenGL
Reply #1 - Dec 31st, 2007, 1:09am
 
maybe you're looking for this:
http://processing.org/reference/screenX_.html
Re: Links in OpenGL
Reply #2 - Dec 31st, 2007, 7:53am
 
hi sebo, what you are looking for is called picking : you want to check which object (PImage) has been clicked in a 3D space.

it is not so easy to do, but you can find more info about this technique here :
http://www.processinghacks.com/hacks/picking
http://www.processinghacks.com/hacks/picking_color_buffer
Re: Links in OpenGL
Reply #3 - Dec 31st, 2007, 1:33pm
 
Thank you guys! Happy new year! Cheesy
Page Index Toggle Pages: 1