com.threerings.tudey.client
Class TudeySceneView

java.lang.Object
  extended by com.threerings.expr.DynamicScope
      extended by com.threerings.tudey.client.TudeySceneView
All Implemented Interfaces:
com.threerings.crowd.chat.client.ChatDisplay, com.threerings.crowd.client.OccupantObserver, com.threerings.crowd.client.PlaceView, Scope, ScopeUpdateListener, Compositable, GlView, Tickable, com.threerings.presents.data.InvocationCodes, TudeyCodes, TudeySceneModel.Observer, ActorAdvancer.Environment
Direct Known Subclasses:
ToolSceneView

public class TudeySceneView
extends DynamicScope
implements GlView, com.threerings.crowd.client.PlaceView, TudeySceneModel.Observer, com.threerings.crowd.client.OccupantObserver, com.threerings.crowd.chat.client.ChatDisplay, ActorAdvancer.Environment, TudeyCodes

Displays a view of a Tudey scene.


Nested Class Summary
static interface TudeySceneView.TickParticipant
          An interface for objects (such as sprites and observers) that require per-tick updates.
 
Field Summary
 
Fields inherited from interface com.threerings.tudey.data.TudeyCodes
DEFAULT_BUFFER_DELAY, DEFAULT_TICK_INTERVAL
 
Fields inherited from interface com.threerings.presents.data.InvocationCodes
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
TudeySceneView(TudeyContext ctx)
          Creates a new scene view for use in the editor.
TudeySceneView(TudeyContext ctx, TudeySceneController ctrl)
          Creates a new scene view.
 
Method Summary
 void addCameraConfig(CameraConfig camcfg)
          Adds a camera config to the stack with no transition.
 void addCameraConfig(CameraConfig camcfg, float transition, Easing easing)
          Adds a camera config to the stack with an option transition.
 void addTickParticipant(TudeySceneView.TickParticipant participant)
          Adds a participant to tick at each frame.
 void addTickParticipant(TudeySceneView.TickParticipant participant, boolean prepend)
          Adds a participant to tick at each frame.
 boolean canMerge()
          Checks whether we should attempt to merge static models.
 void clear()
           
 boolean collides(Actor actor, Shape shape)
          Checks whether the actor is colliding with anything.
 void composite()
          Adds this object's Dependencys and Enqueueables to the compositor in preparation for rendering.
 void didLeavePlace(com.threerings.crowd.data.PlaceObject plobj)
           
 boolean displayMessage(com.threerings.crowd.chat.data.ChatMessage msg, boolean alreadyDisplayed)
           
 void entryAdded(TudeySceneModel.Entry entry)
          Notes that an entry has been added to the scene.
 void entryRemoved(TudeySceneModel.Entry oentry)
          Notes that an entry has been removed from the scene.
 void entryUpdated(TudeySceneModel.Entry oentry, TudeySceneModel.Entry nentry)
          Notes that an entry has been updated within the scene.
 HashSpace getActorSpace()
          Returns a reference to the actor space.
 ActorSprite getActorSprite(int id)
          Returns a reference to the actor sprite with the supplied id, or null if it doesn't exist.
 int getAdvancedTime()
          Returns the advanced time, which is the smoothed time plus an interval that compensates for buffering and latency.
 int getBufferDelay()
          Returns the delay with which to display information received from the server in order to compensate for network jitter and dropped packets.
 OrbitCameraHandler getCameraHandler()
          Returns a reference to the camera handler.
 int getControlDelta()
          Returns the client control delta (the difference between the advanced and delayed times).
 ActorSprite getControlledSprite()
          Returns a reference to the controlled sprite.
 TudeySceneController getController()
          Returns a reference to the scene controller.
 int getDelayedTime()
          Returns the delayed client time, which is the smoothed time minus a delay that compensates for network jitter and dropped packets.
 int getElapsed()
          Returns the average of the elapsed times.
 EntrySprite getEntrySprite(Object key)
          Returns the sprite corresponding to the entry with the given key.
 Transform3D getFloorTransform(float x, float y, float rotation, int mask)
          Gets the transform of an object on the floor with the provided coordinates.
 Transform3D getFloorTransform(float x, float y, float rotation, int mask, Transform3D result)
          Gets the transform of an object on the floor with the provided coordinates.
 Transform3D getFloorTransform(float x, float y, float rotation, Predicate<? super SceneElement> filter)
          Gets the transform of an object on the floor with the provided coordinates.
 Transform3D getFloorTransform(float x, float y, float rotation, Predicate<? super SceneElement> filter, Transform3D result)
          Gets the transform of an object on the floor with the provided coordinates.
 float getFloorZ(float x, float y, int mask, float defvalue)
          Returns the z coordinate of the floor at the provided coordinates, or the provided default if no floor is found.
 float getFloorZ(float x, float y, Predicate<? super SceneElement> filter, float defvalue)
          Returns the z coordinate of the floor at the provided coordinates, or the provided default if no floor is found.
 int getInputAdvance()
          Returns the interval ahead of the smoothed server time (which estimates the server time minus one-way latency) at which we schedule input events.
 Window getInputWindow()
          Returns a reference to the window used to gather input events.
 Sprite getIntersection(Ray3D ray, Vector3f location)
          Checks for an intersection between the provided ray and the sprites in the scene.
 Sprite getIntersection(Ray3D ray, Vector3f location, Predicate<? super Sprite> filter)
          Checks for an intersection between the provided ray and the sprites in the scene.
 boolean getPenetration(Actor actor, Shape shape, Vector2f result)
          Checks whether the actor is colliding with anything and, if it is, populates the provided object with the penetration vector (the minimum translation required to cancel the penetration).
 HashScene getScene()
          Returns a reference to the view scene.
 TudeySceneModel getSceneModel()
          Returns a reference to the scene model.
 int getSmoothedTime()
          Returns the smoothed estimate of the server time (plus network latency) calculated at the start of each tick.
 Sprite getSprite(EntityKey key)
          Returns the sprite corresponding to the entity with the given key.
 ActorSprite getTargetSprite()
          Returns a reference to the target sprite.
 Model maybeMerge(int x, int y, ConfigReference<ModelConfig> ref, Transform3D transform, int floorFlags)
          Attempts to merge a static model.
 void occupantEntered(com.threerings.crowd.data.OccupantInfo info)
           
 void occupantLeft(com.threerings.crowd.data.OccupantInfo info)
           
 void occupantUpdated(com.threerings.crowd.data.OccupantInfo oinfo, com.threerings.crowd.data.OccupantInfo ninfo)
           
 EffectSprite prefireEffect(int timestamp, EntityKey target, Vector2f translation, float rotation, ConfigReference<EffectConfig> ref)
          Requests to prefire an effect.
 ActorSprite prespawnActor(int timestamp, ActorSprite source, Vector2f translation, float rotation, ConfigReference<ActorConfig> ref)
          Requests to prespawn an actor.
 boolean processSceneDelta(SceneDeltaEvent event)
          Processes a scene delta received from the server.
 void removeCameraConfig(CameraConfig camcfg)
          Removes a camera config from the stack with no transition.
 void removeCameraConfig(CameraConfig camcfg, float transition, Easing easing)
          Removes a camera config from the stack with an optional transition.
 void removeTickParticipant(TudeySceneView.TickParticipant participant)
          Removes a participant from the tick list.
 void setSceneModel(TudeySceneModel model)
          Sets the scene model for this view.
 void tick(float elapsed)
          Updates the state of this object based on the elapsed time in seconds.
 boolean unmerge(int x, int y, ConfigReference<ModelConfig> ref, Transform3D transform)
          Unmerges a model.
 void updateControlledSprite()
          Updates the controlled sprite base on the controlled id.
 void updateTargetSprite()
          Updates the target sprite based on the target id.
 void wasAdded()
          Notifies the view that it is going to be rendered.
 void wasRemoved()
          Notifies the view that it will no longer be rendered.
 void willEnterPlace(com.threerings.crowd.data.PlaceObject plobj)
           
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TudeySceneView

public TudeySceneView(TudeyContext ctx)
Creates a new scene view for use in the editor.


TudeySceneView

public TudeySceneView(TudeyContext ctx,
                      TudeySceneController ctrl)
Creates a new scene view.

Method Detail

getController

public TudeySceneController getController()
Returns a reference to the scene controller.


getCameraHandler

public OrbitCameraHandler getCameraHandler()
Returns a reference to the camera handler.


getInputWindow

public Window getInputWindow()
Returns a reference to the window used to gather input events.


getScene

public HashScene getScene()
Returns a reference to the view scene.


getActorSpace

public HashSpace getActorSpace()
Returns a reference to the actor space.


getControlDelta

public int getControlDelta()
Returns the client control delta (the difference between the advanced and delayed times).


getDelayedTime

public int getDelayedTime()
Returns the delayed client time, which is the smoothed time minus a delay that compensates for network jitter and dropped packets.


getBufferDelay

public int getBufferDelay()
Returns the delay with which to display information received from the server in order to compensate for network jitter and dropped packets.


getElapsed

public int getElapsed()
Returns the average of the elapsed times.


getAdvancedTime

public int getAdvancedTime()
Returns the advanced time, which is the smoothed time plus an interval that compensates for buffering and latency.


getInputAdvance

public int getInputAdvance()
Returns the interval ahead of the smoothed server time (which estimates the server time minus one-way latency) at which we schedule input events. This should be at least the transmit interval (which represents the maximum amount of time that events may be delayed) plus the two-way latency.


getSmoothedTime

public int getSmoothedTime()
Returns the smoothed estimate of the server time (plus network latency) calculated at the start of each tick.


setSceneModel

public void setSceneModel(TudeySceneModel model)
Sets the scene model for this view.


getSprite

public Sprite getSprite(EntityKey key)
Returns the sprite corresponding to the entity with the given key.


getEntrySprite

public EntrySprite getEntrySprite(Object key)
Returns the sprite corresponding to the entry with the given key.


getActorSprite

public ActorSprite getActorSprite(int id)
Returns a reference to the actor sprite with the supplied id, or null if it doesn't exist.


getTargetSprite

public ActorSprite getTargetSprite()
Returns a reference to the target sprite.


getControlledSprite

public ActorSprite getControlledSprite()
Returns a reference to the controlled sprite.


canMerge

public boolean canMerge()
Checks whether we should attempt to merge static models.


maybeMerge

public Model maybeMerge(int x,
                        int y,
                        ConfigReference<ModelConfig> ref,
                        Transform3D transform,
                        int floorFlags)
Attempts to merge a static model.

Returns:
a reference to the merged model, or null if the model cannot be merged.

unmerge

public boolean unmerge(int x,
                       int y,
                       ConfigReference<ModelConfig> ref,
                       Transform3D transform)
Unmerges a model.

Returns:
whether or not the model was found and unmerged.

getIntersection

public Sprite getIntersection(Ray3D ray,
                              Vector3f location)
Checks for an intersection between the provided ray and the sprites in the scene.

Parameters:
location - a vector to populate with the location of the intersection, if any.
Returns:
a reference to the first sprite intersected by the ray, or null for none.

getIntersection

public Sprite getIntersection(Ray3D ray,
                              Vector3f location,
                              Predicate<? super Sprite> filter)
Checks for an intersection between the provided ray and the sprites in the scene.

Parameters:
location - a vector to populate with the location of the intersection, if any.
Returns:
a reference to the first sprite intersected by the ray, or null for none.

getFloorTransform

public Transform3D getFloorTransform(float x,
                                     float y,
                                     float rotation,
                                     int mask)
Gets the transform of an object on the floor with the provided coordinates.

Parameters:
mask - the floor mask to use for the query.

getFloorTransform

public Transform3D getFloorTransform(float x,
                                     float y,
                                     float rotation,
                                     Predicate<? super SceneElement> filter)
Gets the transform of an object on the floor with the provided coordinates.

Parameters:
filter - the floor filter to use for the query.

getFloorTransform

public Transform3D getFloorTransform(float x,
                                     float y,
                                     float rotation,
                                     int mask,
                                     Transform3D result)
Gets the transform of an object on the floor with the provided coordinates.

Parameters:
mask - the floor mask to use for the query.

getFloorTransform

public Transform3D getFloorTransform(float x,
                                     float y,
                                     float rotation,
                                     Predicate<? super SceneElement> filter,
                                     Transform3D result)
Gets the transform of an object on the floor with the provided coordinates.

Parameters:
filter - the floor filter to use for the query.

getFloorZ

public float getFloorZ(float x,
                       float y,
                       int mask,
                       float defvalue)
Returns the z coordinate of the floor at the provided coordinates, or the provided default if no floor is found.

Parameters:
mask - the floor mask to use for the query.

getFloorZ

public float getFloorZ(float x,
                       float y,
                       Predicate<? super SceneElement> filter,
                       float defvalue)
Returns the z coordinate of the floor at the provided coordinates, or the provided default if no floor is found.

Parameters:
filter - the floor filter to use for the query.

prespawnActor

public ActorSprite prespawnActor(int timestamp,
                                 ActorSprite source,
                                 Vector2f translation,
                                 float rotation,
                                 ConfigReference<ActorConfig> ref)
Requests to prespawn an actor.


prefireEffect

public EffectSprite prefireEffect(int timestamp,
                                  EntityKey target,
                                  Vector2f translation,
                                  float rotation,
                                  ConfigReference<EffectConfig> ref)
Requests to prefire an effect.


processSceneDelta

public boolean processSceneDelta(SceneDeltaEvent event)
Processes a scene delta received from the server.

Returns:
true if the scene delta was processed, false if we have not yet received the reference delta.

addTickParticipant

public void addTickParticipant(TudeySceneView.TickParticipant participant)
Adds a participant to tick at each frame.


addTickParticipant

public void addTickParticipant(TudeySceneView.TickParticipant participant,
                               boolean prepend)
Adds a participant to tick at each frame.

Parameters:
prepend - if true, prepend the participant so that it is ticked last (participants are usually ticked in reverse order of addition).

removeTickParticipant

public void removeTickParticipant(TudeySceneView.TickParticipant participant)
Removes a participant from the tick list.


updateTargetSprite

public void updateTargetSprite()
Updates the target sprite based on the target id.


updateControlledSprite

public void updateControlledSprite()
Updates the controlled sprite base on the controlled id.


addCameraConfig

public void addCameraConfig(CameraConfig camcfg)
Adds a camera config to the stack with no transition.


addCameraConfig

public void addCameraConfig(CameraConfig camcfg,
                            float transition,
                            Easing easing)
Adds a camera config to the stack with an option transition.


removeCameraConfig

public void removeCameraConfig(CameraConfig camcfg)
Removes a camera config from the stack with no transition.


removeCameraConfig

public void removeCameraConfig(CameraConfig camcfg,
                               float transition,
                               Easing easing)
Removes a camera config from the stack with an optional transition.


wasAdded

public void wasAdded()
Description copied from interface: GlView
Notifies the view that it is going to be rendered.

Specified by:
wasAdded in interface GlView

wasRemoved

public void wasRemoved()
Description copied from interface: GlView
Notifies the view that it will no longer be rendered.

Specified by:
wasRemoved in interface GlView

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

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

willEnterPlace

public void willEnterPlace(com.threerings.crowd.data.PlaceObject plobj)
Specified by:
willEnterPlace in interface com.threerings.crowd.client.PlaceView

didLeavePlace

public void didLeavePlace(com.threerings.crowd.data.PlaceObject plobj)
Specified by:
didLeavePlace in interface com.threerings.crowd.client.PlaceView

entryAdded

public void entryAdded(TudeySceneModel.Entry entry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been added to the scene.

Specified by:
entryAdded in interface TudeySceneModel.Observer

entryUpdated

public void entryUpdated(TudeySceneModel.Entry oentry,
                         TudeySceneModel.Entry nentry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been updated within the scene.

Specified by:
entryUpdated in interface TudeySceneModel.Observer

entryRemoved

public void entryRemoved(TudeySceneModel.Entry oentry)
Description copied from interface: TudeySceneModel.Observer
Notes that an entry has been removed from the scene.

Specified by:
entryRemoved in interface TudeySceneModel.Observer

occupantEntered

public void occupantEntered(com.threerings.crowd.data.OccupantInfo info)
Specified by:
occupantEntered in interface com.threerings.crowd.client.OccupantObserver

occupantLeft

public void occupantLeft(com.threerings.crowd.data.OccupantInfo info)
Specified by:
occupantLeft in interface com.threerings.crowd.client.OccupantObserver

occupantUpdated

public void occupantUpdated(com.threerings.crowd.data.OccupantInfo oinfo,
                            com.threerings.crowd.data.OccupantInfo ninfo)
Specified by:
occupantUpdated in interface com.threerings.crowd.client.OccupantObserver

displayMessage

public boolean displayMessage(com.threerings.crowd.chat.data.ChatMessage msg,
                              boolean alreadyDisplayed)
Specified by:
displayMessage in interface com.threerings.crowd.chat.client.ChatDisplay

clear

public void clear()
Specified by:
clear in interface com.threerings.crowd.chat.client.ChatDisplay

getSceneModel

public TudeySceneModel getSceneModel()
Description copied from interface: ActorAdvancer.Environment
Returns a reference to the scene model.

Specified by:
getSceneModel in interface ActorAdvancer.Environment

getPenetration

public boolean getPenetration(Actor actor,
                              Shape shape,
                              Vector2f result)
Description copied from interface: ActorAdvancer.Environment
Checks whether the actor is colliding with anything and, if it is, populates the provided object with the penetration vector (the minimum translation required to cancel the penetration).

Specified by:
getPenetration in interface ActorAdvancer.Environment
Returns:
true if a collision was detected (in which case the result vector will be populated), false otherwise.

collides

public boolean collides(Actor actor,
                        Shape shape)
Description copied from interface: ActorAdvancer.Environment
Checks whether the actor is colliding with anything.

Specified by:
collides in interface ActorAdvancer.Environment


Copyright © 2011. All Rights Reserved.