/** * Calls render for all attached and initialized states, do not call directly. */ public void postRender(){ AppState[] array = getStates(); for (AppState state : array){ if (state.isEnabled()) { state.postRender(); } } }
public MjpegFileWriter(File aviFile, int width, int height, double framerate, int numFrames) throws Exception { this.aviFile = aviFile; this.width = width; this.height = height; this.framerate = framerate; this.numFrames = numFrames; aviOutput = new FileOutputStream(aviFile); aviChannel = aviOutput.getChannel(); RIFFHeader rh = new RIFFHeader(); aviOutput.write(rh.toBytes()); aviOutput.write(new AVIMainHeader().toBytes()); aviOutput.write(new AVIStreamList().toBytes()); aviOutput.write(new AVIStreamHeader().toBytes()); aviOutput.write(new AVIStreamFormat().toBytes()); aviOutput.write(new AVIJunk().toBytes()); aviMovieOffset = aviChannel.position(); aviOutput.write(new AVIMovieList().toBytes()); indexlist = new AVIIndexList(); }
/** * Attaches many state to the AppStateManager in a way that is guaranteed * that they will all get initialized before any of their updates are run. * The same state cannot be attached twice and will be ignored. * * @param states The states to attach */ public void attachAll(Iterable<AppState> states){ synchronized (this.states){ for( AppState state : states ) { attach(state); } } }
/** * Calls update for attached states, do not call directly. * @param tpf Time per frame. */ public void update(float tpf){ // Cleanup any states pending terminatePending(); // Initialize any states pending initializePending(); // Update enabled states AppState[] array = getStates(); for (AppState state : array){ if (state.isEnabled()) { state.update(tpf); } } }
public final <T extends AppState> T getState( Class<T> type, boolean failOnMiss ) { return getStateManager().getState( type, failOnMiss ); }
/** * Returns the first state that is an instance of subclass of the specified class. * @param <T> * @param stateClass * @return First attached state that is an instance of stateClass */ public <T extends AppState> T getState(Class<T> stateClass){ return getState(stateClass, false); }
public byte[] toBytes() throws Exception { cb = 16 * ind.size(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(fcc); baos.write(intBytes(swapInt(cb))); for (int i = 0; i < ind.size(); i++) { AVIIndex in = (AVIIndex) ind.get(i); baos.write(in.toBytes()); } return baos.toByteArray(); } }
public void addImage(Bitmap image, float quality) throws Exception { addImage(writeImageToBytes(image, quality)); }
@Override public boolean isInitialized() { return super.isInitialized() && renderer != null; }
public void addImage(Bitmap image) throws Exception { addImage(image, 0.8f); }
@Override public void stateDetached(AppStateManager stateManager) { super.stateDetached(stateManager); }
public final <T extends AppState> T getState( Class<T> type ) { return getState( type, false ); }
public MjpegFileWriter(File aviFile, int width, int height, double framerate, int numFrames) throws Exception { this.aviFile = aviFile; this.width = width; this.height = height; this.framerate = framerate; this.numFrames = numFrames; aviOutput = new FileOutputStream(aviFile); aviChannel = aviOutput.getChannel(); RIFFHeader rh = new RIFFHeader(); aviOutput.write(rh.toBytes()); aviOutput.write(new AVIMainHeader().toBytes()); aviOutput.write(new AVIStreamList().toBytes()); aviOutput.write(new AVIStreamHeader().toBytes()); aviOutput.write(new AVIStreamFormat().toBytes()); aviOutput.write(new AVIJunk().toBytes()); aviMovieOffset = aviChannel.position(); aviOutput.write(new AVIMovieList().toBytes()); indexlist = new AVIIndexList(); }
/** * Create a new VR application and attach the given {@link AppState app states}.<br> * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. * @param initialStates the {@link AppState app states} to attach to the application. */ public VRApplication(AppState... initialStates) { this(); if (initialStates != null) { for (AppState a : initialStates) { if (a != null) { stateManager.attach(a); } } } }
public byte[] toBytes() throws Exception { cb = 16 * ind.size(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(fcc); baos.write(intBytes(swapInt(cb))); for (int i = 0; i < ind.size(); i++) { AVIIndex in = (AVIIndex) ind.get(i); baos.write(in.toBytes()); } baos.close(); return baos.toByteArray(); } }
public void addImage(Image image, float quality) throws Exception { addImage(writeImageToBytes(image, quality)); }
public void addImage(Image image) throws Exception { addImage(image, 0.8f); }
public void finishAVI() throws Exception { byte[] indexlistBytes = indexlist.toBytes(); aviOutput.write(indexlistBytes); aviOutput.close(); int fileSize = (int)aviFile.length(); int listSize = (int) (fileSize - 8 - aviMovieOffset - indexlistBytes.length); RandomAccessFile raf = new RandomAccessFile(aviFile, "rw"); //add header and length by writing the headers again //with the now available information raf.write(new RIFFHeader(fileSize).toBytes()); raf.write(new AVIMainHeader().toBytes()); raf.write(new AVIStreamList().toBytes()); raf.write(new AVIStreamHeader().toBytes()); raf.write(new AVIStreamFormat().toBytes()); raf.write(new AVIJunk().toBytes()); raf.write(new AVIMovieList(listSize).toBytes()); raf.close(); }