Mostrando entradas con la etiqueta Cámara. Mostrar todas las entradas
Mostrando entradas con la etiqueta Cámara. Mostrar todas las entradas

viernes, 29 de abril de 2016

De P.O.O., uso de la cámara e Importación de archivos OBJ en Processing.



Código:

La clase Piso

class Piso{

    int Sx, Sy, Sz; //parametros de escala
    int CF;
 
    void Poner(int sx, int sy, int sz, int c, int a){
      Sx = sx; Sy = sy; Sz = sz;
      CF = c;
   
      noStroke();
      noFill();
      pushMatrix();
      translate(width/2,height/2,0);
      scale(Sx,Sy,Sz);
      //rotateX(radians(a));
      fill(CF);
      box(1); //vertex o primitivas un cuadrado, etc.
      popMatrix();
    }
}

Sketch principal

Piso p1 = new Piso();
int angulo = 90;

void setup(){

  size(800,600,P3D);
  smooth();

  lights();
}

void draw(){
  background(500);

  //rotateY(radians(((mouseX/(float)width)*200)-90));
  //rotateX(radians(((mouseY/(float)width)*200)-90));
  camera(800, 0, 10, width/2, height/2, 0, 0, 1, 0);


  p1.Poner(400,1,400,255,angulo);

 
}





Código:

void setup(){

    size(600,600,P3D);
 
    //camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
    camera(700,700,700,0,0,0,1,0,0);

}

void draw(){

  background(0);

  stroke(255);
  noFill();
  box(600);
}






Código:

PShape s; //declaramos un objeto tipo PShape
int x = -30;

void setup(){
 
  size(300,300,P3D);
 
  //inicializamos el objeto con el nombre del archivo obj
  s = loadShape("table lamp.obj");
  frameRate(20); //30

}

void draw(){
 
  background(0);
  //translate(width/2,height/2);
  lights();
  translate(x,height/2);
  rotateX(radians(mouseY));
  shape(s, 0,0);
 
  x++;
 
  if(x == 350)
    x = -30;

}