- cleanup VideoRecorderAppState

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8707 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent fa68e89e6c
commit 0420b4121e
  1. 90
      engine/src/desktop/com/jme3/app/state/VideoRecorderAppState.java

@ -47,53 +47,16 @@ public class VideoRecorderAppState extends AbstractAppState {
super.cleanup(); super.cleanup();
} }
public static final class IsoTimer extends com.jme3.system.Timer {
private float framerate;
private int ticks;
public IsoTimer(float framerate) {
this.framerate = framerate;
this.ticks = 0;
}
public long getTime() {
return (long) (this.ticks * (1.0f / this.framerate));
}
public long getResolution() {
return 1000000000L;
}
public float getFrameRate() {
return this.framerate;
}
public float getTimePerFrame() {
return (float) (1.0f / this.framerate);
}
public void update() {
this.ticks++;
}
public void reset() {
this.ticks = 0;
}
}
public class VideoProcessor implements SceneProcessor { public class VideoProcessor implements SceneProcessor {
Camera camera; private Camera camera;
int width; private int width;
int height; private int height;
FrameBuffer frameBuffer; private FrameBuffer frameBuffer;
RenderManager renderManager; private RenderManager renderManager;
ByteBuffer byteBuffer; private ByteBuffer byteBuffer;
BufferedImage rawFrame; private BufferedImage rawFrame;
int videoChannel = 0; private boolean isInitilized = false;
long currentTimeStamp = 0;
boolean isInitilized = false;
public void initialize(RenderManager rm, ViewPort viewPort) { public void initialize(RenderManager rm, ViewPort viewPort) {
this.camera = viewPort.getCamera(); this.camera = viewPort.getCamera();
@ -130,7 +93,6 @@ public class VideoRecorderAppState extends AbstractAppState {
byteBuffer.clear(); byteBuffer.clear();
renderManager.getRenderer().readFrameBuffer(out, byteBuffer); renderManager.getRenderer().readFrameBuffer(out, byteBuffer);
synchronized (rawFrame) { synchronized (rawFrame) {
rawFrame.getGraphics().clearRect(0, 0, width, height);
Screenshots.convertScreenShot(byteBuffer, rawFrame); Screenshots.convertScreenShot(byteBuffer, rawFrame);
try { try {
writer.addImage(rawFrame); writer.addImage(rawFrame);
@ -138,7 +100,6 @@ public class VideoRecorderAppState extends AbstractAppState {
Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, "Error writing frame: {0}", ex); Logger.getLogger(VideoRecorderAppState.class.getName()).log(Level.SEVERE, "Error writing frame: {0}", ex);
} }
} }
currentTimeStamp += (long) (1000000000.0 / (double) framerate);
} }
public void cleanup() { public void cleanup() {
@ -149,4 +110,39 @@ public class VideoRecorderAppState extends AbstractAppState {
} }
} }
} }
public static final class IsoTimer extends com.jme3.system.Timer {
private float framerate;
private int ticks;
public IsoTimer(float framerate) {
this.framerate = framerate;
this.ticks = 0;
}
public long getTime() {
return (long) (this.ticks * (1.0f / this.framerate));
}
public long getResolution() {
return 1000000000L;
}
public float getFrameRate() {
return this.framerate;
}
public float getTimePerFrame() {
return (float) (1.0f / this.framerate);
}
public void update() {
this.ticks++;
}
public void reset() {
this.ticks = 0;
}
}
} }

Loading…
Cancel
Save