2016年12月29日 星期四

許君平 1229 上課筆記

2016/12/29

1.3D掃描
*Voxxlr
http://www.voxxlr.com/

















*Project Tango Test in my Room
https://www.youtube.com/watch?v=PMou8eIRzMk





*kinectfusion

https://www.youtube.com/watch?v=quGhaggn3cQ




*深度攝影機ToF Camera Noise of Kinect for Windows Ver.2.0

https://www.youtube.com/watch?v=CKuAqnwEjgM



*Q: 那戶外大型建築怎麼掃描?
A: 義大利有許多大型的雕像,可能5-10公尺高, "數位米開朗基羅計畫" 由跨國的團隊,把大型的雕像掃描起來。
https://graphics.stanford.edu/projects/mich/more-david/more-david.html



2.processing實作
*binvox
http://www.patrickmin.com/binvox/




int xRes,yRes,zRes, bunny[][][], inside[][][], millis0;
float angleX=0, angleY=0, myScale=1;
void setup(){
  size(600,400,P3D);
  byte b[]=loadBytes("bunny40.mira");//("bunny80.mira");
  xRes=((b[8] &0x00FF)<<8)+(b[9] &0x00FF);
  yRes=((b[10]&0x00FF)<<8)+(b[11]&0x00FF);
  zRes=((b[12]&0x00FF)<<8)+(b[13]&0x00FF);
  myScale=0.3*width/float(xRes);
  bunny=new int[xRes][yRes][zRes]; inside=new int[xRes][yRes][zRes];
  for(int i=0;i<xRes*yRes*zRes;i++){
    int x=int(i/(yRes*zRes)), y=int(i/zRes)%yRes, z=i%zRes;
    bunny[x][y][z]=b[256+(xRes+yRes+zRes)*8+i];
  }
  for(int i=1;i<xRes-1;i++)
    for(int j=1;j<yRes-1;j++)
      for(int k=1;k<zRes-1;k++)
        if(bunny[i-1][j][k]!=0 && bunny[i+1][j][k]!=0 && bunny[i][j-1][k]!=0 && bunny[i][j+1][k]!=0
            && bunny[i][j][k-1]!=0 && bunny[i][j][k+1]!=0) inside[i][j][k]=1;
}
void draw(){
  println("fps: "+frameRate);
  background(128); noStroke();
  pointLight(128,255,128, width, height, height);
  directionalLight(30,30,30, 0,0,-1);
  directionalLight(40,40,40, 0,1,-1); 
  translate(width/2,height/2,0);
  rotateX(-angleY);
  rotateY(angleX);
  rotateX(PI/2);
  scale(myScale);
  translate(-xRes,-yRes,-zRes);
  for(int i=0;i<xRes;i++){
    for(int j=0;j<yRes;j++){
      for(int k=0;k<zRes;k++){
        if(bunny[i][j][k]!=0 && inside[i][j][k]==0){
          pushMatrix();
          translate(2*i,2*j,2*k);
          box(2);
          popMatrix();
        }
      }
    }
  }
}
void mouseDragged(){
  angleX+=0.01*(mouseX-pmouseX);
  angleY+=0.01*(mouseY-pmouseY);
}

*火箭範例



*實作1



*實作2-加旋轉、打光


*可以隨著滑鼠旋轉





PShape bunny;

void setup(){
  size(400,400,P3D);
  bunny = loadShape("rocket.obj");
}
void draw(){
  background(255,0,0);
  lights();
  translate(width/2,height/2);
  rotateX(radians(mouseY));
  rotateY(radians(mouseX));
  shape(bunny,0,0);
}




沒有留言:

張貼留言