High-resolution output file doesn't save perspective set with PeasyCam.

edited April 2014 in Questions about Code

Hello,

I'm using and tweaking the code from a sketch that uses 3 images to produce a 3D scene (Three Phase 3D Scanner).

The original code already had a screenshot option but I needed high-resolution outputs and tried to combine some code from this link alexanno.net/2010/06/high-resolution-output-from-processing-processing-in-hd/.

When I press the "s" key it creates two screenshots: one normal and another with high-resolution. The problem is that the high-resolution image doesn't save the image with the perspective I chose with PeasyCam and makes an image with the initial perspective, while the standard screenshot works perfectly with PeasyCam and saves with the perspective I chose before pressing "s".

Can someone help me?

The sketch has 4 files: ThreePhase.pde, Controls.pde, PhaseWrap.pde and PhaseUnwrap.pde I think the problem is in the code of the first one: (I'm sorry for the long code...)

/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/1995*@* */
/* !do not delete the line above, required for linking your tweak if you upload again */
import peasy.*;
import java.applet.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Image;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.util.regex.*;

int inputWidth = 1100;
int inputHeight = 1100;

PeasyCam cam;

float[][] phase = new float[inputHeight][inputWidth];
boolean[][] mask = new boolean[inputHeight][inputWidth];
boolean[][] process = new boolean[inputHeight][inputWidth];
color[][] colors = new color[inputHeight][inputWidth];     
boolean update;   

void setup() {
  size(inputWidth, inputHeight, P3D);
  cam = new PeasyCam(this, width/1);

  frameRate(60);
  stroke(255); 
  strokeWeight(1);  

  setupControls();         
//  phaseWrap();
//  phaseUnwrap();
  update = true;                
}

void draw () {
  background(0);                                   
  translate(-inputWidth / 2, -inputHeight / 2);  
  noFill();                                        

  int step = 2;
//for (int y = step; y < inputHeight; y += step) {
  for (int y = 0; y < inputHeight; y += renderDetail) {                
    float planephase = 0.5 - (y - (inputHeight / 2)) / zskew;
    for (int x = 0; x < inputWidth; x += renderDetail)          
//  for (int x = step; x < inputWidth; x += step)
      if (!mask[y][x]) {
    stroke(colors[y][x], 255);           
        point(x, y, (phase[y][x] - planephase) * zscale);
      }
  }

  if(update) {                                             
    phaseWrap();
    phaseUnwrap();
    update = false;                                         
  }

  if(takeScreenshot) {
    saveFrame(day() + " " + hour() + " " + minute() + " " + second() + ".png");
    takeScreenshot = false; 
  }                                                            
}

void HiRes_begin() {
    background(0);                                                   
    strokeWeight(1);  

  int step = 2;
  for (int y = 0; y < inputHeight; y += renderDetail) {                  
    float planephase = 0.5 - (y - (inputHeight / 2)) / zskew;
    for (int x = 0; x < inputWidth; x += renderDetail)                 
      if (!mask[y][x]) {
    stroke(colors[y][x], 255);
        point(x, y, (phase[y][x] - planephase) * zscale);
      }
  }
}

void keyPressed() {
  if (key == 's') {
    save("ss_normal.png");
    saveHiRes(4);
    exit();
  }
}

void saveHiRes(int scaleFactor) {
  PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, P3D);
  beginRecord(hires);
  hires.scale(scaleFactor);
  HiRes_begin(
  );
  endRecord();
  hires.save("ss_hires.png");
  println("Frames saved");
}

Answers

Sign In or Register to comment.