xxxxxxxxxx
//This example helps render and export your generative content in panorama, and is required to be compiled and run in Processing IDE.
//Press "r" to record sequence in equirectangular projection.
//Check out this 360° video demo. https://vimeo.com/216337773
PGraphics pgFront, pgBack, pgLeft, pgRight, pgTop, pgBottom, pgCubeMap, pgEqRectMap;
PVector ctr;
int cubeSize = 400;
boolean recordSeq;
void setup(){
size(1200, 900, P3D);
ctr = new PVector(-cubeSize*.5, 0);
pgCubeMap = createGraphics(cubeSize*4, cubeSize*3, P3D);
pgEqRectMap = createGraphics(cubeSize*3, floor(cubeSize*1.5));
pgFront = createGraphics(cubeSize, cubeSize, P3D);
pgBack = createGraphics(cubeSize, cubeSize, P3D);
pgLeft = createGraphics(cubeSize, cubeSize, P3D);
pgRight = createGraphics(cubeSize, cubeSize, P3D);
pgTop = createGraphics(cubeSize, cubeSize, P3D);
pgBottom = createGraphics(cubeSize, cubeSize, P3D);
pgCubeMap.smooth(8);
pgCubeMap.imageMode(CENTER);
initPG(pgFront);
initPG(pgLeft);
initPG(pgRight);
initPG(pgTop);
initPG(pgBottom);
initPG(pgBack);
}
void draw(){
drawPGFront();
drawPGBack();
drawPGLeft();
drawPGRight();
drawPGTop();
drawPGBottom();
drawCubeMap();
image(pgCubeMap, 0, 0, width, height);
if(recordSeq){
translate(15, 30, 1);
fill(255);
textSize(16);
text("Updating and exporting sequence \n with equirectangular projection...", 0, 0);
updateEqRectMap();
pgEqRectMap.save("exportedSeq/seq-"+nf(frameCount, 6)+".jpg");
}
}
void keyReleased(){
if(key == 'r')recordSeq = !recordSeq;
}