|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.swing.Controller
com.threerings.crowd.client.PlaceController
com.threerings.whirled.client.SceneController
com.threerings.tudey.client.TudeySceneController
public class TudeySceneController
The basic Tudey scene controller class.
| Nested Class Summary | |
|---|---|
protected static class |
TudeySceneController.PawnState
Records the state of the controlled pawn at the time of an input frame (along with the frame itself). |
| Nested classes/interfaces inherited from class com.threerings.crowd.client.PlaceController |
|---|
PlaceController.DelegateOp |
| Nested classes/interfaces inherited from class com.samskivert.swing.Controller |
|---|
Controller.ActionInvoker |
| Field Summary | |
|---|---|
protected float[] |
_absoluteMoveAmounts
The absolute move command amounts in each direction. |
protected IntMap<Float>[] |
_absoluteMovePresses
Pseudo-key presses for each absolute direction. |
protected PawnAdvancer |
_advancer
The advancer we use to update the controlled pawn state. |
protected int |
_controlledId
The id of the actor being controlled. |
protected com.google.common.collect.Multimap<Integer,Integer> |
_flagPresses
Maps flags to corresponding presses pseudo-keys. |
protected int |
_flags
The current value of the input flags. |
protected boolean |
_holdHover
When true, we hold the hover state. |
protected Sprite |
_hsprite
The current hover sprite, if any. |
protected List<InputFrame> |
_input
The list of outgoing input frames. |
protected Vector3f |
_isect
Contains the result of the intersection test. |
protected IntMap<ObserverList<PseudoKeys.Observer>> |
_keyObservers
Maps pseudo-key codes to observers for individual keys. |
protected int |
_lastDelta
The timestamp of the last delta received from the server. |
protected float |
_lastDirection
The last direction we transmitted. |
protected int |
_lastFlags
The last flags we transmitted. |
protected InputFrame |
_lastFrame
The last input frame added. |
protected float |
_lastRotation
The last rotation we transmitted. |
protected long |
_lastTransmit
The time at which we last transmitted our input. |
protected long |
_nextInput
The latest time at which we should enqueue an input frame. |
protected MouseOrbiter |
_orbiter
The orbiter used to control the camera, if any. |
protected Ray3D |
_pick
Used for picking. |
protected float[] |
_relativeMoveAmounts
The relative move command amounts in each direction. |
protected IntMap<Float>[] |
_relativeMovePresses
Pseudo-key presses for each relative direction. |
protected List<TudeySceneController.PawnState> |
_states
States recorded for input frames. |
protected HashIntSet |
_strafePresses
The set of keys pressed mapped to the strafe function. |
protected int |
_targetId
The id of the actor that the camera should track. |
protected TudeyContext |
_tctx
A casted reference to the context. |
protected int |
_tickCount
Incremented on each tick. |
protected Plane |
_tplane
Contains the target plane for intersecting testing. |
protected Vector2f |
_translation
Holds averaged translation. |
protected TudeySceneObject |
_tsobj
A casted reference to the scene object. |
protected TudeySceneView |
_tsview
A casted reference to the scene view. |
protected PseudoKeys.Unifier |
_unifier
Translates various events into pseudo-key events. |
protected static float |
CONVERGENCE_RATE
The exponential rate at which we converge upon the server-corrected translation. |
protected static com.google.common.base.Predicate<SceneElement> |
HOVER_FILTER
Selects hoverable sprites. |
protected static int |
UPSTREAM_RATE_LIMIT
A rate limit (in bytes per second) for upstream traffic. |
| Fields inherited from class com.threerings.whirled.client.SceneController |
|---|
_updateListener, _wctx |
| Fields inherited from class com.threerings.crowd.client.PlaceController |
|---|
_config, _ctx, _delegates, _plobj, _view |
| Fields inherited from class com.samskivert.swing.Controller |
|---|
DISPATCHER |
| Constructor Summary | |
|---|---|
TudeySceneController()
|
|
| Method Summary | |
|---|---|
protected void |
addKeyObserver(int key,
PseudoKeys.Observer observer)
Adds an observer for a single key. |
protected void |
addKeyObserver(int key,
PseudoKeys.Observer observer,
boolean hold)
Adds an observer for a single key. |
protected void |
bindKeyCycle(int key,
boolean forward)
Binds a key to cycle between targets. |
protected void |
bindKeyFlag(int key,
int flag)
Binds a key to an input flag. |
protected void |
bindKeyMovement(int key,
float[] amounts,
IntMap<Float>[] presses,
int idx)
Binds a key to a movement direction. |
protected void |
bindKeys()
Binds pseudo-keys to observers that act on key press and/or release events. |
protected void |
bindKeyStrafe(int key)
Binds a key to the strafe flag. |
protected void |
clearDirection(float[] amounts,
IntMap<Float>[] presses)
Clears directional state. |
protected void |
clearInput()
Clears the input state, since the input window is not hovered. |
protected float |
computeDirection(float dir)
Computes the direction of movement based on the requested direction. |
void |
controlledActorAdded(int timestamp,
Actor actor)
Called by the view when we first add our controlled actor. |
void |
controlledActorUpdated(int timestamp,
Actor actor)
Called by the view when we receive an update for our controlled actor. |
void |
controlledSpriteRemoved(long timestamp)
Called by the view when we remove our controlled sprite. |
protected static IntMap<Float>[] |
createDirectionPresses()
Creates a map array to store per-direction pseudo-key presses. |
protected InputFrame |
createInputFrame(int timestamp,
float rotation,
float direction,
int flags)
Creates an input frame. |
protected PlaceView |
createPlaceView(CrowdContext ctx)
|
protected void |
cycleTarget(boolean forward)
Switches to the next or previous potential target in the occupant list. |
protected void |
didInit()
|
void |
didLeavePlace(PlaceObject plobj)
|
protected Sprite |
findHoverSprite(Ray3D pick)
Finds the hover sprite that the pick ray intersects, if any. |
int |
getControlledId()
Returns the id of the actor that is being controlled. |
Sprite |
getHoverSprite()
Returns a reference to the hover sprite, if any. |
protected int |
getInputMask()
Returns the set of all flags corresponding to input controls (i.e., the flags that should be cleared when input is disabled). |
protected int |
getMouseCameraModifiers()
Returns the combination of modifiers that activates the mouse camera, or 0 if the mouse camera is not enabled. |
int |
getTargetId()
Returns the id of the actor that the camera should track. |
int |
getTransmitInterval()
Returns the interval at which we transmit our input frames. |
protected boolean |
inputWindowFocused()
Determines whether the input window is receiving/should receive keyboard/controller events. |
protected boolean |
inputWindowHovered()
Determines whether we should process mouse events on the input window. |
boolean |
isControlledId(int actorId)
Checks whether the specified actor id is that of the controlled target. |
protected boolean |
isPressed(float[] amounts)
Checks whether the supplied amounts count as a "press" for movement purposes. |
void |
keyPressed(long when,
int key,
float amount)
Called when a "key" (either a real key or a pseudo-key) is pressed. |
void |
keyReleased(long when,
int key)
Called when a "key" is released. |
protected void |
maybeDispatchToHoverSprite(Event event)
Dispatches the given event to the hover sprite if we have one and the input window is hovered. |
void |
messageReceived(MessageEvent event)
|
protected boolean |
mouseCameraEnabled()
Determines whether the mouse camera is enabled. |
void |
mouseClicked(MouseEvent event)
Dispatched when a button is clicked within the bounds of the target component. |
void |
mouseDragged(MouseEvent event)
Dispatched when the mouse is moved after a button having been pressed within the bounds of the target component. |
void |
mouseEntered(MouseEvent event)
Dispatched when the mouse enters the bounds of the target component. |
void |
mouseExited(MouseEvent event)
Dispatched when the mouse exits the bounds of the target component. |
void |
mouseMoved(MouseEvent event)
Dispatched when the mouse is moved within the bounds of the target component. |
void |
mousePressed(MouseEvent event)
Dispatched when a button is pressed within the bounds of the target component. |
void |
mouseReleased(MouseEvent event)
Dispatched when a button is released after having been pressed within the bounds of the target component. |
void |
mouseWheeled(MouseEvent event)
Dispatched when the mouse wheel is rotated within the bounds of the target component. |
void |
sceneDeltaReceived(SceneDeltaEvent event)
Called when a scene delta has been received. |
protected void |
setHoverSprite(Sprite nhsprite)
Sets the hover sprite. |
protected void |
setTarget(int pawnId)
Targets the pawn with the specified id. |
void |
submitRequest(Sprite source,
String name)
Submits a named request to the server. |
void |
tick(float elapsed)
Updates the state of this object based on the elapsed time in seconds. |
protected void |
transmitInput()
Sends all enqueued input to the server. |
protected void |
updateFlag(int flag)
Updates the state of the specified flag based on its presses. |
protected void |
updateInput(float elapsed)
Updates the input for the current tick. |
protected void |
updateMoveFlag()
Updates the move flag. |
void |
wasAdded()
|
void |
wasRemoved()
|
void |
willEnterPlace(PlaceObject plobj)
|
| Methods inherited from class com.threerings.whirled.client.SceneController |
|---|
init, sceneUpdated |
| Methods inherited from class com.threerings.crowd.client.PlaceController |
|---|
addDelegate, applyToDelegates, createPlaceView, getPlaceConfig, getPlaceView, handleAction, mayLeavePlace |
| Methods inherited from class com.samskivert.swing.Controller |
|---|
actionPerformed, configureAction, createActionButton, generateArguments, handleAction, handleAction, handleAction, postAction, postAction, postAction, setControlledPanel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TudeyContext _tctx
protected TudeySceneView _tsview
protected TudeySceneObject _tsobj
protected MouseOrbiter _orbiter
protected int _targetId
protected int _controlledId
protected Sprite _hsprite
protected boolean _holdHover
protected PseudoKeys.Unifier _unifier
protected IntMap<ObserverList<PseudoKeys.Observer>> _keyObservers
protected int _flags
protected com.google.common.collect.Multimap<Integer,Integer> _flagPresses
protected float[] _absoluteMoveAmounts
protected float[] _relativeMoveAmounts
protected IntMap<Float>[] _absoluteMovePresses
protected IntMap<Float>[] _relativeMovePresses
protected List<InputFrame> _input
protected InputFrame _lastFrame
protected List<TudeySceneController.PawnState> _states
protected PawnAdvancer _advancer
protected float _lastRotation
protected float _lastDirection
protected int _lastFlags
protected long _nextInput
protected long _lastTransmit
protected int _lastDelta
protected HashIntSet _strafePresses
protected int _tickCount
protected Ray3D _pick
protected Plane _tplane
protected Vector3f _isect
protected Vector2f _translation
protected static final float CONVERGENCE_RATE
protected static final int UPSTREAM_RATE_LIMIT
protected static final com.google.common.base.Predicate<SceneElement> HOVER_FILTER
| Constructor Detail |
|---|
public TudeySceneController()
| Method Detail |
|---|
public int getTransmitInterval()
public int getTargetId()
public int getControlledId()
public boolean isControlledId(int actorId)
public Sprite getHoverSprite()
public void controlledActorAdded(int timestamp,
Actor actor)
public void controlledActorUpdated(int timestamp,
Actor actor)
public void controlledSpriteRemoved(long timestamp)
public void submitRequest(Sprite source,
String name)
public void sceneDeltaReceived(SceneDeltaEvent event)
SceneDeltaListener
sceneDeltaReceived in interface SceneDeltaListenerpublic void messageReceived(MessageEvent event)
messageReceived in interface MessageListener
public void keyPressed(long when,
int key,
float amount)
PseudoKeys.Observer
keyPressed in interface PseudoKeys.Observer
public void keyReleased(long when,
int key)
PseudoKeys.Observer
keyReleased in interface PseudoKeys.Observerpublic void mousePressed(MouseEvent event)
MouseListener
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent event)
MouseListener
mouseReleased in interface MouseListenerpublic void mouseClicked(MouseEvent event)
MouseListener
mouseClicked in interface MouseListenerpublic void mouseEntered(MouseEvent event)
MouseListener
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent event)
MouseListener
mouseExited in interface MouseListenerpublic void mouseMoved(MouseEvent event)
MouseMotionListener
mouseMoved in interface MouseMotionListenerpublic void mouseDragged(MouseEvent event)
MouseMotionListener
mouseDragged in interface MouseMotionListenerpublic void mouseWheeled(MouseEvent event)
MouseWheelListener
mouseWheeled in interface MouseWheelListenerpublic void tick(float elapsed)
Tickable
tick in interface Tickablepublic void wasAdded()
wasAdded in class Controllerpublic void wasRemoved()
wasRemoved in class Controllerpublic void willEnterPlace(PlaceObject plobj)
willEnterPlace in class SceneControllerpublic void didLeavePlace(PlaceObject plobj)
didLeavePlace in class SceneControllerprotected PlaceView createPlaceView(CrowdContext ctx)
createPlaceView in class PlaceControllerprotected void didInit()
didInit in class PlaceControllerprotected void bindKeys()
protected void bindKeyFlag(int key,
int flag)
protected void updateFlag(int flag)
protected void updateMoveFlag()
protected boolean isPressed(float[] amounts)
protected void bindKeyCycle(int key,
boolean forward)
protected void bindKeyMovement(int key,
float[] amounts,
IntMap<Float>[] presses,
int idx)
protected void bindKeyStrafe(int key)
protected void addKeyObserver(int key,
PseudoKeys.Observer observer)
protected void addKeyObserver(int key,
PseudoKeys.Observer observer,
boolean hold)
hold - if true and the key is pressed and released in the same frame, hold the release
event until the next frame so that we have a chance to process the press.protected void maybeDispatchToHoverSprite(Event event)
protected boolean inputWindowHovered()
protected boolean inputWindowFocused()
protected boolean mouseCameraEnabled()
protected int getMouseCameraModifiers()
protected void updateInput(float elapsed)
protected Sprite findHoverSprite(Ray3D pick)
protected float computeDirection(float dir)
protected void clearInput()
protected int getInputMask()
protected void clearDirection(float[] amounts,
IntMap<Float>[] presses)
protected InputFrame createInputFrame(int timestamp,
float rotation,
float direction,
int flags)
protected void setHoverSprite(Sprite nhsprite)
protected void transmitInput()
protected void cycleTarget(boolean forward)
protected void setTarget(int pawnId)
protected static IntMap<Float>[] createDirectionPresses()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||