|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.io.SimpleStreamableObject
com.threerings.whirled.data.SceneModel
com.threerings.tudey.data.TudeySceneModel
public class TudeySceneModel
Contains a representation of a Tudey scene.
| Nested Class Summary | |
|---|---|
static class |
TudeySceneModel.AreaEntry
An area entry. |
static class |
TudeySceneModel.Entry
An entry in the scene. |
protected static class |
TudeySceneModel.FloorPlaceableFilter
Used to select sprites according to their floor flags. |
static class |
TudeySceneModel.GlobalEntry
A global entry. |
static class |
TudeySceneModel.IdEntry
An entry identified by an integer id. |
static interface |
TudeySceneModel.LayerObserver
An extended Observer interface for observers interested in layers. |
static interface |
TudeySceneModel.Observer
An interface for objects interested in changes to the scene model. |
static class |
TudeySceneModel.Paint
Contains information on a painted location. |
protected static class |
TudeySceneModel.PaintConfigMapping
Represents a type of paint identified by an integer id. |
static class |
TudeySceneModel.PathEntry
A path entry. |
static class |
TudeySceneModel.PlaceableElement
A placeable shape element. |
static class |
TudeySceneModel.PlaceableEntry
A placeable entry. |
protected static class |
TudeySceneModel.TileConfigMapping
Represents a type of tile identified by an integer id. |
static class |
TudeySceneModel.TileEntry
A tile entry. |
static class |
TudeySceneModel.Vertex
Represents a single vertex in a path or area. |
| Nested classes/interfaces inherited from interface com.threerings.io.Streamable |
|---|
Streamable.Closure |
| Field Summary | |
|---|---|
protected ConfigManager |
_cfgmgr
The scene configuration manager. |
protected CoordIntMap |
_collisionFlags
Collision flags for each location. |
protected SoftReference<byte[]> |
_data
The cached exported representation of the scene model. |
protected boolean |
_dirty
Flags the scene model as having changed since the dirty bit was last cleared. |
protected HashMap<Object,SpaceElement> |
_elements
Maps entry keys to space elements. |
protected HashMap<Object,TudeySceneModel.Entry> |
_entries
Scene entries mapped by key. |
protected boolean |
_exportLayers
Do we want to export layers when we serialize? |
protected TudeySceneModel.FloorPlaceableFilter |
_floorPlaceableFilter
Used to fine the floor. |
protected ArrayList<SpaceElement> |
_intersecting
(Re)used to store intersecting elements. |
protected int |
_lastEntryId
The last entry id assigned. |
protected Map<Integer,Integer> |
_layerMap
Maps entry keys to their layer. |
protected List<String> |
_layerNamesView
An unmodifiable list that represents the names of each layer. |
protected List<String> |
_layers
The names of each layer. |
protected String |
_notes
The notes regarding this scene. |
protected ObserverList<TudeySceneModel.Observer> |
_observers
The scene model observers. |
protected CoordIntMap |
_paint
Encoded paint data. |
protected Map<ConfigReference<? extends PaintableConfig>,Integer> |
_paintConfigIds
Paint config ids mapped by reference. |
protected ArrayList<TudeySceneModel.PaintConfigMapping> |
_paintConfigs
Paint config references by id. |
protected Vector2f |
_penetration
Stores penetration vector during queries. |
protected TudeySceneConfig |
_placeConfig
The place configuration. |
protected Point |
_point
Used to find the floor. |
protected Polygon |
_quad
Used to store tile shapes for intersecting testing. |
protected Rect |
_rect
Bounds object to reuse. |
protected WeakHashMap<ConfigReference,ConfigReference> |
_references
The set of entry references (used to ensure that entries with equal references use the same instance. |
protected Rectangle |
_region
Region object to reuse. |
protected HashSpace |
_space
The space containing the (non-tile) entry shapes. |
protected Map<String,List<TudeySceneModel.Entry>> |
_tagged
Maps tags to lists of tagged entries. |
protected Map<ConfigReference<TileConfig>,Integer> |
_tileConfigIds
Tile config ids mapped by reference. |
protected ArrayList<TudeySceneModel.TileConfigMapping> |
_tileConfigs
Tile config references by id. |
protected CoordIntMap |
_tileCoords
Maps locations to the encoded coordinates of any tiles intersecting them. |
protected CoordIntMap |
_tiles
The encoded tiles. |
| Fields inherited from class com.threerings.whirled.data.SceneModel |
|---|
auxModels, name, sceneId, version |
| Constructor Summary | |
|---|---|
TudeySceneModel()
Creates a new, empty scene model. |
|
| Method Summary | |
|---|---|
protected TudeySceneModel.Entry |
add(TudeySceneModel.Entry entry)
Performs the actual addition of the specified entry. |
protected void |
addElement(TudeySceneModel.Entry entry)
Adds the entry's space element to the hash space and maps it by its tags. |
boolean |
addEntry(TudeySceneModel.Entry entry)
Adds an entry to the scene, assigning it a unique id in the process if it is an TudeySceneModel.IdEntry. |
boolean |
addEntry(TudeySceneModel.Entry entry,
boolean assignId)
Adds an entry to the scene. |
int |
addLayer(String n)
Deprecated. |
int |
addLayer(String name,
int position)
Add a new layer to the model. |
void |
addObserver(TudeySceneModel.Observer observer)
Adds an observer for scene changes. |
protected int |
addPaintConfig(ConfigReference<? extends PaintableConfig> paintable)
Adds a reference to the specified paint config and returns the index assigned to the config. |
protected int |
addTileConfig(ConfigReference<TileConfig> tile)
Adds a reference to the specified tile config and returns the index assigned to the config. |
protected void |
canonicalizeReference(TudeySceneModel.Entry entry)
Ensures that the entry's reference, if non-null, points to one of the references in the _references set (that is, that all entries whose references are equal point to
the same reference instance). |
void |
clearPaint()
Clears all paint from the scene. |
TudeySceneModel |
clone()
|
boolean |
collides(Actor actor,
Shape shape)
Checks the specified actor for a collision with the environment. |
boolean |
collides(int mask,
Shape shape)
Checks the specified mask for a collision with the environment. |
boolean |
containsEntry(Object key)
Determines whether the scene contains an entry with the supplied key. |
protected void |
createShadow(TudeySceneModel.TileEntry entry)
Creates the shadow data for the specified tile and maps it by its tags. |
protected TudeySceneModel.Paint |
decodePaint(int value)
Decodes the specified paint value. |
protected TudeySceneModel.TileEntry |
decodeTileEntry(Coord coord,
int value)
Decodes the specified tile entry. |
protected TudeySceneModel.TileEntry |
decodeTileEntry(int x,
int y,
int value)
Decodes the specified tile entry. |
protected void |
deleteShadow(TudeySceneModel.TileEntry entry)
Deletes the shadow data for the supplied tile and removes its tag mappings. |
CoordIntMap |
getCollisionFlags()
Returns a reference to the map containing the tile collision flags. |
protected static int |
getConfigIndex(int value)
Extracts the tile configuration index from the supplied encoded tile. |
ConfigManager |
getConfigManager()
Returns a reference to the scene's configuration manager. |
byte[] |
getData()
Returns the cached exported binary representation of the model. |
Map<Object,SpaceElement> |
getElements()
Returns a reference to the map from entry key to space elements. |
protected static int |
getElevation(int value)
Extracts the tile elevation from the supplied encoded tile. |
Collection<TudeySceneModel.Entry> |
getEntries()
Returns a reference to the collection of entries. |
void |
getEntries(Shape shape,
Collection<TudeySceneModel.Entry> results)
Retrieves all entries intersecting the supplied shape. |
void |
getEntries(Shape shape,
com.google.common.base.Predicate<? super TudeySceneModel.Entry> pred,
Collection<TudeySceneModel.Entry> results)
Retrieves all entries intersecting the supplied shape and matching the predicate. |
TudeySceneModel.Entry |
getEntry(Object key)
Looks up the entry with the supplied key. |
float |
getFloorZ(float x,
float y,
float defvalue)
Returns the z coordinate of the floor at the provided coordinates, or the provided default if no floor is found. |
boolean |
getIntersection(Ray2D ray,
float length,
int mask,
Vector2f intersection)
Finds the intersection with the ray. |
int |
getLayer(Object key)
Get the layer of the entry with the specified key. |
List<String> |
getLayers()
Get the layer names. |
boolean |
getNearestPoint(Shape shape,
int mask,
Vector2f origin,
Vector2f nearPoint)
Finds the nearest point to the origin if the shape collides with the environment. |
String |
getNotes()
Returns the scene notes. |
TudeySceneModel.Paint |
getPaint(int x,
int y)
Returns the paint at the specified coordinates, if any. |
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). |
TudeySceneConfig |
getPlaceConfig()
Returns a reference to the model's place config. |
void |
getPreloads(PreloadableSet preloads)
Adds the resources to preload for this scene model to the supplied set. |
void |
getResources(Set<String> paths)
Adds the resources referenced by this scene model to the supplied set. |
TudeySceneModel |
getSceneModel()
Returns a reference to the scene model. |
Space |
getSpace()
Returns a reference to the space containing the (non-tile) entry elements. |
List<TudeySceneModel.Entry> |
getTaggedEntries(String tag)
Returns the list of all entries bearing the specified tag. |
TudeySceneModel.Entry |
getTaggedEntry(String tag)
Returns the first entry bearing the specified tag, or null for none. |
int |
getTileElevation(int x,
int y)
Returns the tile elevation at the specified coordinates, or Integer.MIN_VALUE if
there is no tile there. |
void |
getTileEntries(Rectangle region,
Collection<TudeySceneModel.TileEntry> results)
Retrieves all of the tile entries intersecting the supplied region. |
protected TudeySceneModel.TileEntry |
getTileEntry(int pair)
Retrieves the tile entry identified by the provided encoded coordinate pair. |
TudeySceneModel.TileEntry |
getTileEntry(int x,
int y)
Returns the tile entry intersecting the specified coordinates, if any. |
protected int |
getTileValue(int pair)
Returns the encoded tile value corresponding to the encoded coordinate pair given, logging a warning and returning -1 if no value exists at the coordinates. |
void |
init(ConfigManager cfgmgr)
Initializes the model. |
void |
invalidate()
Invalidates any cached data in the model, forcing it to be recreated (and sets the dirty flag). |
boolean |
isDirty()
Returns the value of the dirty flag. |
boolean |
isLayerEmpty(int layer)
Return true if the specified layer not 0 and is empty. |
protected void |
mapEntry(TudeySceneModel.Entry entry)
Maps the specified entry according to its tags. |
void |
readFields(Importer in)
Custom field read method. |
void |
readObject(ObjectInputStream in)
Custom read method for streaming. |
protected TudeySceneModel.Entry |
remove(Object key)
Performs the actual removal of the identified entry. |
protected void |
removeElement(TudeySceneModel.Entry entry)
Removes the entry's space element from the hash space and removes its tag mappings. |
TudeySceneModel.Entry |
removeEntry(Object key)
Removes an entry from the scene. |
void |
removeLayer(int layer)
Remove the specified layer, moving anything present to the base layer. |
void |
removeObserver(TudeySceneModel.Observer observer)
Removes a scene observer. |
protected void |
removePaintConfig(int idx)
Removes a reference for the indexed paint config. |
protected void |
removeTileConfig(int idx)
Removes a reference for the indexed tile config. |
void |
renameLayer(int layer,
String name)
Rename one of the layers. |
void |
setDirty(boolean dirty)
Sets the value of the dirty flag. |
void |
setLayer(Object key,
int layer)
Set the layer of the entry with the specified key. |
void |
setName(String name)
Sets the scene's name and invalidates. |
void |
setNotes(String notes)
Sets the scene notes. |
TudeySceneModel.Paint |
setPaint(int x,
int y,
TudeySceneModel.Paint paint)
Sets the paint at the specified coordinates. |
void |
setPlaceConfig(TudeySceneConfig config)
Sets the place config for the model. |
protected void |
unmapEntry(TudeySceneModel.Entry entry)
Unmaps the specified entry according to its tags. |
protected TudeySceneModel.Entry |
update(TudeySceneModel.Entry nentry)
Performs the actual update of the specified entry. |
TudeySceneModel.Entry |
updateEntry(TudeySceneModel.Entry nentry)
Updates an entry within the scene. |
protected int |
validateLayer(int layer)
Validate that a layer value is valid. |
boolean |
validateReferences(String where,
PrintStream out)
Validates the references in the scene. |
void |
writeFields(Exporter out)
Custom field write method. |
void |
writeObject(ObjectOutputStream out)
Custom write method for streaming. |
| Methods inherited from class com.threerings.whirled.data.SceneModel |
|---|
addAuxModel, blankSceneModel, populateBlankSceneModel |
| Methods inherited from class com.threerings.io.SimpleStreamableObject |
|---|
toString, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String _notes
protected TudeySceneConfig _placeConfig
protected ConfigManager _cfgmgr
@DeepOmit protected CoordIntMap _tiles
@DeepOmit protected ArrayList<TudeySceneModel.TileConfigMapping> _tileConfigs
@DeepOmit protected transient Map<ConfigReference<TileConfig>,Integer> _tileConfigIds
@DeepOmit protected transient HashMap<Object,TudeySceneModel.Entry> _entries
@DeepOmit protected CoordIntMap _paint
@DeepOmit protected ArrayList<TudeySceneModel.PaintConfigMapping> _paintConfigs
@DeepOmit protected transient boolean _exportLayers
@DeepOmit protected transient List<String> _layers
@DeepOmit protected transient List<String> _layerNamesView
@DeepOmit protected transient Map<Integer,Integer> _layerMap
@DeepOmit protected transient Map<ConfigReference<? extends PaintableConfig>,Integer> _paintConfigIds
@DeepOmit protected transient Map<String,List<TudeySceneModel.Entry>> _tagged
protected transient int _lastEntryId
@DeepOmit protected transient WeakHashMap<ConfigReference,ConfigReference> _references
@DeepOmit protected transient CoordIntMap _tileCoords
@DeepOmit protected transient CoordIntMap _collisionFlags
@DeepOmit protected transient HashSpace _space
@DeepOmit protected transient HashMap<Object,SpaceElement> _elements
@DeepOmit protected transient ObserverList<TudeySceneModel.Observer> _observers
@DeepOmit protected transient SoftReference<byte[]> _data
@DeepOmit protected transient boolean _dirty
@DeepOmit protected transient Rectangle _region
@DeepOmit protected transient Rect _rect
@DeepOmit protected transient Polygon _quad
@DeepOmit protected transient ArrayList<SpaceElement> _intersecting
@DeepOmit protected transient Vector2f _penetration
@DeepOmit protected transient Point _point
@DeepOmit protected transient TudeySceneModel.FloorPlaceableFilter _floorPlaceableFilter
| Constructor Detail |
|---|
public TudeySceneModel()
| Method Detail |
|---|
public void init(ConfigManager cfgmgr)
public ConfigManager getConfigManager()
public void addObserver(TudeySceneModel.Observer observer)
public void removeObserver(TudeySceneModel.Observer observer)
public void setName(String name)
public void setNotes(String notes)
public String getNotes()
public void setPlaceConfig(TudeySceneConfig config)
public TudeySceneConfig getPlaceConfig()
public CoordIntMap getCollisionFlags()
public Space getSpace()
public Map<Object,SpaceElement> getElements()
public boolean addEntry(TudeySceneModel.Entry entry)
TudeySceneModel.IdEntry.
public boolean addEntry(TudeySceneModel.Entry entry,
boolean assignId)
assignId - if true and the entry is an TudeySceneModel.IdEntry, assign a unique id to
the entry.
public TudeySceneModel.Entry updateEntry(TudeySceneModel.Entry nentry)
null for none (in which
case a warning will be logged).public TudeySceneModel.Entry removeEntry(Object key)
null for none (in which
case a warning will be logged).public boolean containsEntry(Object key)
public TudeySceneModel.Entry getEntry(Object key)
null if not found.public TudeySceneModel.Entry getTaggedEntry(String tag)
null for none.
public List<TudeySceneModel.Entry> getTaggedEntries(String tag)
public Collection<TudeySceneModel.Entry> getEntries()
public void getEntries(Shape shape,
Collection<TudeySceneModel.Entry> results)
public void getEntries(Shape shape,
com.google.common.base.Predicate<? super TudeySceneModel.Entry> pred,
Collection<TudeySceneModel.Entry> results)
public void getTileEntries(Rectangle region,
Collection<TudeySceneModel.TileEntry> results)
public TudeySceneModel.TileEntry getTileEntry(int x,
int y)
public int getTileElevation(int x,
int y)
Integer.MIN_VALUE if
there is no tile there.
public float getFloorZ(float x,
float y,
float defvalue)
mask - the floor mask to use for the query.
public int addLayer(String name,
int position)
@Deprecated public int addLayer(String n)
public void renameLayer(int layer,
String name)
public List<String> getLayers()
public boolean isLayerEmpty(int layer)
public void removeLayer(int layer)
public int getLayer(Object key)
public void setLayer(Object key,
int layer)
public TudeySceneModel.Paint setPaint(int x,
int y,
TudeySceneModel.Paint paint)
public TudeySceneModel.Paint getPaint(int x,
int y)
public void clearPaint()
public void getPreloads(PreloadableSet preloads)
public void getResources(Set<String> paths)
public boolean validateReferences(String where,
PrintStream out)
public void writeFields(Exporter out)
throws IOException
IOException
public void readFields(Importer in)
throws IOException
IOException
public void writeObject(ObjectOutputStream out)
throws IOException
IOException
public void readObject(ObjectInputStream in)
throws IOException
IOExceptionpublic byte[] getData()
public void invalidate()
public void setDirty(boolean dirty)
public boolean isDirty()
public boolean collides(Actor actor,
Shape shape)
collides in interface ActorAdvancer.Environment
public boolean collides(int mask,
Shape shape)
public boolean getNearestPoint(Shape shape,
int mask,
Vector2f origin,
Vector2f nearPoint)
public boolean getIntersection(Ray2D ray,
float length,
int mask,
Vector2f intersection)
public TudeySceneModel getSceneModel()
ActorAdvancer.Environment
getSceneModel in interface ActorAdvancer.Environment
public boolean getPenetration(Actor actor,
Shape shape,
Vector2f result)
ActorAdvancer.Environment
getPenetration in interface ActorAdvancer.Environmentpublic TudeySceneModel clone()
clone in class SceneModelprotected TudeySceneModel.Entry add(TudeySceneModel.Entry entry)
protected TudeySceneModel.Entry update(TudeySceneModel.Entry nentry)
protected TudeySceneModel.Entry remove(Object key)
protected void addElement(TudeySceneModel.Entry entry)
protected void removeElement(TudeySceneModel.Entry entry)
protected void createShadow(TudeySceneModel.TileEntry entry)
protected void deleteShadow(TudeySceneModel.TileEntry entry)
protected void mapEntry(TudeySceneModel.Entry entry)
protected void unmapEntry(TudeySceneModel.Entry entry)
protected TudeySceneModel.TileEntry getTileEntry(int pair)
protected int getTileValue(int pair)
protected void canonicalizeReference(TudeySceneModel.Entry entry)
_references set (that is, that all entries whose references are equal point to
the same reference instance).
protected int addTileConfig(ConfigReference<TileConfig> tile)
protected void removeTileConfig(int idx)
protected TudeySceneModel.TileEntry decodeTileEntry(Coord coord,
int value)
protected TudeySceneModel.TileEntry decodeTileEntry(int x,
int y,
int value)
protected int addPaintConfig(ConfigReference<? extends PaintableConfig> paintable)
protected void removePaintConfig(int idx)
protected TudeySceneModel.Paint decodePaint(int value)
protected int validateLayer(int layer)
protected static int getConfigIndex(int value)
protected static int getElevation(int value)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||