Here's a processing version of the code i posted above.
Change the NUM_TILES variables to alter the size of the final image. A value of 12 produces a 12xwidthx12xheight size image. I just made one of 10248x10248 pixels.
Be sure to increase your VM memory!
http://processing.org/faq/bugs.html#memory
Code:
import processing.opengl.*;
float FOV = 60; // Set the initial field of view
float cameraZ;
boolean saveThis=false;
int NUM_TILES = 12;
void setup()
{
size(850, 850, P3D);
noStroke();
fill(0, 102, 153, 26);
cameraZ = (height/2.0) / tan(PI * FOV / 360.0);
}
void draw()
{
int x=0,y=0;
float left,right,bottom,top;
background(0);
camera(width/2.0, height/2.0, cameraZ, width/2.0, height/2.0, 0, 0, 1, 0);
frustum(-width/2, width/2, -height/2, height/2, cameraZ, 1000);
renderScreen();
if(saveThis) {
saveThis=false;
saveScreen();
}
}
void mouseReleased() {
saveThis=true;
}
void renderScreen() {
// Draw something cool
translate(width/2, height/2, 0);
scale(height/20);
rotateX(radians(-30));
rotateY(radians(35));
for(int j1 = 0; j1 < 10; j1++) {
for(int j2 = 0; j2 < 10; j2++) {
for(int j3 = 0; j3 < 10; j3++) {
pushMatrix();
translate(j1-4.5, j2-4.5, j3-4.5);
fill(240-j1*25, 240-j2*25, 15+j3*25);
box(.75);
popMatrix();
}
}
}
}
void saveScreen() {
int x=0,y=0,index=0;
float left,right,bottom,top;
PImage img = new PImage(width*NUM_TILES,height*NUM_TILES,RGB);
for (y = 0; y < NUM_TILES;y++) {
for (x = 0; x < NUM_TILES;x++) {
println("saving "+x+"-" + y+"...");
left = (float)(-width/2) + (float)x*width/NUM_TILES;
right = (float)(-width/2) + (float)((x+1)*width)/NUM_TILES;
bottom = (float)(-height/2) + (float)(y*height)/NUM_TILES;
top = (float)(-height/2) + (float)((y+1)*height)/NUM_TILES;
background(0);
camera(width/2.0, height/2.0, cameraZ, width/2.0, height/2.0, 0, 0, 1, 0);
frustum(left, right, bottom, top, cameraZ, 1000);
// Call the rendering function
renderScreen();
loadPixels();
// After rendering each tile,
// we read the framebuffer contents into our bitmap.
for (int i=0; i < height;i++) {
//Shift to the correct scanline
index = (((y)*height)*(width*NUM_TILES) + (width*x) + i*(width*NUM_TILES));
// Read a line from the framebuffer
for(int j=0; j < width;j++) {
img.pixels[index+j] = pixels[i*height+j];
}
}
}
}
img.save("/home/grimus/processing/test.tga");
}