Intranet Catprocess
  1. news...
  2. about Blackvoxel
  3. download
  4. manual
  5. videos
  6. about us
  1. 3D Photo Image Deformation

    // 3D PHOTO IMAGE DEFORMATION
    
    init<-0;
    factor<-0;
    FadeIn<-0;
    FadeFactor<-0;
    
    // This function is called repeatedly for each step of the robot.
    
    function Voxel_Step() 
    {
      local x,y,z,i,u,v, Color;
      
      // Startup code, build the environnment. Executes only once.
      
      if (init ==0)
      {
        init = 1;
        Image_New(0,32,32);
        Image_Clear(0,0);  
        Image_Load(1,GetPath(4)+GetInfo(20)+"Photo_2.bmp");
      }
      
      // Compute deformation height map
      
      for (x=0;x<32;x++)
        for (y=0;y<32;y++)
        {
          u = sin(y*0.09817477*3.2);
          v = sin(x*0.09817477*3.2);
          u = (u*v*sin(factor)*10+10)*FadeFactor;
          Image_SetPixel(0,x,y, u.tointeger());
        }
      
      // Draw the photo image in the world according to the above height map.
      
      for (x=0;x<32;x++)
        for(z=0;z<32;z++)
          for (y=0;y<20;y++)
          {
            Color = 7-(Image_GetPixel(1,x,31-z) & 255) / 32;
            UNF_PlaceVoxel3D(x+1,y,z, (Image_GetPixel(0,x,31-z) >= y) ? Color+216:0);
          }
          
      // Animate by changing values.
      
      factor+=0.1;
      if (FadeIn>1.0) { if (FadeFactor < 1.0) FadeFactor+=0.025; }
      FadeIn += 0.025;
    }
    
    
     
  2. Google+