com.threerings.opengl.model
Class Model

java.lang.Object
  extended by com.threerings.expr.DynamicScope
      extended by com.threerings.opengl.model.Model
All Implemented Interfaces:
ConfigUpdateListener<ModelConfig>, Scope, ScopeUpdateListener, Compositable, SceneElement, SceneObject, Intersectable, Tickable
Direct Known Subclasses:
Scene.Transient

public class Model
extends DynamicScope
implements SceneElement, ConfigUpdateListener<ModelConfig>

A 3D model.


Nested Class Summary
static class Model.Implementation
          The actual model implementation.
 
Nested classes/interfaces inherited from interface com.threerings.opengl.scene.SceneElement
SceneElement.TickPolicy
 
Field Summary
static int DEFINITION_INFLUENCE
          A flag indicating that the model implementation relies on the definitions.
static int FOG_INFLUENCE
          A flag indicating that the model implementation relies on the fog state.
static int LIGHT_INFLUENCE
          A flag indicating that the model implementation relies on the light state.
static int PROJECTION_INFLUENCE
          A flag indicating that the model implementation relies on the projections.
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
Model(GlContext ctx)
          Creates a new model with a null configuration.
Model(GlContext ctx, ConfigReference<ModelConfig> ref)
          Creates a new model with the referenced configuration.
Model(GlContext ctx, ModelConfig config)
          Creates a new model with the given configuration.
Model(GlContext ctx, String name)
          Creates a new model with the named configuration.
Model(GlContext ctx, String name, String firstKey, Object firstValue, Object... otherArgs)
          Creates a new model with the named configuration and arguments.
 
Method Summary
 void addObserver(ModelObserver observer)
          Adds an observer to this model.
 void attach(String point, Model model)
          Attaches the specified model at the given point.
 void attach(String point, Model model, boolean replace)
          Attaches the specified model at the given point.
 void boundsDidChange(Model.Implementation impl)
          Notes that the bounds have changed.
 void boundsWillChange(Model.Implementation impl)
          Notes that the bounds will change.
 void clearConfig()
          Resets the configuration of this model to the null configuration.
 void completed(Model.Implementation impl)
          Notes that the model has completed.
 void composite()
          Adds this object's Dependencys and Enqueueables to the compositor in preparation for rendering.
 void configUpdated(ConfigEvent<ModelConfig> event)
          Called when a configuration has been updated.
 Animation createAnimation()
          Creates an unconfigured animation for the model.
 Animation createAnimation(ConfigReference<AnimationConfig> ref)
          Creates an animation for this model.
 Animation createAnimation(String name)
          Creates an animation for this model.
 Animation createAnimation(String name, String firstKey, Object firstValue, Object... otherArgs)
          Creates an animation for this model.
 void detach(Model model)
          Detaches an attached model.
 void detachAll(String point)
          Detaches any models attached to the specified point.
 void dispose()
          Releases the resources associated with this scope.
 void drawBounds()
          Draws the bounds of the model in immediate mode.
<T> T
get(String name, Class<T> clazz)
          Looks up a symbol in this scope.
 Animation getAnimation(String name)
          Retrieves an animation by name.
 Animation[] getAnimations()
          Returns a reference to this model's list of animations.
 Box getBounds()
          Returns a reference to the bounds of the object.
 ColorState getColorState()
          Returns a reference to the model's color state.
 ModelConfig getConfig()
          Returns a reference to this model's configuration.
 FogState getFogState()
          Returns a reference to the model's fog state.
 boolean getIntersection(Ray3D ray, Vector3f result)
          Finds the intersection of a ray with this object and places it in the supplied vector (if it exists).
 LightState getLightState()
          Returns a reference to the model's light state.
 Transform3D getLocalTransform()
          Returns a reference to the model's local transform.
static MaterialConfig getMaterialConfig(GlContext ctx, String texture, String tag, ModelConfig.Imported.MaterialMapping[] materialMappings, Map<String,MaterialConfig> materialConfigs)
          Resolves a material config through a cache.
 List<Animation> getPlayingAnimations()
          Returns a list containing all animations currently playing on this model.
 Transform3D getPointWorldTransform(String point)
          Returns a reference to the world transform of the model point.
 String getRenderScheme()
          Returns the model's render scheme.
 Scene getScene(Model.Implementation impl)
          Returns a reference to the scene containing the model, if any.
 SceneElement.TickPolicy getTickPolicy()
          Returns the policy that determines when the Tickable.tick(float) method must be called.
 Object getUserObject()
          Returns this element's user object reference.
 boolean hasCompleted()
          Determines whether this model (such as a transient effect) has completed.
 boolean isAnimationPlaying(String name)
          Checks whether the named animation is playing.
 boolean isVisible()
          Returns the value of the model's visibility flag.
 void removeObserver(ModelObserver observer)
          Removes an observer from this model.
 void reset()
          Resets the state of this model.
 void setColorState(ColorState state)
          Sets the model's color state.
 void setConfig(ConfigReference<ModelConfig> ref)
          Sets the configuration of this model.
 void setConfig(ModelConfig config)
          Sets the configuration of this model.
 void setConfig(String name)
          Sets the configuration of this model.
 void setConfig(String name, String firstKey, Object firstValue, Object... otherArgs)
          Sets the configuration of this model.
 void setFogState(FogState state)
          Sets the model's fog state.
 void setInfluences(SceneInfluenceSet influences)
          Sets the influences affecting this element.
 void setLightState(LightState state)
          Sets the model's light state.
 void setLocalTransform(Transform3D transform)
          Sets the local transform to the specified value and promotes it to Transform3D.UNIFORM, then updates the bounds of the model.
 void setRenderScheme(String scheme)
          Sets the model's render scheme.
 void setTickPolicy(SceneElement.TickPolicy policy)
          Sets the tick policy of the model.
 void setUserObject(Object object)
          Sets the model's user object reference.
 void setVisible(boolean visible)
          Sets the model's visibility flag.
 void startAnimation(String name)
          Starts an animation by name.
 void stopAllAnimations()
          Stops all animations currently playing.
 void stopAnimation(String name)
          Stops an animation by name.
 void stopAnimations(int priority, float blendOut)
          Stops all animations playing at the specified priority level, blending them out over the specified interval.
 void tick(float elapsed)
          Updates the state of this object based on the elapsed time in seconds.
 void tickPolicyDidChange(Model.Implementation impl)
          Notes that the tick policy has changed.
 void tickPolicyWillChange(Model.Implementation impl)
          Notes that the tick policy will change.
 void updateBounds()
          Updates the bounds of the model.
 boolean updateLastVisit(int visit)
          Checks and updates the last visit value.
 void wasAdded(Scene scene)
          Notes that the element was added to the specified scene.
 void wasUpdated()
          Notes that this scope has been updated.
 void willBeRemoved()
          Notes that the element will be removed from the scene.
 
Methods inherited from class com.threerings.expr.DynamicScope
addListener, endCompoundUpdate, getParentScope, getScopeName, put, remove, removeListener, scopeUpdated, setParentScope, startCompoundUpdate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOG_INFLUENCE

public static final int FOG_INFLUENCE
A flag indicating that the model implementation relies on the fog state.

See Also:
Constant Field Values

LIGHT_INFLUENCE

public static final int LIGHT_INFLUENCE
A flag indicating that the model implementation relies on the light state.

See Also:
Constant Field Values

PROJECTION_INFLUENCE

public static final int PROJECTION_INFLUENCE
A flag indicating that the model implementation relies on the projections.

See Also:
Constant Field Values

DEFINITION_INFLUENCE

public static final int DEFINITION_INFLUENCE
A flag indicating that the model implementation relies on the definitions.

See Also:
Constant Field Values
Constructor Detail

Model

public Model(GlContext ctx)
Creates a new model with a null configuration.


Model

public Model(GlContext ctx,
             String name)
Creates a new model with the named configuration.


Model

public Model(GlContext ctx,
             String name,
             String firstKey,
             Object firstValue,
             Object... otherArgs)
Creates a new model with the named configuration and arguments.


Model

public Model(GlContext ctx,
             ConfigReference<ModelConfig> ref)
Creates a new model with the referenced configuration.


Model

public Model(GlContext ctx,
             ModelConfig config)
Creates a new model with the given configuration.

Method Detail

getMaterialConfig

public static MaterialConfig getMaterialConfig(GlContext ctx,
                                               String texture,
                                               String tag,
                                               ModelConfig.Imported.MaterialMapping[] materialMappings,
                                               Map<String,MaterialConfig> materialConfigs)
Resolves a material config through a cache.


setLocalTransform

public void setLocalTransform(Transform3D transform)
Sets the local transform to the specified value and promotes it to Transform3D.UNIFORM, then updates the bounds of the model.


getLocalTransform

public Transform3D getLocalTransform()
Returns a reference to the model's local transform.


getPointWorldTransform

public Transform3D getPointWorldTransform(String point)
Returns a reference to the world transform of the model point.


setConfig

public void setConfig(String name)
Sets the configuration of this model.


setConfig

public void setConfig(ConfigReference<ModelConfig> ref)
Sets the configuration of this model.


setConfig

public void setConfig(String name,
                      String firstKey,
                      Object firstValue,
                      Object... otherArgs)
Sets the configuration of this model.


clearConfig

public void clearConfig()
Resets the configuration of this model to the null configuration.


setConfig

public void setConfig(ModelConfig config)
Sets the configuration of this model.


getConfig

public ModelConfig getConfig()
Returns a reference to this model's configuration.


setRenderScheme

public void setRenderScheme(String scheme)
Sets the model's render scheme.


getRenderScheme

public String getRenderScheme()
Returns the model's render scheme.


setVisible

public void setVisible(boolean visible)
Sets the model's visibility flag.


isVisible

public boolean isVisible()
Returns the value of the model's visibility flag.


setColorState

public void setColorState(ColorState state)
Sets the model's color state.


getColorState

public ColorState getColorState()
Returns a reference to the model's color state.


setFogState

public void setFogState(FogState state)
Sets the model's fog state.


getFogState

public FogState getFogState()
Returns a reference to the model's fog state.


setLightState

public void setLightState(LightState state)
Sets the model's light state.


getLightState

public LightState getLightState()
Returns a reference to the model's light state.


attach

public void attach(String point,
                   Model model)
Attaches the specified model at the given point.


attach

public void attach(String point,
                   Model model,
                   boolean replace)
Attaches the specified model at the given point.

Parameters:
replace - if true, replace any existing attachments at the point.

detach

public void detach(Model model)
Detaches an attached model.


detachAll

public void detachAll(String point)
Detaches any models attached to the specified point.


startAnimation

public void startAnimation(String name)
Starts an animation by name.


stopAnimation

public void stopAnimation(String name)
Stops an animation by name.


stopAnimations

public void stopAnimations(int priority,
                           float blendOut)
Stops all animations playing at the specified priority level, blending them out over the specified interval.


stopAllAnimations

public void stopAllAnimations()
Stops all animations currently playing.


getPlayingAnimations

public List<Animation> getPlayingAnimations()
Returns a list containing all animations currently playing on this model.


isAnimationPlaying

public boolean isAnimationPlaying(String name)
Checks whether the named animation is playing.


getAnimation

public Animation getAnimation(String name)
Retrieves an animation by name.


getAnimations

public Animation[] getAnimations()
Returns a reference to this model's list of animations.


createAnimation

public Animation createAnimation(String name)
Creates an animation for this model.


createAnimation

public Animation createAnimation(ConfigReference<AnimationConfig> ref)
Creates an animation for this model.


createAnimation

public Animation createAnimation(String name,
                                 String firstKey,
                                 Object firstValue,
                                 Object... otherArgs)
Creates an animation for this model.


createAnimation

public Animation createAnimation()
Creates an unconfigured animation for the model.


hasCompleted

public boolean hasCompleted()
Determines whether this model (such as a transient effect) has completed.


addObserver

public void addObserver(ModelObserver observer)
Adds an observer to this model.


removeObserver

public void removeObserver(ModelObserver observer)
Removes an observer from this model.


reset

public void reset()
Resets the state of this model.


updateBounds

public void updateBounds()
Updates the bounds of the model.


drawBounds

public void drawBounds()
Draws the bounds of the model in immediate mode.


setTickPolicy

public void setTickPolicy(SceneElement.TickPolicy policy)
Sets the tick policy of the model.


setUserObject

public void setUserObject(Object object)
Sets the model's user object reference.


getTickPolicy

public SceneElement.TickPolicy getTickPolicy()
Description copied from interface: SceneElement
Returns the policy that determines when the Tickable.tick(float) method must be called.

Specified by:
getTickPolicy in interface SceneElement

getUserObject

public Object getUserObject()
Description copied from interface: SceneElement
Returns this element's user object reference.

Specified by:
getUserObject in interface SceneElement

getBounds

public Box getBounds()
Description copied from interface: SceneObject
Returns a reference to the bounds of the object.

Specified by:
getBounds in interface SceneObject

wasAdded

public void wasAdded(Scene scene)
Description copied from interface: SceneElement
Notes that the element was added to the specified scene.

Specified by:
wasAdded in interface SceneElement

willBeRemoved

public void willBeRemoved()
Description copied from interface: SceneElement
Notes that the element will be removed from the scene.

Specified by:
willBeRemoved in interface SceneElement

setInfluences

public void setInfluences(SceneInfluenceSet influences)
Description copied from interface: SceneElement
Sets the influences affecting this element.

Specified by:
setInfluences in interface SceneElement

updateLastVisit

public boolean updateLastVisit(int visit)
Description copied from interface: SceneObject
Checks and updates the last visit value. This is used to determine when we have visited (e.g., rendered) the object without having to clear a flag for all objects before performing the operation. Instead, we use a unique visitation id for each operation and assume that any object with that id has been visited already.

Specified by:
updateLastVisit in interface SceneObject
Returns:
true if the last visit value was not equal to the value provided (and has now been set to that value), false if the object had already been visited during the current operation.

tick

public void tick(float elapsed)
Description copied from interface: Tickable
Updates the state of this object based on the elapsed time in seconds.

Specified by:
tick in interface Tickable

getIntersection

public boolean getIntersection(Ray3D ray,
                               Vector3f result)
Description copied from interface: Intersectable
Finds the intersection of a ray with this object and places it in the supplied vector (if it exists).

Specified by:
getIntersection in interface Intersectable
Returns:
true if the ray intersected the object (in which case the result will contain the point of intersection), false otherwise.

composite

public void composite()
Description copied from interface: Compositable
Adds this object's Dependencys and Enqueueables to the compositor in preparation for rendering.

Specified by:
composite in interface Compositable

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>

get

public <T> T get(String name,
                 Class<T> clazz)
Description copied from interface: Scope
Looks up a symbol in this scope.

Specified by:
get in interface Scope
Overrides:
get in class DynamicScope
Returns:
the mapping for the requested symbol, or null if not found.

wasUpdated

public void wasUpdated()
Description copied from class: DynamicScope
Notes that this scope has been updated.

Overrides:
wasUpdated in class DynamicScope

dispose

public void dispose()
Description copied from class: DynamicScope
Releases the resources associated with this scope.

Overrides:
dispose in class DynamicScope

getScene

public Scene getScene(Model.Implementation impl)
Returns a reference to the scene containing the model, if any. This should only be called by the _impl.


completed

public void completed(Model.Implementation impl)
Notes that the model has completed. This should only be called by the _impl.


tickPolicyWillChange

public void tickPolicyWillChange(Model.Implementation impl)
Notes that the tick policy will change. Should only be called by the _impl.


tickPolicyDidChange

public void tickPolicyDidChange(Model.Implementation impl)
Notes that the tick policy has changed. Should only be called by the _impl.


boundsWillChange

public void boundsWillChange(Model.Implementation impl)
Notes that the bounds will change. Should only be called by the _impl.


boundsDidChange

public void boundsDidChange(Model.Implementation impl)
Notes that the bounds have changed. Should only be called by the _impl.



Copyright © 2011. All Rights Reserved.