com.threerings.opengl.model.tools
Class ModelViewer

java.lang.Object
  extended by com.threerings.expr.DynamicScope
      extended by com.threerings.opengl.GlApp
          extended by com.threerings.opengl.GlCanvasApp
              extended by com.threerings.opengl.GlCanvasTool
                  extended by com.threerings.opengl.model.tools.ModelTool
                      extended by com.threerings.opengl.model.tools.ModelViewer
All Implemented Interfaces:
ConfigUpdateListener<ModelConfig>, EditorContext, Scope, ScopeUpdateListener, AlContext, Enqueueable, AnimationObserver, ModelObserver, GlContext, ActionListener, EventListener, ChangeListener

public class ModelViewer
extends ModelTool
implements ChangeListener, ConfigUpdateListener<ModelConfig>, ModelObserver

A simple model viewer application.


Nested Class Summary
protected  class ModelViewer.TrackPanel
          A single panel for running animations.
 
Nested classes/interfaces inherited from class com.threerings.opengl.model.tools.ModelTool
ModelTool.EnvironmentModel, ModelTool.ModelToolPrefs
 
Nested classes/interfaces inherited from class com.threerings.opengl.GlCanvasTool
GlCanvasTool.CanvasToolPrefs
 
Field Summary
protected  JPanel _apanel
          The animation control container.
protected  JCheckBoxMenuItem _autoReset
          The toggle for automatic reset.
protected  ChangeBlock _block
          Indicates that we should ignore any changes, because we're the one effecting them.
protected  JPanel _cpanel
          The panel that holds the control bits.
protected  float _elapsed
          Accumulated elapsed time.
protected  EditorPanel _epanel
          The editor panel we use to edit the model configuration.
protected  long _lastUpdate
          The time of the last update.
protected static Preferences _prefs
          The application preferences.
protected  JButton _removeTrack
          The remove track button.
protected  DraggableSpinner _speedSpinner
          The speed control spinner.
protected  JPanel _tpanels
          The container for the animation track panels.
protected static DecimalFormat SPEED_FORMAT
          The format for the speed display.
 
Fields inherited from class com.threerings.opengl.model.tools.ModelTool
_environment, _model, _scene, _showEnvironment
 
Fields inherited from class com.threerings.opengl.GlCanvasTool
_bounds, _compass, _eprefs, _grid, _msgs, _pdialog, _showBounds, _showCompass, _showGrid, _showStats, _stats
 
Fields inherited from class com.threerings.opengl.GlCanvasApp
_canvas, _canvasRoot, _frame, _keymgr
 
Fields inherited from class com.threerings.opengl.GlApp
_at, _billboardRotation, _camhand, _cfgmgr, _clipprov, _colorpos, _compatibilityMode, _compositor, _epoch, _imgcache, _msgmgr, _now, _renderEffects, _renderer, _renderScheme, _rsrcmgr, _shadcache, _soundmgr, _streamGain, _up, _viewTransform, _viewTransformState, _worldTransform, PIXEL_FORMATS
 
Fields inherited from class com.threerings.expr.DynamicScope
_compoundDepth, _listeners, _owner, _parentScope, _scopeName, _symbols, INVALID_SCOPE
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
ModelViewer(String model)
          Creates the model viewer with (optionally) the path to a model to load.
 
Method Summary
 void actionPerformed(ActionEvent event)
           
 boolean animationStarted(Animation animation)
          Notes that an animation has started.
 boolean animationStopped(Animation animation, boolean completed)
          Notifies the observer that the animation has stopped.
 void configUpdated(ConfigEvent<ModelConfig> event)
          Called when a configuration has been updated.
protected  JComponent createCanvasContainer()
          Creates and returns the component that contains the canvas (after the canvas has been created).
protected  GlCanvasTool.CanvasToolPrefs createEditablePrefs()
          Creates and returns the editable preferences.
protected  void didInit()
          Override to perform custom initialization after the render context is valid.
static void main(String[] args)
          The program entry point.
 boolean modelCompleted(Model model)
          Notes that a model (such as a transient effect) has completed.
 void stateChanged(ChangeEvent event)
           
protected  void updateTrackControls()
          Updates all of the track controls.
protected  void updateView()
          Performs any updates that are necessary even when not rendering.
protected  void updateView(float elapsed)
          Performs any updates that are necessary even when not rendering.
 
Methods inherited from class com.threerings.opengl.model.tools.ModelTool
compositeView, createBounds
 
Methods inherited from class com.threerings.opengl.GlCanvasTool
createAction, createAction, createButton, createButton, createCameraHandler, createCheckBoxMenuItem, createCheckBoxMenuItem, createGrid, createMenu, createMenuItem, createMenuItem, shouldCheckTimestamps
 
Methods inherited from class com.threerings.opengl.GlCanvasApp
createCanvas, createRoot, getCanvas, getFrame, getMouseRay, getPickRay, getRunQueue, initRenderer, makeCurrent, shutdown, startup, willShutdown
 
Methods inherited from class com.threerings.opengl.GlApp
createSnapshot, enqueue, getApp, getCameraHandler, getClipProvider, getColorPository, getCompatibilityMode, getCompositor, getConfigManager, getImageCache, getMessageManager, getRenderEffects, getRenderer, getRenderScheme, getResourceManager, getScope, getShaderCache, getSoundManager, getStreamGain, init, initSharedManagers, renderView, setCameraHandler, setCompatibilityMode, setRenderEffects, setRenderer, setRenderScheme, xlate
 
Methods inherited from class com.threerings.expr.DynamicScope
addListener, dispose, endCompoundUpdate, get, getParentScope, getScopeName, put, remove, removeListener, scopeUpdated, setParentScope, startCompoundUpdate, wasUpdated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.threerings.editor.util.EditorContext
getColorPository, getConfigManager, getMessageManager, getResourceManager
 

Field Detail

_autoReset

protected JCheckBoxMenuItem _autoReset
The toggle for automatic reset.


_cpanel

protected JPanel _cpanel
The panel that holds the control bits.


_epanel

protected EditorPanel _epanel
The editor panel we use to edit the model configuration.


_apanel

protected JPanel _apanel
The animation control container.


_tpanels

protected JPanel _tpanels
The container for the animation track panels.


_removeTrack

protected JButton _removeTrack
The remove track button.


_speedSpinner

protected DraggableSpinner _speedSpinner
The speed control spinner.


_lastUpdate

protected long _lastUpdate
The time of the last update.


_elapsed

protected float _elapsed
Accumulated elapsed time.


_block

protected ChangeBlock _block
Indicates that we should ignore any changes, because we're the one effecting them.


_prefs

protected static Preferences _prefs
The application preferences.


SPEED_FORMAT

protected static final DecimalFormat SPEED_FORMAT
The format for the speed display.

Constructor Detail

ModelViewer

public ModelViewer(String model)
Creates the model viewer with (optionally) the path to a model to load.

Method Detail

main

public static void main(String[] args)
The program entry point.


stateChanged

public void stateChanged(ChangeEvent event)
Specified by:
stateChanged in interface ChangeListener

configUpdated

public void configUpdated(ConfigEvent<ModelConfig> event)
Description copied from interface: ConfigUpdateListener
Called when a configuration has been updated.

Specified by:
configUpdated in interface ConfigUpdateListener<ModelConfig>

animationStarted

public boolean animationStarted(Animation animation)
Description copied from interface: AnimationObserver
Notes that an animation has started.

Specified by:
animationStarted in interface AnimationObserver
Returns:
true to keep the observer in the list, false to remove it.

animationStopped

public boolean animationStopped(Animation animation,
                                boolean completed)
Description copied from interface: AnimationObserver
Notifies the observer that the animation has stopped.

Specified by:
animationStopped in interface AnimationObserver
completed - whether or not the animation ran to completion (as opposed to being cancelled).
Returns:
true to keep the observer in the list, false to remove it.

modelCompleted

public boolean modelCompleted(Model model)
Description copied from interface: ModelObserver
Notes that a model (such as a transient effect) has completed.

Specified by:
modelCompleted in interface ModelObserver
Returns:
true to keep the observer in the list, false to remove it.

actionPerformed

public void actionPerformed(ActionEvent event)
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class ModelTool

createCanvasContainer

protected JComponent createCanvasContainer()
Description copied from class: GlCanvasApp
Creates and returns the component that contains the canvas (after the canvas has been created).

Overrides:
createCanvasContainer in class GlCanvasApp

createEditablePrefs

protected GlCanvasTool.CanvasToolPrefs createEditablePrefs()
Description copied from class: GlCanvasTool
Creates and returns the editable preferences.

Specified by:
createEditablePrefs in class GlCanvasTool

didInit

protected void didInit()
Description copied from class: GlApp
Override to perform custom initialization after the render context is valid.

Overrides:
didInit in class ModelTool

updateView

protected void updateView()
Description copied from class: GlApp
Performs any updates that are necessary even when not rendering.

Overrides:
updateView in class GlApp

updateView

protected void updateView(float elapsed)
Description copied from class: GlApp
Performs any updates that are necessary even when not rendering.

Overrides:
updateView in class ModelTool
Parameters:
elapsed - the elapsed time since the last update, in seconds.

updateTrackControls

protected void updateTrackControls()
Updates all of the track controls.