We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Everyone,
I have written a code that uses the "controlP5" library. The sketch has some sliders and textboxes. The setup function of the sketch has the information about the position of the gui elements.
So, I want to make a simulation. In fact, I did on other sketch, but I got a size problem when I implement the simulation and the code on the same sketch. Let me explain a bit more about the simulation :
I used P3D to apply the coordinates of the shape by using vertex function.
Here is a quick example of what I did so far :
public class SecondApplet extends PApplet {
public void settings() {
size(1000, 600,P3D);
}
public void setup() {
translate(width/2,height/3, -200);
stroke(255);
noFill();
beginShape();
vertex(-82.27,0,47.5); vertex(0,0,-23.75);
vertex(82.27,0,47.5); vertex(-82.27,0,47.5);
vertex(-270,0,0); vertex(-65,397.5,0);
vertex(32.5,397.5,-56.3); vertex(32.5,397.5,56.3);
vertex(-65,397.5,0); vertex(32.5,397.5,56.3);
vertex(135,0,233.827); vertex(82.27,0,47.5);
vertex(0,0,-23.75); vertex(135,0,-233.827);
vertex(32.5,397.5,-56.3);
endShape();
}
}
void setup() {
size(1000,800);
frameRate(25);
controlP5 = new ControlP5(this);
controlP5.setAutoInitialization(false);
/* Setups of the gui elements ...
-----------------------*/
SecondApplet sa = new SecondApplet();
String[] args = {"TwoFrameTest"};
PApplet.runSketch(args, sa);
updateGuiElements();
}
So, the situation is the size problem on the two windows that I wanted to see when I run the sketch. The main window, which is on the "void setup()" section, is smaller than the second window.
I tried to find out the solution, but I couldn't overcome this problem. What I have to do in order to solve this situation ?
( I tried to explain the problem as well as I can).
I am looking forward to your suggestions. Thanks in advanced.
Have a nice works to all..
Answers
Use settings() for the main sketch as well! L-)
Thanks a lot. It works. :)
Now, I have another problem about this :) Is there any way to control the coordinates within the vertex function by using the slider variables on the main window. For example :
When I did like this, there was no change on the second window.
Clearly, I wanted to control the simulation on the second window by using sliders on the main window. So, I thought I can do this with the code I wrote above. However, as I said that, there was no change. It keep constant.
Thanks in advance..
Check the following demo. Notice you need to explicitly write an empty draw() function to have an interactive slider.
Kf