Annonce

>>> Bienvenue sur codelab! >>> Première visite ? >>> quelques mots sur codelab //// une carte des membres//// (apéros) codelab


#1 2012-11-19 18:57:24 SELECTINPUT() + OBJLOADER

Malleat
membre
Date d'inscription: 2012-04-15
Messages: 148
Site web

SELECTINPUT() + OBJLOADER



Bonjour

Je cherche a intégrer une 3D dans un sketches que voici, mais j'ai un peut du mal avec les PGraphics, a savoir, comment j'y intègre la 3D chargée avec SelectInput() et obj loader.

Cela me retirerais une énorme épine du pieds que de savoir cette simple chose.

En vous remerciant de votre patience

Voici le code:

import controlP5.*;
ControlP5 cp5;
import saito.objloader.*;
import java.lang.reflect.*;

ControlWindow controlWindow;

Renderer renderers[];

OBJModel model;

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 = 0;
public float Echelle = 1.00;


void setup()
{
  size(displayHeight, displayHeight, P3D);
  background(0);
  
///DECLARATION MODEL
  model = new OBJModel(this, "MTECH.obj", "relative", QUADS);
  model.enableDebug();


  cp5 = new ControlP5(this);

  controlWindow = cp5.addControlWindow("controlP5window", 100, 100, 600, 300)
    .hideCoordinates()
      .setBackground(color(150))
        ;
  //////ROTATIONS
  cp5.addSlider("RotationX")
    .setRange(0, 360)
      .setPosition(40, 40)
        .setSize(200, 30)
          .setWindow(controlWindow)
            ;
  cp5.addSlider("RotationY")
    .setRange(0, 360)
      .setPosition(40, 80)
        .setSize(200, 30)
          .setWindow(controlWindow)
            ;
  cp5.addSlider("RotationZ")
    .setRange(0, 360)
      .setPosition(40, 120)
        .setSize(200, 30)
          .setWindow(controlWindow)
            ;

  //////DEPLACEMENTS
  cp5.addSlider("DeplacerX")
    .setRange(-100, 100)
      .setPosition(300, 40)
        .setSize(200, 30)
          .setWindow(controlWindow)
            ;
  cp5.addSlider("DeplacerY")
    .setRange(-120, 120)
      .setPosition(300, 80)
        .setSize(200, 30)
          .setWindow(controlWindow)
            ;

  /////OPTIONS
  cp5.addSlider("Echelle")
    .setRange(0, 10)
      .setPosition(40, 220)
        .setSize(200, 15)
          .setWindow(controlWindow)
            ;

  cp5.addButton("Importer")
    .setValue(0)
      .setPosition(40, 160)
        .setSize(100, 20)
          .setWindow(controlWindow)
            ;
  cp5.addButton("DEMONSTRATION")
    .setValue(0)
      .setPosition(40, 190)
        .setSize(100, 20)
          .setWindow(controlWindow)
            ;



  renderers = new Renderer[4];
  renderers[0] = new Renderer(this, width/4, 0, width/2, height/2);
  renderers[1] = new Renderer(this, width/2, width/4, width/2, height/2);
  renderers[2] = new Renderer(this, width/4, height/2, width/2, height/2);
  renderers[3] = new Renderer(this, 0, height/4, width/2, height/2);

  // 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();
    
  }
}

//// 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();
    //model = ; LAAAAAAAAAA
  }
}

///DEMO NEURON

/*public void DEMONSTRATION(int theValue) {
 DEMONSTRATION = 1
 if (DEMONSTRATION = 1)
 {
 //NEURON?
 }
 }
 */


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); // VERIFIER sur installation
  r.graphics().scale(Echelle);
  r.graphics().lights();
  r.graphics().perspective(fov, float(width*100)/float(height*100), cameraZ/100.0, cameraZ*100.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)  ;
}

et la class RENDERER:

class Renderer
{
  PApplet applet;
  PGraphics pg;
  PVector transfoRotation;
  PVector position;
  PVector dimension;
  Method methodDrawObject;

  Renderer(PApplet applet, float x, float y, float w, float h)
  {
    this.applet = applet;
    this.pg = createGraphics(int(w), int(h), P3D);
    this.pg.sphereDetail(7);

    position = new PVector(x, y, 0);
    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,LIGHTEST);//
    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)
   {
   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();
   }*/
}

Je précise, ceci est un projet de mémoire, et je compte récidiver pour mon diplôme (architecture), je souhaite vraiment apprendre a créer de nouveaux outils pour les architectes.
Ceci est pour moi comme un départ, j'ai vraiment besoin d'aide, car je suis le seul a faire cela dans mon école (et a m'être poser la question de l'outils d'architecture).

Merci a vous.

Dernière modification par Malleat (2012-11-19 19:00:01)


SITE WEB ->REVŒLUTION

Hors ligne

 

#2 2012-11-22 09:57:21 Re : SELECTINPUT() + OBJLOADER

Malleat
membre
Date d'inscription: 2012-04-15
Messages: 148
Site web

Re: SELECTINPUT() + OBJLOADER



is anybody out there (lalalaaa)?


SITE WEB ->REVŒLUTION

Hors ligne

 

#3 2012-11-22 23:50:27 Re : SELECTINPUT() + OBJLOADER

the skull
membre
Lieu: Belgique
Date d'inscription: 2011-07-03
Messages: 55
Site web

Re: SELECTINPUT() + OBJLOADER



Ce que je peux te dire c'est que si tu utilises la 3d dans processing c'est à dire un .obj 
Tu dois dans ton programme 3d l'exporter pour 3dsmax, ensuite l'ouvrir avec meshlab et le réenregistrer en obj.
obj = objet; c'est un format on peux dire universel en 3D.
ne pas oublier de bien placer ton objet dans ton fichier data! et autre chose quand tu es dans mashlab tu dois activer les lumière directionnel dans les options. sinon quelque fois il ne reconnaitra pas les formes.
Dernière précision, ne pas jouer avec les textures dans la 3D et l'importer dans processing, si tu veux rajouter de la texture il faut le faire dans processing. voila voilaaaa

Hors ligne

 

#4 2012-11-23 14:35:57 Re : SELECTINPUT() + OBJLOADER

Malleat
membre
Date d'inscription: 2012-04-15
Messages: 148
Site web

Re: SELECTINPUT() + OBJLOADER



ça j'avais compris, en fait, je cherche plus a IMPORTER la 3D, en la sélectionnant avec "selectInput", il s'agit la d'un visualiseur 3D pour pyramide holographique...
Le programme devant être utilisable par tous, pour tous, je cherche a faire une vraie appli'!

Sur le forum processing international, ils disent qu'ils ne savent pas... sad


SITE WEB ->REVŒLUTION

Hors ligne

 

#5 2012-11-26 11:10:31 Re : SELECTINPUT() + OBJLOADER

Malleat
membre
Date d'inscription: 2012-04-15
Messages: 148
Site web

Re: SELECTINPUT() + OBJLOADER



En fait, ceci est un code que j'ai reçus et modifier... Manque de bol, dans la classe renderer y est intégré une partie en JAVA.

... ça explique pourquoi je ne comprenais RIEN a ce code là. Quelqu'un aurait-il quelques notions la dedans pour m'aider?

yes? no?


SITE WEB ->REVŒLUTION

Hors ligne

 

fil rss de cette discussion : rss

Pied de page des forums

Powered by FluxBB

codelab, graphisme & code : emoc / 2008-2024