We are about to switch to a new forum software. Until then we have removed the registration on this forum.
****Hi, I am new to processing and am using processing 3.3.6
Wondering if anyone can help me make the GUI interface render in 2D ?
The idea is to have a sphere in the middle (able to rotate with mouseX,Y ->using peacy cam) and on click GUI button will render 2D pattern(ellipse for example) on the canvas and play sound
Below is my code:
import peasy.*;
!import processing.sound.*;
import controlP5.*;
ControlP5 cp5;
PeasyCam cam;
PVector [][] globe;
int total = 100;
// button data
Button pollution;
// --- set up control
boolean populationpatternon = true;
boolean deathpatternon = true;
boolean socialpatternon = true;
boolean pollutionpatternon = true;
void setup(){
size(1000,1000,P3D);
hint(ENABLE_DEPTH_TEST);
globe = new PVector[total][total];
cam = new PeasyCam(this,200);
hint(DISABLE_DEPTH_TEST);
cp5 = new ControlP5(this);
pollution = cp5.addButton("pollution").setValue(0).activateBy(ControlP5.RELEASE);
}
public void pollution(){
println("Button Pressed pollution");
pollutionpatternon = !pollutionpatternon;
}
void draw(){
background(255);
lights();
lightSpecular(255, 255, 255);
directionalLight(255, 255, 255, 1, 1, -1);
drawsphere();
if(pollutionpatternon == true){
pollutionpattern();
}
}
void drawsphere(){
lights();
float r = 50;
for(int i = 0; i < total; i ++){
float lat = map(i, 0,total,-HALF_PI,HALF_PI);
for(int j = 0; j <total; j ++){
float lon = map(j, 0,total,-PI,PI);
float x = r * sin(lon)*cos(lat);
float y = r * sin(lon)*sin(lat);
float z = r * cos(lon);
globe[i][j] = new PVector(x,y,z);
}
}
for(int i = 0; i < total; i ++){
for(int j = 0; j <total; j ++){
PVector v = globe[i][j];
stroke(20);
strokeWeight(2);
point(v.x, v.y, v.z);
}
}
}
void pollutionpattern(){
ellipse(300,100,100,100);
}
Answers
First, please edit your post and format your code:
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text#latest
I'm not sure if I understand exactly what effect you are trying to create -- do you want 3D objects to be clickable, or do you want a 2D interface to control a 3D view? Check out the previous thread below and see if either:
hint()
...would help solve your problem.
- https://forum.processing.org/two/discussion/comment/97765/#Comment_97765
Hi jeremydouglass,
Thanks for your reply. I was not aware of the HUD of peasycam. Will try that out first. I want to have two graphics 2D interface to control vector in 3D shape
Good luck and follow up here is you have further questions, @joannajoanna
Hi jeremydouglass,
I am still working trying out using peasycam with GUI. but peasycam works with shapes (Think I have to use hint with GUI...)
Thanks for the example and discussion link! that was really helpful