The amazing revamp four hundred billion. Let's see:
- Reworked colorization repository such that we now have arbitrary named "colorization classes" which can be used by various and sundry entities to colorize themselves. - Added support for individual object colorizations as well as "spots" that go along with objects (will be used to automatically create portals into buildings and automatically position users properly when at a "station"). - Repackaged things in miso to more closely mimic what we do everywhere else (no more miso.scene, now we have miso.data and miso.client). - Fixed up miso scene XML representation so that objects can more easily be expanded to have yet more stuff if we think of more stuff that they might aught to have in the future. Structured the miso scene model so that "uninteresting" objects (those that simply sit somewhere and don't do anything) take up a lot less memory than "interesting" objects (those that have action strings, "spots", colorizations and the works). I may want to roll colorizations into the "uninteresting" realm, but that remains to be seen. - Made it possible for object tilesets to specify default render priorities for objects in that tileset. This will hopefully allow us to get by without any "custom" render priorities that are specified on scene objects, instead relying on the default priorities to resolve common conflicts. There are surely other cleanups in there, but I think that was the major thrust of it. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2228 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: DirtyItemList.java,v 1.17 2002/10/16 01:53:10 ray Exp $
|
||||
// $Id: DirtyItemList.java,v 1.18 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -17,7 +17,7 @@ import com.samskivert.util.StringUtil;
|
||||
import com.threerings.media.Log;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.tile.ObjectTile;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.client.util.IsoUtil;
|
||||
|
||||
/**
|
||||
* The dirty item list keeps track of dirty sprites and object tiles
|
||||
@@ -48,10 +48,10 @@ public class DirtyItemList
|
||||
* @param footprint the footprint of the object tile if it should be
|
||||
* rendered, null otherwise.
|
||||
*/
|
||||
public void appendDirtyObject (SceneObject scobj, Shape footprint)
|
||||
public void appendDirtyObject (DisplayObjectInfo info, Shape footprint)
|
||||
{
|
||||
DirtyItem item = getDirtyItem();
|
||||
item.init(scobj, scobj.bounds, footprint, scobj.x, scobj.y);
|
||||
item.init(info, info.bounds, footprint, info.x, info.y);
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ public class DirtyItemList
|
||||
// rightmost tiles are equivalent
|
||||
lx = rx = ox;
|
||||
ly = ry = oy;
|
||||
if (obj instanceof SceneObject) {
|
||||
ObjectTile tile = ((SceneObject)obj).tile;
|
||||
if (obj instanceof DisplayObjectInfo) {
|
||||
ObjectTile tile = ((DisplayObjectInfo)obj).tile;
|
||||
lx -= (tile.getBaseWidth() - 1);
|
||||
ry -= (tile.getBaseHeight() - 1);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public class DirtyItemList
|
||||
if (obj instanceof Sprite) {
|
||||
((Sprite)obj).paint(gfx);
|
||||
} else {
|
||||
((SceneObject)obj).tile.paint(gfx, bounds.x, bounds.y);
|
||||
((DisplayObjectInfo)obj).tile.paint(gfx, bounds.x, bounds.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ public class DirtyItemList
|
||||
// }
|
||||
|
||||
// // objects are equivalent if they are the same object
|
||||
// if ((obj instanceof SceneObject) && (b.obj instanceof SceneObject)) {
|
||||
// if ((obj instanceof DisplayObjectInfo) && (b.obj instanceof DisplayObjectInfo)) {
|
||||
// return (obj == b.obj);
|
||||
// }
|
||||
|
||||
@@ -534,10 +534,10 @@ public class DirtyItemList
|
||||
// priority scene; this allows us to avoid all sorts of sticky
|
||||
// business wherein the render order between two overlapping
|
||||
// objects cannot be determined without a z-buffer
|
||||
if ((da.obj instanceof SceneObject) &&
|
||||
(db.obj instanceof SceneObject)) {
|
||||
SceneObject soa = (SceneObject)da.obj;
|
||||
SceneObject sob = (SceneObject)db.obj;
|
||||
if ((da.obj instanceof DisplayObjectInfo) &&
|
||||
(db.obj instanceof DisplayObjectInfo)) {
|
||||
DisplayObjectInfo soa = (DisplayObjectInfo)da.obj;
|
||||
DisplayObjectInfo sob = (DisplayObjectInfo)db.obj;
|
||||
if (IsoUtil.objectFootprintsOverlap(soa, sob)) {
|
||||
return (soa.priority - sob.priority);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//
|
||||
// $Id: DisplayMisoScene.java,v 1.8 2003/01/13 22:53:56 mdb Exp $
|
||||
// $Id: DisplayMisoScene.java,v 1.9 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.threerings.media.tile.ObjectTile;
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
import com.threerings.miso.scene.util.ObjectSet;
|
||||
import com.threerings.miso.client.util.ObjectSet;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
@@ -30,10 +30,10 @@ public interface DisplayMisoScene
|
||||
public Tile getFringeTile (int x, int y);
|
||||
|
||||
/**
|
||||
* Populates the supplied scene object set with all objects whose
|
||||
* Populates the supplied object set with info on all objects whose
|
||||
* origin falls in the requested region.
|
||||
*/
|
||||
public void getSceneObjects (Rectangle region, ObjectSet set);
|
||||
public void getObjects (Rectangle region, ObjectSet set);
|
||||
|
||||
/**
|
||||
* Returns true if the supplied traverser can traverse the specified
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.64 2003/01/13 22:53:56 mdb Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.65 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.NoSuchTileException;
|
||||
import com.threerings.media.tile.NoSuchTileSetException;
|
||||
import com.threerings.media.tile.ObjectTile;
|
||||
@@ -17,7 +15,9 @@ import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.tile.TileLayer;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.ObjectSet;
|
||||
import com.threerings.miso.client.util.ObjectSet;
|
||||
import com.threerings.miso.data.MisoSceneModel;
|
||||
import com.threerings.miso.data.ObjectInfo;
|
||||
import com.threerings.miso.tile.AutoFringer;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
import com.threerings.miso.tile.BaseTileLayer;
|
||||
@@ -56,6 +56,62 @@ public class DisplayMisoSceneImpl
|
||||
setMisoSceneModel(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this display miso scene with a tile manager from which it
|
||||
* can load up all of its tiles.
|
||||
*/
|
||||
public void setTileManager (MisoTileManager tmgr)
|
||||
{
|
||||
_tmgr = tmgr;
|
||||
_fringer = tmgr.getAutoFringer();
|
||||
populateLayers();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public BaseTile getBaseTile (int x, int y)
|
||||
{
|
||||
return _base.getTile(x, y);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public Tile getFringeTile (int x, int y)
|
||||
{
|
||||
return _fringe.getTile(x, y);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public void getObjects (Rectangle region, ObjectSet set)
|
||||
{
|
||||
// iterate over all of our objects, creating and including scene
|
||||
// objects for those that intersect the region
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
DisplayObjectInfo scobj = (DisplayObjectInfo)_objects.get(ii);
|
||||
if (region.contains(scobj.x, scobj.y)) {
|
||||
set.insert(scobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public boolean canTraverse (Object trav, int x, int y)
|
||||
{
|
||||
BaseTile tile = getBaseTile(x, y);
|
||||
return (((tile == null) || tile.isPassable()) &&
|
||||
!_covered[y*_model.width+x]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of this Miso scene object.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("[width=").append(_base.getWidth());
|
||||
buf.append(", height=").append(_base.getHeight());
|
||||
return buf.append("]").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs this miso scene to use the supplied model instead of its
|
||||
* current model. This should be followed up by a called to {@link
|
||||
@@ -73,17 +129,20 @@ public class DisplayMisoSceneImpl
|
||||
_base = new BaseTileLayer(new BaseTile[swid*shei], swid, shei);
|
||||
_fringe = new TileLayer(new Tile[swid*shei], swid, shei);
|
||||
_covered = new boolean[swid*shei];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this display miso scene with a tile manager from which it
|
||||
* can load up all of its tiles.
|
||||
*/
|
||||
public void setTileManager (MisoTileManager tmgr)
|
||||
{
|
||||
_tmgr = tmgr;
|
||||
_fringer = tmgr.getAutoFringer();
|
||||
populateLayers();
|
||||
// create display object infos for our uninteresting objects
|
||||
int ocount = (_model.objectTileIds == null) ? 0 :
|
||||
_model.objectTileIds.length;
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
_objects.add(new DisplayObjectInfo(_model.objectTileIds[ii],
|
||||
_model.objectXs[ii],
|
||||
_model.objectYs[ii]));
|
||||
}
|
||||
|
||||
// create display object infos for our interesting objects
|
||||
for (int ii = 0, ll = _model.objectInfo.length; ii < ll; ii++) {
|
||||
_objects.add(new DisplayObjectInfo(_model.objectInfo[ii]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,132 +186,57 @@ public class DisplayMisoSceneImpl
|
||||
}
|
||||
}
|
||||
|
||||
// sanity check the object layer info
|
||||
int ocount = _model.objectTileIds.length;
|
||||
if (ocount % 3 != 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"model.objectTileIds.length % 3 != 0");
|
||||
}
|
||||
|
||||
// create object tile instances for our objects
|
||||
for (int ii = 0; ii < ocount; ii += 3) {
|
||||
int col = _model.objectTileIds[ii];
|
||||
int row = _model.objectTileIds[ii+1];
|
||||
int fqTid = _model.objectTileIds[ii+2];
|
||||
int tsid = (fqTid >> 16) & 0xFFFF, tid = (fqTid & 0xFFFF);
|
||||
try {
|
||||
expandObject(col, row, tsid, tid, fqTid, ii/3);
|
||||
} catch (NoSuchTileSetException te) {
|
||||
Log.warning("Scene contains non-existent object tile " +
|
||||
"[tsid=" + tsid + ", tid=" + tid +
|
||||
", col=" + col + ", row=" + row + "].");
|
||||
}
|
||||
// populate our display objects with object tiles
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
populateObject((DisplayObjectInfo)_objects.get(ii));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to expand each object read from the model into an actual
|
||||
* object tile instance with the appropriate additional data.
|
||||
*
|
||||
* @return the scene object record for the newly created object tile
|
||||
* (which will have been put into all the appropriate lists and
|
||||
* tables).
|
||||
* Called to populate an object with its object tile when we have been
|
||||
* configured with a tile manager from which to obtain such things.
|
||||
*/
|
||||
protected SceneObject expandObject (
|
||||
int col, int row, int tsid, int tid, int fqTid, int objidx)
|
||||
throws NoSuchTileException, NoSuchTileSetException
|
||||
protected void populateObject (DisplayObjectInfo info)
|
||||
{
|
||||
// create and initialize an object info record for this object
|
||||
SceneObject scobj = createSceneObject(
|
||||
col, row, (ObjectTile)_tmgr.getTile(tsid, tid));
|
||||
int tsid = (info.tileId >> 16) & 0xFFFF, tid = (info.tileId & 0xFFFF);
|
||||
try {
|
||||
initObject(info, (ObjectTile)_tmgr.getTile(tsid, tid));
|
||||
} catch (NoSuchTileSetException te) {
|
||||
Log.warning("Scene contains non-existent object tile " +
|
||||
"[info=" + info + ", tsid=" + tsid +
|
||||
", tid=" + tid + "].");
|
||||
}
|
||||
}
|
||||
|
||||
// assign the object's remaining attributes
|
||||
if (!StringUtil.blank(_model.objectActions[objidx])) {
|
||||
scobj.action = _model.objectActions[objidx];
|
||||
}
|
||||
// if we have object priorities, use 'em
|
||||
if (_model.objectPrios != null) {
|
||||
scobj.priority = _model.objectPrios[objidx];
|
||||
}
|
||||
/**
|
||||
* Initializes the supplied object with its object tile and configures
|
||||
* any necessary peripheral scene business that couldn't be configured
|
||||
* prior to the object having its tile.
|
||||
*/
|
||||
protected void initObject (DisplayObjectInfo info, ObjectTile tile)
|
||||
{
|
||||
// configure the object info with its object tile
|
||||
info.setObjectTile(tile);
|
||||
|
||||
// generate a "shadow" for this object tile by toggling the
|
||||
// "covered" flag on in all base tiles below it (to prevent
|
||||
// sprites from walking on those tiles)
|
||||
setObjectTileFootprint(scobj.tile, col, row, true);
|
||||
|
||||
// add the info record to the list
|
||||
_objects.add(scobj);
|
||||
|
||||
// return the object info so that derived classes may access it
|
||||
return scobj;
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public BaseTile getBaseTile (int x, int y)
|
||||
{
|
||||
return _base.getTile(x, y);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public Tile getFringeTile (int x, int y)
|
||||
{
|
||||
return _fringe.getTile(x, y);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public void getSceneObjects (Rectangle region, ObjectSet set)
|
||||
{
|
||||
// iterate over all of our objects, creating and including scene
|
||||
// objects for those that intersect the region
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = (SceneObject)_objects.get(ii);
|
||||
if (region.contains(scobj.x, scobj.y)) {
|
||||
set.insert(scobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public boolean canTraverse (Object trav, int x, int y)
|
||||
{
|
||||
BaseTile tile = getBaseTile(x, y);
|
||||
return (((tile == null) || tile.isPassable()) &&
|
||||
!_covered[y*_model.width+x]);
|
||||
setObjectTileFootprint(info.tile, info.x, info.y, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of this Miso scene object.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("[width=").append(_base.getWidth());
|
||||
buf.append(", height=").append(_base.getHeight());
|
||||
return buf.append("]").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a scene object record. This allows derived classes to
|
||||
* provide extended records.
|
||||
*/
|
||||
protected SceneObject createSceneObject (int x, int y, ObjectTile tile)
|
||||
{
|
||||
return new SceneObject(x, y, tile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the scene object record for the object tile at the
|
||||
* Locates the display object info record for the object tile at the
|
||||
* specified location. Two of the same kind of object tile cannot
|
||||
* exist at the same location.
|
||||
*/
|
||||
protected SceneObject getSceneObject (ObjectTile tile, int x, int y)
|
||||
protected DisplayObjectInfo getObjectInfo (ObjectTile tile, int x, int y)
|
||||
{
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = (SceneObject)_objects.get(ii);
|
||||
if (scobj.tile == tile && scobj.x == x && scobj.y == y) {
|
||||
return scobj;
|
||||
DisplayObjectInfo oinfo = (DisplayObjectInfo)_objects.get(ii);
|
||||
if (oinfo.tile == tile && oinfo.x == x && oinfo.y == y) {
|
||||
return oinfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,44 +1,56 @@
|
||||
//
|
||||
// $Id: DisplayObjectInfo.java,v 1.5 2002/11/28 03:41:58 mdb Exp $
|
||||
// $Id: DisplayObjectInfo.java,v 1.6 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.ObjectTile;
|
||||
import com.threerings.miso.data.ObjectInfo;
|
||||
|
||||
/**
|
||||
* Used to track information about an object in the scene.
|
||||
*/
|
||||
public class SceneObject
|
||||
public class DisplayObjectInfo extends ObjectInfo
|
||||
{
|
||||
/** A reference to the object tile itself. */
|
||||
public ObjectTile tile;
|
||||
|
||||
/** The x and y tile coordinates of the object. */
|
||||
public int x = -1, y = -1;
|
||||
|
||||
/** The object's render priority. */
|
||||
public byte priority = 0;
|
||||
|
||||
/** The action associated with this object or null if it has no
|
||||
* action. */
|
||||
public String action;
|
||||
|
||||
/** The object's bounding rectangle. This will be filled in
|
||||
* automatically by the Miso scene view when the object is used. */
|
||||
* automatically by the scene view when the object is used. */
|
||||
public Rectangle bounds;
|
||||
|
||||
/**
|
||||
* Convenience constructor.
|
||||
*/
|
||||
public SceneObject (int x, int y, ObjectTile tile)
|
||||
public DisplayObjectInfo (int tileId, int x, int y)
|
||||
{
|
||||
super(tileId, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor.
|
||||
*/
|
||||
public DisplayObjectInfo (ObjectInfo source)
|
||||
{
|
||||
super(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this display object with a reference to its object tile
|
||||
* when it becomes available. This must be called before the tile is
|
||||
* used in any sort of display circumstances.
|
||||
*/
|
||||
public void setObjectTile (ObjectTile tile)
|
||||
{
|
||||
this.tile = tile;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
// if we don't already have an overridden render priority; use the
|
||||
// one from our object tile (assuming we have one)
|
||||
if (priority == 0 && tile != null) {
|
||||
priority = (byte)Math.max(
|
||||
Byte.MIN_VALUE, Math.min(Byte.MAX_VALUE, tile.getPriority()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,29 +62,4 @@ public class SceneObject
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
if (other instanceof SceneObject) {
|
||||
SceneObject oso = (SceneObject)other;
|
||||
return (x == oso.x && y == oso.y && tile == oso.tile);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public int hashCode ()
|
||||
{
|
||||
return x ^ y ^ tile.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this instance.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
return StringUtil.fieldsToString(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.130 2003/01/15 21:12:45 shaper Exp $
|
||||
// $Id: IsoSceneView.java,v 1.131 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
@@ -36,10 +36,10 @@ import com.threerings.media.tile.Tile;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.MisoPrefs;
|
||||
import com.threerings.miso.scene.DirtyItemList.DirtyItem;
|
||||
import com.threerings.miso.scene.util.AStarPathUtil;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.scene.util.ObjectSet;
|
||||
import com.threerings.miso.client.DirtyItemList.DirtyItem;
|
||||
import com.threerings.miso.client.util.AStarPathUtil;
|
||||
import com.threerings.miso.client.util.IsoUtil;
|
||||
import com.threerings.miso.client.util.ObjectSet;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
@@ -124,12 +124,12 @@ public class IsoSceneView implements SceneView
|
||||
// grab all available objects
|
||||
Rectangle rect = new Rectangle(Short.MIN_VALUE, Short.MIN_VALUE,
|
||||
2*Short.MAX_VALUE, 2*Short.MAX_VALUE);
|
||||
_scene.getSceneObjects(rect, _objects);
|
||||
_scene.getObjects(rect, _objects);
|
||||
|
||||
// and fill in the new objects' bounds
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = _objects.get(ii);
|
||||
DisplayObjectInfo scobj = _objects.get(ii);
|
||||
if (scobj.bounds == null) {
|
||||
scobj.bounds = IsoUtil.getObjectBounds(_model, scobj);
|
||||
}
|
||||
@@ -194,8 +194,8 @@ public class IsoSceneView implements SceneView
|
||||
Polygon hpoly = null;
|
||||
|
||||
// if we have a hover object, do some business
|
||||
if (_hobject != null && _hobject instanceof SceneObject) {
|
||||
SceneObject scobj = (SceneObject)_hobject;
|
||||
if (_hobject != null && _hobject instanceof DisplayObjectInfo) {
|
||||
DisplayObjectInfo scobj = (DisplayObjectInfo)_hobject;
|
||||
if (scobj.action != null || _hmode == HIGHLIGHT_ALWAYS) {
|
||||
hpoly = IsoUtil.getObjectFootprint(_model, scobj);
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class IsoSceneView implements SceneView
|
||||
// add any objects impacted by the dirty rectangle
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = (SceneObject)_objects.get(ii);
|
||||
DisplayObjectInfo scobj = _objects.get(ii);
|
||||
if (!scobj.bounds.intersects(clip)) {
|
||||
continue;
|
||||
}
|
||||
@@ -467,13 +467,13 @@ public class IsoSceneView implements SceneView
|
||||
// grab all available objects
|
||||
Rectangle rect = new Rectangle(Short.MIN_VALUE, Short.MIN_VALUE,
|
||||
2*Short.MAX_VALUE, 2*Short.MAX_VALUE);
|
||||
_scene.getSceneObjects(rect, _objects);
|
||||
addAdditionalSceneObjects(_objects);
|
||||
_scene.getObjects(rect, _objects);
|
||||
addAdditionalObjects(_objects);
|
||||
|
||||
// and fill in those objects' bounds
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = _objects.get(ii);
|
||||
DisplayObjectInfo scobj = _objects.get(ii);
|
||||
scobj.bounds = IsoUtil.getObjectBounds(_model, scobj);
|
||||
}
|
||||
}
|
||||
@@ -482,7 +482,7 @@ public class IsoSceneView implements SceneView
|
||||
* A place for subclasses to add any additional scene objects they
|
||||
* may have.
|
||||
*/
|
||||
protected void addAdditionalSceneObjects (ObjectSet set)
|
||||
protected void addAdditionalObjects (ObjectSet set)
|
||||
{
|
||||
// nothing by default
|
||||
}
|
||||
@@ -581,8 +581,8 @@ public class IsoSceneView implements SceneView
|
||||
}
|
||||
|
||||
// unhover the old
|
||||
if (_hobject instanceof SceneObject) {
|
||||
SceneObject oldhov = (SceneObject) _hobject;
|
||||
if (_hobject instanceof DisplayObjectInfo) {
|
||||
DisplayObjectInfo oldhov = (DisplayObjectInfo) _hobject;
|
||||
if (oldhov.setHovered(false)) {
|
||||
_remgr.invalidateRegion(oldhov.bounds);
|
||||
}
|
||||
@@ -593,8 +593,8 @@ public class IsoSceneView implements SceneView
|
||||
_hobject = newHover;
|
||||
|
||||
// hover the new
|
||||
if (_hobject instanceof SceneObject) {
|
||||
SceneObject newhov = (SceneObject) _hobject;
|
||||
if (_hobject instanceof DisplayObjectInfo) {
|
||||
DisplayObjectInfo newhov = (DisplayObjectInfo) _hobject;
|
||||
if (newhov.setHovered(true)) {
|
||||
_remgr.invalidateRegion(newhov.bounds);
|
||||
}
|
||||
@@ -622,7 +622,7 @@ public class IsoSceneView implements SceneView
|
||||
{
|
||||
int ocount = _objects.size();
|
||||
for (int ii = 0; ii < ocount; ii++) {
|
||||
SceneObject scobj = (SceneObject)_objects.get(ii);
|
||||
DisplayObjectInfo scobj = (DisplayObjectInfo)_objects.get(ii);
|
||||
Rectangle pbounds = scobj.bounds;
|
||||
// skip bounding rects that don't contain the point
|
||||
if (!pbounds.contains(x, y)) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//
|
||||
// $Id: IsoSceneViewModel.java,v 1.27 2003/01/15 21:12:45 shaper Exp $
|
||||
// $Id: IsoSceneViewModel.java,v 1.28 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.MisoConfig;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.client.util.IsoUtil;
|
||||
|
||||
/**
|
||||
* Provides a holding place for the myriad parameters and bits of data
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: SceneView.java,v 1.32 2003/01/13 22:53:56 mdb Exp $
|
||||
// $Id: SceneView.java,v 1.33 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
@@ -79,7 +79,7 @@ public interface SceneView
|
||||
|
||||
/**
|
||||
* Returns information about the object over which the mouse is
|
||||
* currently hovering (either a {@link SceneObject} or a {@link
|
||||
* currently hovering (either a {@link DisplayObjectInfo} or a {@link
|
||||
* Sprite}), or null if the mouse is not hovering over anything of
|
||||
* interest.
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: SceneViewPanel.java,v 1.48 2003/01/15 21:12:45 shaper Exp $
|
||||
// $Id: SceneViewPanel.java,v 1.49 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -22,7 +22,7 @@ import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.SpriteManager;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.client.util.IsoUtil;
|
||||
|
||||
/**
|
||||
* The scene view panel is responsible for managing a {@link
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: TilePath.java,v 1.12 2003/01/13 22:53:56 mdb Exp $
|
||||
// $Id: TilePath.java,v 1.13 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@ import com.threerings.media.util.PathNode;
|
||||
import com.threerings.media.util.Pathable;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.IsoUtil;
|
||||
import com.threerings.miso.client.util.IsoUtil;
|
||||
|
||||
/**
|
||||
* The tile path represents a path of tiles through a scene. The path is
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: TilePathNode.java,v 1.2 2002/05/31 03:38:03 mdb Exp $
|
||||
// $Id: TilePathNode.java,v 1.3 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
package com.threerings.miso.client;
|
||||
|
||||
import com.threerings.media.util.PathNode;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: AStarPathUtil.java,v 1.24 2003/01/15 21:44:52 shaper Exp $
|
||||
// $Id: AStarPathUtil.java,v 1.25 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
package com.threerings.miso.client.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.*;
|
||||
@@ -11,7 +11,7 @@ import com.samskivert.util.HashIntMap;
|
||||
import com.threerings.media.util.MathUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.DisplayMisoScene;
|
||||
import com.threerings.miso.client.DisplayMisoScene;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: IsoUtil.java,v 1.42 2003/01/13 22:53:56 mdb Exp $
|
||||
// $Id: IsoUtil.java,v 1.43 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
package com.threerings.miso.client.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
@@ -16,8 +16,8 @@ import com.threerings.util.DirectionCodes;
|
||||
import com.threerings.util.DirectionUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.IsoSceneViewModel;
|
||||
import com.threerings.miso.scene.SceneObject;
|
||||
import com.threerings.miso.client.IsoSceneViewModel;
|
||||
import com.threerings.miso.client.DisplayObjectInfo;
|
||||
|
||||
/**
|
||||
* The <code>IsoUtil</code> class is a holding place for miscellaneous
|
||||
@@ -38,7 +38,7 @@ public class IsoUtil
|
||||
* @return the bounding polygon.
|
||||
*/
|
||||
public static Polygon getObjectFootprint (
|
||||
IsoSceneViewModel model, SceneObject scobj)
|
||||
IsoSceneViewModel model, DisplayObjectInfo scobj)
|
||||
{
|
||||
Polygon boundsPoly = new SmartPolygon();
|
||||
Point tpos = tileToScreen(model, scobj.x, scobj.y, new Point());
|
||||
@@ -84,7 +84,7 @@ public class IsoUtil
|
||||
* @return the bounding rectangle.
|
||||
*/
|
||||
public static Rectangle getObjectBounds (
|
||||
IsoSceneViewModel model, SceneObject scobj)
|
||||
IsoSceneViewModel model, DisplayObjectInfo scobj)
|
||||
{
|
||||
Point tpos = tileToScreen(model, scobj.x, scobj.y, new Point());
|
||||
|
||||
@@ -110,7 +110,7 @@ public class IsoUtil
|
||||
* the objects occupy the specified coordinates, false if not.
|
||||
*/
|
||||
public static boolean objectFootprintsOverlap (
|
||||
SceneObject so1, SceneObject so2)
|
||||
DisplayObjectInfo so1, DisplayObjectInfo so2)
|
||||
{
|
||||
return (so2.x > so1.x - so1.tile.getBaseWidth() &&
|
||||
so1.x > so2.x - so2.tile.getBaseWidth() &&
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: ObjectSet.java,v 1.2 2002/10/15 21:01:39 ray Exp $
|
||||
// $Id: ObjectSet.java,v 1.3 2003/01/31 23:10:45 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
package com.threerings.miso.client.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -9,31 +9,36 @@ import java.util.Comparator;
|
||||
import com.samskivert.util.ArrayUtil;
|
||||
import com.samskivert.util.ListUtil;
|
||||
|
||||
import com.threerings.miso.scene.SceneObject;
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.client.DisplayObjectInfo;
|
||||
|
||||
/**
|
||||
* Used to store an (arbitrarily) ordered, low-impact iteratable (doesn't
|
||||
* require object creation), set of {@link SceneObject} instances.
|
||||
* require object creation), set of {@link DisplayObjectInfo} instances.
|
||||
*/
|
||||
public class ObjectSet
|
||||
{
|
||||
/**
|
||||
* Inserts the supplied scene object into the set.
|
||||
* Inserts the supplied object into the set.
|
||||
*
|
||||
* @return true if it was inserted, false if the object was already in
|
||||
* the set.
|
||||
*/
|
||||
public boolean insert (SceneObject scobj)
|
||||
public boolean insert (DisplayObjectInfo info)
|
||||
{
|
||||
// bail if it's already in the set
|
||||
int ipos = indexOf(scobj);
|
||||
int ipos = indexOf(info);
|
||||
if (ipos >= 0) {
|
||||
// log a warning because the caller shouldn't be doing this
|
||||
Log.warning("Requested to add a display object to a set that " +
|
||||
"already contains such an object [ninfo=" + info +
|
||||
", oinfo=" + _objs[ipos] + "].");
|
||||
return false;
|
||||
}
|
||||
|
||||
// otherwise insert it
|
||||
ipos = -(ipos+1);
|
||||
_scobjs = ListUtil.insert(_scobjs, ipos, scobj);
|
||||
_objs = ListUtil.insert(_objs, ipos, info);
|
||||
_size++;
|
||||
return true;
|
||||
}
|
||||
@@ -42,13 +47,13 @@ public class ObjectSet
|
||||
* Returns true if the specified object is in the set, false if it is
|
||||
* not.
|
||||
*/
|
||||
public boolean contains (SceneObject scobj)
|
||||
public boolean contains (DisplayObjectInfo info)
|
||||
{
|
||||
return (indexOf(scobj) >= 0);
|
||||
return (indexOf(info) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of scene objects in this set.
|
||||
* Returns the number of objects in this set.
|
||||
*/
|
||||
public int size ()
|
||||
{
|
||||
@@ -56,12 +61,12 @@ public class ObjectSet
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scene object with the specified index. The index must &
|
||||
* be between <code>0</code> and {@link #size}<code>-1</code>.
|
||||
* Returns the object with the specified index. The index must & be
|
||||
* between <code>0</code> and {@link #size}<code>-1</code>.
|
||||
*/
|
||||
public SceneObject get (int index)
|
||||
public DisplayObjectInfo get (int index)
|
||||
{
|
||||
return (SceneObject)_scobjs[index];
|
||||
return (DisplayObjectInfo)_objs[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,18 +74,18 @@ public class ObjectSet
|
||||
*/
|
||||
public void remove (int index)
|
||||
{
|
||||
ListUtil.remove(_scobjs, index);
|
||||
ListUtil.remove(_objs, index);
|
||||
_size--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified scene object from the set.
|
||||
* Removes the specified object from the set.
|
||||
*
|
||||
* @return true if it was removed, false if it was not in the set.
|
||||
*/
|
||||
public boolean remove (SceneObject scobj)
|
||||
public boolean remove (DisplayObjectInfo info)
|
||||
{
|
||||
int opos = indexOf(scobj);
|
||||
int opos = indexOf(info);
|
||||
if (opos >= 0) {
|
||||
remove(opos);
|
||||
return true;
|
||||
@@ -95,30 +100,50 @@ public class ObjectSet
|
||||
public void clear ()
|
||||
{
|
||||
_size = 0;
|
||||
Arrays.fill(_scobjs, null);
|
||||
Arrays.fill(_objs, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this instance.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("[");
|
||||
for (int ii = 0; ii < _size; ii++) {
|
||||
if (ii > 0) {
|
||||
buf.append(", ");
|
||||
}
|
||||
buf.append(_objs[ii]);
|
||||
}
|
||||
return buf.append("]").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the object or it's insertion index if it is
|
||||
* not in the set.
|
||||
*/
|
||||
protected final int indexOf (SceneObject scobj)
|
||||
protected final int indexOf (DisplayObjectInfo info)
|
||||
{
|
||||
return ArrayUtil.binarySearch(_scobjs, 0, _size, scobj, SCOBJ_COMP);
|
||||
return ArrayUtil.binarySearch(_objs, 0, _size, info, INFO_COMP);
|
||||
}
|
||||
|
||||
/** Our sorted array of scene objects. */
|
||||
protected Object[] _scobjs = new Object[DEFAULT_SIZE];
|
||||
/** Our sorted array of objects. */
|
||||
protected Object[] _objs = new Object[DEFAULT_SIZE];
|
||||
|
||||
/** The number of objects in the set. */
|
||||
protected int _size;
|
||||
|
||||
/** We simply sort the scene objects in order of their hash code. We
|
||||
* don't care about their orderer, it simply needs to exist to support
|
||||
* binary search. */
|
||||
protected static final Comparator SCOBJ_COMP = new Comparator() {
|
||||
/** We simply sort the objects in order of their hash code. We don't
|
||||
* care about their order, it exists only to support binary search. */
|
||||
protected static final Comparator INFO_COMP = new Comparator() {
|
||||
public int compare (Object o1, Object o2) {
|
||||
return o1.hashCode() - o2.hashCode();
|
||||
DisplayObjectInfo do1 = (DisplayObjectInfo)o1;
|
||||
DisplayObjectInfo do2 = (DisplayObjectInfo)o2;
|
||||
if (do1.tileId == do2.tileId) {
|
||||
return ((do1.x << 16) + do1.y) - ((do2.x << 16) + do2.y);
|
||||
} else {
|
||||
return do1.tileId - do2.tileId;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user