CONTROLP5 and fullscreen (optionnal)
in
Contributed Library Questions
•
9 months ago
Hellooooo everyone!
I'have a little question about Control Frame, i just updated a code, i was using ControlWindows, and i updated it to ControlFrame.
But now, everything is ok in the code, exepted... "unexpected token, void" and it show me the "void setup()", so i'm a little bit lost and i don't know what to do with it.
Can you help me?
My other question, is how to open the main window, in a other sceen, i saw the library fullscreen, but it's to old for my processing version, and i really don't want to change all of my code (who is too actual), to use an old librairy.
Here is the code, and class, i know, this is a big mess, but don't be affraid, i really need the controlFrame at first ^^
thanks to all of you for any respond ^^
I'have a little question about Control Frame, i just updated a code, i was using ControlWindows, and i updated it to ControlFrame.
But now, everything is ok in the code, exepted... "unexpected token, void" and it show me the "void setup()", so i'm a little bit lost and i don't know what to do with it.
Can you help me?
My other question, is how to open the main window, in a other sceen, i saw the library fullscreen, but it's to old for my processing version, and i really don't want to change all of my code (who is too actual), to use an old librairy.
Here is the code, and class, i know, this is a big mess, but don't be affraid, i really need the controlFrame at first ^^
thanks to all of you for any respond ^^
- import saito.objloader.*;
- import java.lang.reflect.*;
- import java.awt.Frame;
- import java.awt.BorderLayout;
- import controlP5.*;
- private ControlP5 cp5;
- ControlFrame cf;
- Renderer renderers[];
- PShape s;
- float rotX;
- float rotY;
- public int DeplacerX = 0;
- public int DeplacerY = 0;
- public int RotationX = 0;
- public int RotationY = 0;
- public int RotationZ = 0;
- public int Importer = 0;
- public int DEMONSTRATION ;
- public float Echelle = 1.00;
- PVector A, B, C, D, CENTRE;
- void setup() {
- size(displayHeight, displayHeight, P3D);
- //size(800,600,P3D);
- background(0);
- // Description des points de l'écran
- A = new PVector(0, 0, 0);
- B = new PVector(width, 0, 0);
- C = new PVector(width, height, 0);
- D = new PVector(0, height, 0);
- CENTRE = new PVector(width/2, height/2, 0);
- ///DECLARATION MODEL
- s = loadShape("test.obj");
- cp5 = new ControlP5(this);
- cf = addControlFrame("SUPER-SET", 550, 200);
- renderers = new Renderer[4];
- renderers[0] = new Renderer(this, width, height/2, D, C, CENTRE);
- renderers[1] = new Renderer(this, width, height/2, A, B, CENTRE);
- renderers[2] = new Renderer(this, width/2, height, A, D, CENTRE);
- renderers[3] = new Renderer(this, width/2, height, B, C, CENTRE);
- // Set views // VIEW ROTATION WARNING
- renderers[0].setRotation( 270, 0, 0);
- renderers[1].setRotation( 270, 90, 0); // NICKEL A TESTER sur installation (toutes)
- renderers[2].setRotation( 90, 180, 0);
- renderers[3].setRotation( 90, 90, 0);
- }
- void draw()
- {
- for (int i=0;i<renderers.length;i++) {
- renderers[i].draw();
- }
- ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
- Frame f = new Frame(theName);
- ControlFrame p = new ControlFrame(this, theWidth, theHeight);
- f.add(p);
- p.init();
- f.setTitle(theName);
- f.setSize(p.w, p.h);
- f.setLocation(100, 100);
- f.setResizable(false);
- f.setVisible(true);
- return p;
- }
- drawRenderer(0);
- drawRenderer(1);
- drawRenderer(2);
- drawRenderer(3);
- /*
- tint(255,255,255,60);
- image(renderers[0].pg, 0, 0);
- */
- }
- void drawRenderer(int which)
- {
- Renderer r = renderers[which];
- noStroke();
- fill(255, 255);
- beginShape(TRIANGLES);
- textureMode(NORMAL);
- texture(r.pg);
- if (which == 0) {
- vertex(r.A.x, r.A.y, 0, 1);
- vertex(r.B.x, r.B.y, 1, 1);
- vertex(r.C.x, r.C.y, 0.5, 0);
- }
- else
- if (which == 1)
- {
- vertex(r.A.x, r.A.y, 0, 0);
- vertex(r.B.x, r.B.y, 1, 0);
- vertex(r.C.x, r.C.y, 0.5, 1);
- }
- else
- if (which == 2)
- {
- vertex(r.A.x, r.A.y, 0, 0);
- vertex(r.B.x, r.B.y, 0, 1);
- vertex(r.C.x, r.C.y, 1, 0.5);
- }
- else
- if (which == 3)
- {
- vertex(r.A.x, r.A.y, 1, 0);
- vertex(r.B.x, r.B.y, 1, 1);
- vertex(r.C.x, r.C.y, 0, 0.5);
- }
- endShape();
- noFill();
- stroke(255, 0, 0);
- // triangle(r.A.x,r.A.y,r.B.x,r.B.y,r.C.x,r.C.y);
- }
- //// IMPORTATEUR
- /*public void Importer(int theValue) {
- //selectInput("Select a file to process:", "fileselected");
- }
- void fileSelected(File selection) {
- if (selection == null) {
- println("Window was closed or the user hit cancel.");
- }
- else {
- println("User selected " + selection.getAbsolutePath());
- model = new OBJModel(this, "fileSelected", "relative", QUADS);
- model.enableDebug();
- }
- }*/
- void drawRendererObject(Renderer r) //METTRE 3D A LA PLACE?
- {
- float fov = PI/4.0;
- float cameraZ = (height/2.0) / tan(fov/2.0);
- r.graphics().rotateX( map((RotationX+rotX)*5, 0, width, 0, PI) );
- r.graphics().rotateY( map((RotationY+rotY)*5, 0, width, 0, PI) );
- r.graphics().rotateZ( map(RotationZ*5, 0, width, 0, PI) );
- r.graphics().translate(DeplacerX, 0, DeplacerY);
- r.graphics().scale(Echelle);
- r.graphics().lights();
- r.graphics().shape(s, 0, 0);
- //dessin :
- //*
- r.graphics().fill(255);
- r.graphics().strokeWeight(0);
- r.graphics().box(60);
- r.graphics().translate(0, 60, 0);
- r.graphics().fill(#74E9FF);
- r.graphics().sphere(30);
- r.graphics().sphereDetail(20);
- // */
- }
- void mouseDragged()
- {
- rotY += (mouseX - pmouseX) ;
- rotX -= (mouseY - pmouseY) ;
- }
- public class ControlFrame extends PApplet {
- int w, h;
- int abc = 100;
- public void setup() {
- size(w, h);
- frameRate(25);
- cp5 = new ControlP5(this);
- cp5.addSlider("abc").setRange(0, 255).setPosition(10, 10);
- cp5.addSlider("def").plugTo(parent, "def").setRange(0, 255).setPosition(10, 30);
- cp5.addSlider("RotationX")
- .setRange(0, 360)
- .setPosition(20, 30)
- .setSize(200, 15)
- ;
- cp5.addSlider("RotationY")
- .setRange(0, 360)
- .setPosition(20, 60)
- .setSize(200, 15)
- ;
- cp5.addSlider("RotationZ")
- .setRange(0, 360)
- .setPosition(20, 90)
- .setSize(200, 15)
- ;
- //////DEPLACEMENTS
- cp5.addSlider("DeplacerX")
- .setRange(-100, 100)
- .setPosition(280, 30)
- .setSize(200, 15)
- ;
- cp5.addSlider("DeplacerY")
- .setRange(-120, 120)
- .setPosition(280, 60)
- .setSize(200, 15)
- ;
- /////OPTIONS
- cp5.addSlider("Echelle")
- .setRange(-1, 5)
- .setPosition(20, 125)
- .setSize(200, 15)
- ;
- cp5.addButton("Importer")
- .setValue(0)
- .setPosition(20, 155)
- .setSize(100, 20)
- ;
- }
- public void draw() {
- background(0);
- }
- private ControlFrame() {
- }
- public ControlFrame(Object theParent, int theWidth, int theHeight) {
- parent = theParent;
- w = theWidth;
- h = theHeight;
- }
- public ControlP5 control() {
- return cp5;
- }
- ControlP5 cp5;
- Object parent;
- }
- class Renderer
- {
- PApplet applet;
- PGraphics pg;
- PVector transfoRotation;
- PVector position;
- PVector dimension;
- Method methodDrawObject;
- PVector A,B,C;
- Renderer(PApplet applet, float w, float h, PVector A_, PVector B_, PVector C_)
- {
- this.applet = applet;
- this.pg = createGraphics(int(w), int(h), P3D);
- this.pg.sphereDetail(7);
- //position = new PVector(x, y, 0);
- A = A_.get();
- B = B_.get();
- C = C_.get();
- dimension = new PVector(w, h, 0);
- transfoRotation = new PVector(0, 0, 0);
- try
- {
- this.methodDrawObject = applet.getClass().getMethod("drawRendererObject", new Class[] {
- Renderer.class
- }
- );
- System.out.println("- \"findMethodFrame\" found.");
- }
- catch (Exception e)
- {
- System.out.println("- no \"findMethodFrame\" found.");
- }
- }
- PGraphics graphics() {
- return pg;
- }
- void setRotation(float x, float y, float z)
- {
- transfoRotation.set(x, y, z);
- }
- void draw()
- {
- pg.beginDraw();
- pg.background(0);//
- //pg.background(0, 100);
- pg.translate(pg.width/2, pg.height/2);
- //pg.translate(DeplacerX,DeplacerY,0);
- pg.rotateX(radians(transfoRotation.x));
- pg.rotateY(radians(transfoRotation.y));
- pg.rotateY(radians(transfoRotation.z));
- //drawAxis(100);
- pg.pushMatrix();
- try {
- if (methodDrawObject!=null)
- methodDrawObject.invoke( applet, new Object[] {
- this
- }
- );
- }
- catch(Exception e) {
- }
- pg.popMatrix();
- pg.endDraw();
- //image(pg, position.x, position.y, dimension.x, dimension.y);
- }
- /* void drawAxis(float l)
- {
- //Axes d'ajustement :
- pg.pushStyle();
- pg.stroke(255, 0, 0);
- pg.line(0, 0, 0, l, 0, 0);
- pg.stroke(0, 255, 0);
- pg.line(0, 0, 0, 0, l, 0);
- pg.stroke(0, 0, 255);
- pg.line(0, 0, 0, 0, 0, l);
- pg.popStyle();
- }*/
- }
1