Posted 8/5/2012 01:05:00

This is based on something my current roommate did to me. When he put his dishes into the cabinet, he somehow loaded them so that when I opened the door, a couple of my glasses fell out of the cabinet and shattered. I ended up with cuts on my hand from the broken glass. I wanted to kill him. Fortunately, however, it is not illegal to kill a robot...

So far I haven't discussed much how I make these comics. I use POV-Ray 3.6 to do the rendering of the images, and almost all the code I use I write myself. A prominent exception is the trees that occur in some scenes. I use the "maketree" macro by Gilles Tran for those. In this comic, I needed to make glasses and plates shatter. I'm sure it's probably been done before, but I decided to write my own macro, that I called "makeshatter", to do the job:

#macro shatter(obj,maxnpcs,pieces,sd,tex)
 #local breakingobj=obj;
 #declare pieces=array[maxnpcs];
 #local pc=1;   
 #local rng=seed(sd);
 #local maxex=max_extent(obj);
 #local minex=min_extent(obj);
 #local siz=maxex-minex;
 #local vol=siz.x*siz.y*siz.z; 
 #local rad=pow(vol/maxnpcs,1/3);
 #while (pc*(maxex-minex);
  #local endpt2=maxex-*(maxex-minex); 
  #local endpt3=maxex-*(maxex-minex);
  #local endpt4=maxex-*(maxex-minex);
  #local blb=blob{threshold 0.6
             cylinder{endpt1,endpt2,rad,1}
             cylinder{endpt3,endpt4,rad,1} 
             texture{tex}
             };
  //#warning str(pc,5,0)
  #declare pieces[pc] = intersection{object{breakingobj} object{blb}};
  #local breakingobj= difference{object{breakingobj} object{blb}};
  
  #local pc=pc+1;
 #end 
  

#end 

//makeshatter:
// Parameters:
//   obj        input   object    Object to shatter
//   numpc      input   integer   Number of pieces to break into
//   sd         input   integer   Random number generator seed
//   debrisdiam input   float     Maximum distance from center to scatter debris
//   tex        input   texture   Texture for edges of shattered object    
//
#macro makeshatter(obj,numpc,sd,debrisdiam,tex)
union{
      //#local numpc=20;
      #local pieces=array[numpc];
      shatter(obj,numpc,pieces,sd,tex)
      #local rng=seed(sd*25+3);
      #local pc=1;
      #while (pc} 
       #local pc=pc+1;
      #end
}
#end

Another note on this comic: I included the song that the robot is singing as a bit of an homage to Questionable Content, one of the more popular webcomics out there. The song that comic is quoting is this one, which sort of sounds like it's being sung by a robot to me.

Transcript