Xj3D 2.0 VRML/X3D Code API

org.xj3d.ui.awt.browser.ogl
Class TimeSensorSceneRecorder

java.lang.Object
  extended by org.xj3d.ui.awt.browser.ogl.TimeSensorSceneRecorder
All Implemented Interfaces:
VRMLNodeListener, ScreenCaptureListener

public class TimeSensorSceneRecorder
extends java.lang.Object
implements ScreenCaptureListener, VRMLNodeListener

A function module that performs a sequenced image capture of an embedded X3D world animation. The requirements of the X3D world are:

The image capture is managed as follows:

Version:
$Revision: 1.4 $
Author:
Rex Melton

Field Summary
protected  java.lang.Object canvas
          The rendering surface
protected  VirtualTimeSensorManager clock
          The clock controller
protected  OGLConstruct construct
          The construct instance to record from
protected  OGLStandardBrowserCore core
          The browser core
protected  ErrorReporter errorReporter
          The error reporting mechanism
protected  long fileTime
          The total file write time
protected  java.text.NumberFormat fmt
          Formatter for creating the image sequence identifier
protected  int fraction_changed_index
          The field index of the time sensor's fraction_changed field.
protected  int height
          The height of the output images
protected  RecorderListener listener
          Listener for recorder status events
protected  int number
          The sequence capture number, used as the file name
protected  java.io.File outputDir
          The output directory for the captured images
protected  boolean recordingComplete
          Flag indicating that the timer sensor has completed a cycle
protected  long renderTime
          The total frame rendering time
protected  long startFrameTime
          The last start of frame rendering time
protected  org.web3d.vrml.renderer.common.nodes.time.BaseTimeSensor timeSensor
          The x3d time sensor node that controls the viewpoint animation
protected  java.lang.String timeSensorName
          The name of the x3d time sensor node that controls the viewpoint animation.
protected  java.lang.String type
          The image encoding type
protected  int width
          The width of the output images
 
Constructor Summary
TimeSensorSceneRecorder(OGLConstruct construct)
          Constructor
 
Method Summary
 void fieldChanged(int index)
          Listener for the end of the animation sequence
 double getAverageFileTime()
          Return the average file write time in milliseconds
 double getAverageRenderTime()
          Return the average frame rendering time in milliseconds
 void saveScreen(java.nio.Buffer buffer, java.lang.String name, int width, int height)
          Process the screen capture buffer into a BufferedImage and save it to a file
 void screenCaptured(java.nio.Buffer buffer)
          Notification of a new screen capture.
 void setEncoding(java.lang.String type)
          Set the image encoding type
 void setFrameRate(int framesPerSecond)
          Set the recording rate
 void setOutputDirectory(java.io.File dir)
          Set the output directory for images
 void setSize(int width, int height)
          Set the image size
 void setTimeSensorName(java.lang.String name)
          Set the DEF'ed name of the time sensor
 void start(RecorderListener listener)
          Initiate the capture sequence
 void stop()
          Terminate the capture sequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

construct

protected OGLConstruct construct
The construct instance to record from


core

protected OGLStandardBrowserCore core
The browser core


clock

protected VirtualTimeSensorManager clock
The clock controller


errorReporter

protected ErrorReporter errorReporter
The error reporting mechanism


canvas

protected java.lang.Object canvas
The rendering surface


number

protected int number
The sequence capture number, used as the file name


fmt

protected java.text.NumberFormat fmt
Formatter for creating the image sequence identifier


timeSensor

protected org.web3d.vrml.renderer.common.nodes.time.BaseTimeSensor timeSensor
The x3d time sensor node that controls the viewpoint animation


timeSensorName

protected java.lang.String timeSensorName
The name of the x3d time sensor node that controls the viewpoint animation. Default value is "TIME"


fraction_changed_index

protected int fraction_changed_index
The field index of the time sensor's fraction_changed field. Used to determine when the time sensor has completed it's cycle


outputDir

protected java.io.File outputDir
The output directory for the captured images


listener

protected RecorderListener listener
Listener for recorder status events


recordingComplete

protected boolean recordingComplete
Flag indicating that the timer sensor has completed a cycle


width

protected int width
The width of the output images


height

protected int height
The height of the output images


type

protected java.lang.String type
The image encoding type


fileTime

protected long fileTime
The total file write time


renderTime

protected long renderTime
The total frame rendering time


startFrameTime

protected long startFrameTime
The last start of frame rendering time

Constructor Detail

TimeSensorSceneRecorder

public TimeSensorSceneRecorder(OGLConstruct construct)
Constructor

Parameters:
construct - The construct instance to record from
Method Detail

screenCaptured

public void screenCaptured(java.nio.Buffer buffer)
Notification of a new screen capture. The buffer will be in openGL pixel order.

Specified by:
screenCaptured in interface ScreenCaptureListener
Parameters:
buffer - The screen capture

fieldChanged

public void fieldChanged(int index)
Listener for the end of the animation sequence

Specified by:
fieldChanged in interface VRMLNodeListener
Parameters:
index - The index of the field that has changed

getAverageRenderTime

public double getAverageRenderTime()
Return the average frame rendering time in milliseconds

Returns:
the average frame rendering time in milliseconds

getAverageFileTime

public double getAverageFileTime()
Return the average file write time in milliseconds

Returns:
the average file write time in milliseconds

setEncoding

public void setEncoding(java.lang.String type)
Set the image encoding type

Parameters:
type - The image encoding type

setSize

public void setSize(int width,
                    int height)
Set the image size

Parameters:
width - The image width
height - The image height

setFrameRate

public void setFrameRate(int framesPerSecond)
Set the recording rate

Parameters:
framesPerSecond - The frames per virtual second to record

setOutputDirectory

public void setOutputDirectory(java.io.File dir)
Set the output directory for images

Parameters:
dir - The output directory for images

setTimeSensorName

public void setTimeSensorName(java.lang.String name)
Set the DEF'ed name of the time sensor

Parameters:
name - The DEF'ed name of the time sensor

start

public void start(RecorderListener listener)
Initiate the capture sequence


stop

public void stop()
Terminate the capture sequence


saveScreen

public void saveScreen(java.nio.Buffer buffer,
                       java.lang.String name,
                       int width,
                       int height)
Process the screen capture buffer into a BufferedImage and save it to a file

Parameters:
buffer - The screen capture buffer
name - The file name prefix
width - The width of the image
height - The height of the image

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium