Loading...
Logo
Processing Forum
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 ^^



Copy code
  1. import saito.objloader.*;
  2. import java.lang.reflect.*;
  3. import java.awt.Frame;
  4. import java.awt.BorderLayout;
  5. import controlP5.*;
  6. private ControlP5 cp5;
  7. ControlFrame cf;
  8. Renderer renderers[];
  9. PShape s;
  10. float rotX;
  11. float rotY;
  12. public int DeplacerX = 0;
  13. public int DeplacerY = 0;
  14. public int RotationX = 0;
  15. public int RotationY = 0;
  16. public int RotationZ = 0;
  17. public int Importer = 0;
  18. public int DEMONSTRATION ;
  19. public float Echelle = 1.00;
  20. PVector A, B, C, D, CENTRE;
  21. void setup() {
  22.   size(displayHeight, displayHeight, P3D);
  23.   //size(800,600,P3D);
  24.   background(0);
  25.   // Description des points de l'écran
  26.   A = new PVector(0, 0, 0);
  27.   B = new PVector(width, 0, 0);
  28.   C = new PVector(width, height, 0);
  29.   D = new PVector(0, height, 0);
  30.   CENTRE = new PVector(width/2, height/2, 0);
  31.   ///DECLARATION MODEL
  32.   s = loadShape("test.obj");
  33.   cp5 = new ControlP5(this);
  34.   cf = addControlFrame("SUPER-SET", 550, 200);
  35.   renderers = new Renderer[4];
  36.   renderers[0] = new Renderer(this, width, height/2, D, C, CENTRE);
  37.   renderers[1] = new Renderer(this, width, height/2, A, B, CENTRE);
  38.   renderers[2] = new Renderer(this, width/2, height, A, D, CENTRE);
  39.   renderers[3] = new Renderer(this, width/2, height, B, C, CENTRE);
  40.   // Set views // VIEW ROTATION WARNING
  41.   renderers[0].setRotation( 270, 0, 0);
  42.   renderers[1].setRotation( 270, 90, 0); // NICKEL A TESTER sur installation (toutes)
  43.   renderers[2].setRotation( 90, 180, 0);
  44.   renderers[3].setRotation( 90, 90, 0);
  45. }
  46. void draw()
  47. {
  48.   for (int i=0;i<renderers.length;i++) {
  49.     renderers[i].draw();
  50.   }
  51.   ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
  52.     Frame f = new Frame(theName);
  53.     ControlFrame p = new ControlFrame(this, theWidth, theHeight);
  54.     f.add(p);
  55.     p.init();
  56.     f.setTitle(theName);
  57.     f.setSize(p.w, p.h);
  58.     f.setLocation(100, 100);
  59.     f.setResizable(false);
  60.     f.setVisible(true);
  61.     return p;
  62.   }
  63.   drawRenderer(0);
  64.   drawRenderer(1);
  65.   drawRenderer(2);
  66.   drawRenderer(3);
  67.   /*
  68. tint(255,255,255,60);
  69.    image(renderers[0].pg, 0, 0);
  70.    */
  71. }
  72. void drawRenderer(int which)
  73. {
  74.   Renderer r = renderers[which];
  75.   noStroke();
  76.   fill(255, 255);
  77.   beginShape(TRIANGLES);
  78.   textureMode(NORMAL);
  79.   texture(r.pg);
  80.   if (which == 0) {
  81.     vertex(r.A.x, r.A.y, 0, 1);
  82.     vertex(r.B.x, r.B.y, 1, 1);
  83.     vertex(r.C.x, r.C.y, 0.5, 0);
  84.   }
  85.   else
  86.     if (which == 1)
  87.     {
  88.       vertex(r.A.x, r.A.y, 0, 0);
  89.       vertex(r.B.x, r.B.y, 1, 0);
  90.       vertex(r.C.x, r.C.y, 0.5, 1);
  91.     }
  92.     else
  93.       if (which == 2)
  94.       {
  95.         vertex(r.A.x, r.A.y, 0, 0);
  96.         vertex(r.B.x, r.B.y, 0, 1);
  97.         vertex(r.C.x, r.C.y, 1, 0.5);
  98.       }
  99.       else
  100.         if (which == 3)
  101.         {
  102.           vertex(r.A.x, r.A.y, 1, 0);
  103.           vertex(r.B.x, r.B.y, 1, 1);
  104.           vertex(r.C.x, r.C.y, 0, 0.5);
  105.         }
  106.   endShape();
  107.   noFill();
  108.   stroke(255, 0, 0);
  109.   //  triangle(r.A.x,r.A.y,r.B.x,r.B.y,r.C.x,r.C.y);
  110. }
  111. //// IMPORTATEUR
  112. /*public void Importer(int theValue) {
  113.  //selectInput("Select a file to process:", "fileselected");
  114.  }
  115.  
  116.  void fileSelected(File selection) {
  117.  if (selection == null) {
  118.  println("Window was closed or the user hit cancel.");
  119.  }
  120.  else {
  121.  println("User selected " + selection.getAbsolutePath());
  122.  model = new OBJModel(this, "fileSelected", "relative", QUADS);
  123.  model.enableDebug();
  124.  
  125.  }
  126.  }*/
  127. void drawRendererObject(Renderer r) //METTRE 3D A LA PLACE?
  128. {
  129.   float fov = PI/4.0;
  130.   float cameraZ = (height/2.0) / tan(fov/2.0);
  131.   r.graphics().rotateX( map((RotationX+rotX)*5, 0, width, 0, PI) );
  132.   r.graphics().rotateY( map((RotationY+rotY)*5, 0, width, 0, PI) );
  133.   r.graphics().rotateZ( map(RotationZ*5, 0, width, 0, PI) );
  134.   r.graphics().translate(DeplacerX, 0, DeplacerY);
  135.   r.graphics().scale(Echelle);
  136.   r.graphics().lights();
  137.   r.graphics().shape(s, 0, 0);
  138.   //dessin :
  139.   //*
  140.   r.graphics().fill(255);
  141.   r.graphics().strokeWeight(0);
  142.   r.graphics().box(60);
  143.   r.graphics().translate(0, 60, 0);
  144.   r.graphics().fill(#74E9FF);
  145.   r.graphics().sphere(30);
  146.   r.graphics().sphereDetail(20);
  147.   // */
  148. }
  149. void mouseDragged()
  150. {
  151.   rotY += (mouseX - pmouseX)  ;
  152.   rotX -= (mouseY - pmouseY)  ;
  153. }


Copy code
  1. public class ControlFrame extends PApplet {
  2.   int w, h;
  3.   int abc = 100;
  4.   public void setup() {
  5.     size(w, h);
  6.     frameRate(25);
  7.     cp5 = new ControlP5(this);
  8.     cp5.addSlider("abc").setRange(0, 255).setPosition(10, 10);
  9.     cp5.addSlider("def").plugTo(parent, "def").setRange(0, 255).setPosition(10, 30);
  10.     cp5.addSlider("RotationX")
  11.       .setRange(0, 360)
  12.         .setPosition(20, 30)
  13.           .setSize(200, 15)
  14.            
  15.               ;
  16.     cp5.addSlider("RotationY")
  17.       .setRange(0, 360)
  18.         .setPosition(20, 60)
  19.           .setSize(200, 15)
  20.            
  21.               ;
  22.     cp5.addSlider("RotationZ")
  23.       .setRange(0, 360)
  24.         .setPosition(20, 90)
  25.           .setSize(200, 15)
  26.            
  27.               ;
  28.     //////DEPLACEMENTS
  29.     cp5.addSlider("DeplacerX")
  30.       .setRange(-100, 100)
  31.         .setPosition(280, 30)
  32.           .setSize(200, 15)
  33.            
  34.               ;
  35.     cp5.addSlider("DeplacerY")
  36.       .setRange(-120, 120)
  37.         .setPosition(280, 60)
  38.           .setSize(200, 15)
  39.            
  40.               ;
  41.     /////OPTIONS
  42.     cp5.addSlider("Echelle")
  43.       .setRange(-1, 5)
  44.         .setPosition(20, 125)
  45.           .setSize(200, 15)
  46.            
  47.               ;
  48.     cp5.addButton("Importer")
  49.       .setValue(0)
  50.         .setPosition(20, 155)
  51.           .setSize(100, 20)
  52.            
  53.               ;
  54.   }
  55.   public void draw() {
  56.     background(0);
  57.   }
  58.   private ControlFrame() {
  59.   }
  60.   public ControlFrame(Object theParent, int theWidth, int theHeight) {
  61.     parent = theParent;
  62.     w = theWidth;
  63.     h = theHeight;
  64.   }
  65.   public ControlP5 control() {
  66.     return cp5;
  67.   }
  68.   ControlP5 cp5;
  69.   Object parent;
  70. }

Copy code
  1. class Renderer
  2. {
  3.   PApplet applet;
  4.   PGraphics pg;
  5.   PVector transfoRotation;
  6.   PVector position;
  7.   PVector dimension;
  8.   Method methodDrawObject;
  9.   PVector A,B,C;
  10.   Renderer(PApplet applet, float w, float h, PVector A_, PVector B_, PVector C_)
  11.   {
  12.     this.applet = applet;
  13.     this.pg = createGraphics(int(w), int(h), P3D);
  14.     this.pg.sphereDetail(7);
  15.     //position = new PVector(x, y, 0);
  16.     A = A_.get();
  17.     B = B_.get();
  18.     C = C_.get();
  19.     dimension = new PVector(w, h, 0);
  20.     transfoRotation = new PVector(0, 0, 0);
  21.     try
  22.     {
  23.       this.methodDrawObject = applet.getClass().getMethod("drawRendererObject", new Class[] {
  24.         Renderer.class
  25.       }
  26.       );
  27.       System.out.println("- \"findMethodFrame\" found.");
  28.     }
  29.     catch (Exception e)
  30.     {
  31.       System.out.println("- no \"findMethodFrame\" found.");
  32.     }
  33.   }
  34.   PGraphics graphics() {
  35.     return pg;
  36.   }
  37.   void setRotation(float x, float y, float z)
  38.   {
  39.     transfoRotation.set(x, y, z);
  40.   }
  41.   void draw()
  42.   {
  43.     pg.beginDraw();   
  44.     pg.background(0);//
  45.     //pg.background(0, 100);
  46.     pg.translate(pg.width/2, pg.height/2);
  47.     //pg.translate(DeplacerX,DeplacerY,0);
  48.     pg.rotateX(radians(transfoRotation.x));
  49.     pg.rotateY(radians(transfoRotation.y));
  50.     pg.rotateY(radians(transfoRotation.z));
  51.     //drawAxis(100);
  52.     pg.pushMatrix();
  53.     try {
  54.       if (methodDrawObject!=null)
  55.       methodDrawObject.invoke( applet, new Object[] {
  56.         this
  57.       }
  58.       );
  59.     }
  60.     catch(Exception e) {
  61.     }
  62.     pg.popMatrix();
  63.     pg.endDraw();
  64.     //image(pg, position.x, position.y, dimension.x, dimension.y);
  65.   }
  66.   /* void drawAxis(float l)
  67.    {
  68.   
  69.    //Axes d'ajustement :
  70.   
  71.    pg.pushStyle();
  72.    pg.stroke(255, 0, 0);
  73.    pg.line(0, 0, 0, l, 0, 0);
  74.    pg.stroke(0, 255, 0);
  75.    pg.line(0, 0, 0, 0, l, 0);
  76.    pg.stroke(0, 0, 255);
  77.    pg.line(0, 0, 0, 0, 0, l);
  78.    pg.popStyle();
  79.    }*/
  80. }