Separate the notion of tile passability from tile objects since
passability is specific to the miso layer. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@405 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
//
|
||||
// $Id: CharacterSprite.java,v 1.9 2001/09/13 19:10:26 mdb Exp $
|
||||
// $Id: CharacterSprite.java,v 1.10 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.media.sprite.*;
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* An <code>AmbulatorySprite</code> is a sprite that can face in one of
|
||||
@@ -48,7 +48,7 @@ public class AmbulatorySprite extends Sprite implements Traverser
|
||||
setFrames(_anims[_orient]);
|
||||
}
|
||||
|
||||
public boolean canTraverse (Tile tile)
|
||||
public boolean canTraverse (MisoTile tile)
|
||||
{
|
||||
// by default, passability is solely the province of the tile
|
||||
return tile.passable;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Tile.java,v 1.12 2001/09/28 01:24:27 mdb Exp $
|
||||
// $Id: Tile.java,v 1.13 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.media.tile;
|
||||
|
||||
@@ -25,9 +25,6 @@ public class Tile
|
||||
/** The tile height in pixels. */
|
||||
public short height;
|
||||
|
||||
/** Whether the tile is passable. */
|
||||
public boolean passable;
|
||||
|
||||
/**
|
||||
* Construct a new tile with the specified identifiers. Intended
|
||||
* only for use by the <code>TileSet</code>. Do not call this
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TileSet.java,v 1.15 2001/08/30 01:13:08 shaper Exp $
|
||||
// $Id: TileSet.java,v 1.16 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.media.tile;
|
||||
|
||||
@@ -26,25 +26,9 @@ public class TileSet
|
||||
/**
|
||||
* Construct a new <code>TileSet</code> object.
|
||||
*/
|
||||
public TileSet (
|
||||
String name, int tsid, String imgFile,
|
||||
int[] rowWidth, int[] rowHeight, int[] tileCount, int[] passable,
|
||||
Point offsetPos, Point gapDist)
|
||||
public TileSet ()
|
||||
{
|
||||
_name = name;
|
||||
_tsid = tsid;
|
||||
_imgFile = imgFile;
|
||||
_rowWidth = rowWidth;
|
||||
_rowHeight = rowHeight;
|
||||
_tileCount = tileCount;
|
||||
_passable = passable;
|
||||
_offsetPos = offsetPos;
|
||||
_gapDist = gapDist;
|
||||
|
||||
// determine the total number of tiles in the set
|
||||
for (int ii = 0; ii < _tileCount.length; ii++) {
|
||||
_numTiles += _tileCount[ii];
|
||||
}
|
||||
_model = new TileSetModel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +36,7 @@ public class TileSet
|
||||
*/
|
||||
public int getId ()
|
||||
{
|
||||
return _tsid;
|
||||
return _model.tsid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +44,7 @@ public class TileSet
|
||||
*/
|
||||
public String getName ()
|
||||
{
|
||||
return _name;
|
||||
return _model.name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +52,7 @@ public class TileSet
|
||||
*/
|
||||
public int getNumTiles ()
|
||||
{
|
||||
return _numTiles;
|
||||
return _model.numTiles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,9 +68,9 @@ public class TileSet
|
||||
{
|
||||
// load the full tile image if we don't already have it
|
||||
if (_imgTiles == null) {
|
||||
if ((_imgTiles = imgmgr.getImage(_imgFile)) == null) {
|
||||
if ((_imgTiles = imgmgr.getImage(_model.imgFile)) == null) {
|
||||
Log.warning("Failed to retrieve full tileset image " +
|
||||
"[file=" + _imgFile + "].");
|
||||
"[file=" + _model.imgFile + "].");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -96,19 +80,19 @@ public class TileSet
|
||||
ridx = tcount = 0;
|
||||
|
||||
// start tile image position at image start offset
|
||||
tx = _offsetPos.x;
|
||||
ty = _offsetPos.y;
|
||||
tx = _model.offsetPos.x;
|
||||
ty = _model.offsetPos.y;
|
||||
|
||||
while ((tcount += _tileCount[ridx]) < tid + 1) {
|
||||
while ((tcount += _model.tileCount[ridx]) < tid + 1) {
|
||||
// increment tile image position by row height and gap distance
|
||||
ty += (_rowHeight[ridx++] + _gapDist.y);
|
||||
ty += (_model.rowHeight[ridx++] + _model.gapDist.y);
|
||||
}
|
||||
|
||||
// determine the horizontal index of this tile in the row
|
||||
int xidx = tid - (tcount - _tileCount[ridx]);
|
||||
int xidx = tid - (tcount - _model.tileCount[ridx]);
|
||||
|
||||
// final image x-position is based on tile width and gap distance
|
||||
tx += (xidx * (_rowWidth[ridx] + _gapDist.x));
|
||||
tx += (xidx * (_model.rowWidth[ridx] + _model.gapDist.x));
|
||||
|
||||
// Log.info("Retrieving tile image [tid=" + tid + ", ridx=" +
|
||||
// ridx + ", xidx=" + xidx + ", tx=" + tx +
|
||||
@@ -116,7 +100,7 @@ public class TileSet
|
||||
|
||||
// crop the tile-sized image chunk from the full image
|
||||
return imgmgr.getImageCropped(
|
||||
_imgTiles, tx, ty, _rowWidth[ridx], _rowHeight[ridx]);
|
||||
_imgTiles, tx, ty, _model.rowWidth[ridx], _model.rowHeight[ridx]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,18 +117,18 @@ public class TileSet
|
||||
public Tile getTile (ImageManager imgmgr, int tid)
|
||||
{
|
||||
// bail if there's no such tile
|
||||
if (tid > (_numTiles - 1)) {
|
||||
if (tid > (_model.numTiles - 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create the tile object
|
||||
Tile tile = new Tile(_tsid, tid);
|
||||
Tile tile = createTile(tid);
|
||||
|
||||
// retrieve the tile image
|
||||
tile.img = getTileImage(imgmgr, tid);
|
||||
if (tile.img == null) {
|
||||
Log.warning("Null tile image " +
|
||||
"[tsid=" + _tsid + ", tid=" + tid + "].");
|
||||
"[tsid=" + _model.tsid + ", tid=" + tid + "].");
|
||||
}
|
||||
|
||||
// populate the tile's dimensions
|
||||
@@ -152,61 +136,94 @@ public class TileSet
|
||||
tile.height = (short)bimg.getHeight();
|
||||
tile.width = (short)bimg.getWidth();
|
||||
|
||||
// and its passability
|
||||
tile.passable = (_passable[tid] == 1);
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tile set model.
|
||||
*/
|
||||
public TileSetModel getModel ()
|
||||
{
|
||||
return _model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of the tileset information.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("[name=").append(_name);
|
||||
buf.append(", file=").append(_imgFile);
|
||||
buf.append(", tsid=").append(_tsid);
|
||||
buf.append(", numtiles=").append(_numTiles);
|
||||
return buf.append("]").toString();
|
||||
return _model.toString();
|
||||
}
|
||||
|
||||
/** The tileset name. */
|
||||
protected String _name;
|
||||
|
||||
/** The file containing the tile images. */
|
||||
protected String _imgFile;
|
||||
|
||||
/** The tileset unique identifier. */
|
||||
protected int _tsid;
|
||||
|
||||
/** The width of the tiles in each row in pixels. */
|
||||
protected int _rowWidth[];
|
||||
|
||||
/** The height of each row in pixels. */
|
||||
protected int _rowHeight[];
|
||||
|
||||
/** The number of tiles in each row. */
|
||||
protected int _tileCount[];
|
||||
|
||||
/** Whether each tile is passable. */
|
||||
protected int _passable[];
|
||||
|
||||
/**
|
||||
* The offset distance (x, y) in pixels from the top-left of the
|
||||
* image to the start of the first tile image.
|
||||
* Construct and return a new tile object for further population
|
||||
* with tile-specific information.
|
||||
*/
|
||||
protected Point _offsetPos;
|
||||
|
||||
/**
|
||||
* The distance (x, y) in pixels between each tile in each row
|
||||
* horizontally, and between each row of tiles vertically.
|
||||
*/
|
||||
protected Point _gapDist;
|
||||
|
||||
/** The total number of tiles. */
|
||||
protected int _numTiles;
|
||||
protected Tile createTile (int tid)
|
||||
{
|
||||
return new Tile(_model.tsid, tid);
|
||||
}
|
||||
|
||||
/** The image containing all tile images for this set. */
|
||||
protected Image _imgTiles;
|
||||
|
||||
/** The tile set data model. */
|
||||
protected TileSetModel _model;
|
||||
|
||||
/**
|
||||
* The model that details the attributes of each tile in a
|
||||
* tileset. Storing the data separately from the tile set object
|
||||
* itself allows for the wealth of information associated with a
|
||||
* tile set to be more cleanly gathered and passed on to the tile
|
||||
* set constructor by those that need to do so.
|
||||
*/
|
||||
public static class TileSetModel
|
||||
{
|
||||
/** The tileset name. */
|
||||
public String name;
|
||||
|
||||
/** The tileset unique identifier. */
|
||||
public int tsid;
|
||||
|
||||
/** The file containing the tile images. */
|
||||
public String imgFile;
|
||||
|
||||
/** The width of the tiles in each row in pixels. */
|
||||
public int[] rowWidth;
|
||||
|
||||
/** The height of the tiles in each row in pixels. */
|
||||
public int[] rowHeight;
|
||||
|
||||
/** The number of tiles in each row. */
|
||||
public int[] tileCount;
|
||||
|
||||
/** The number of tiles in the tileset. */
|
||||
public int numTiles;
|
||||
|
||||
/**
|
||||
* The offset distance (x, y) in pixels from the top-left of the
|
||||
* image to the start of the first tile image.
|
||||
*/
|
||||
public Point offsetPos = new Point();
|
||||
|
||||
/**
|
||||
* The distance (x, y) in pixels between each tile in each row
|
||||
* horizontally, and between each row of tiles vertically.
|
||||
*/
|
||||
public Point gapDist = new Point();
|
||||
|
||||
public TileSetModel ()
|
||||
{
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("[name=").append(name);
|
||||
buf.append(", file=").append(imgFile);
|
||||
buf.append(", tsid=").append(tsid);
|
||||
buf.append(", numtiles=").append(numTiles);
|
||||
return buf.append("]").toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLTileSetParser.java,v 1.14 2001/09/27 18:43:08 shaper Exp $
|
||||
// $Id: XMLTileSetParser.java,v 1.15 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.media.tile;
|
||||
|
||||
@@ -24,16 +24,59 @@ import com.threerings.media.Log;
|
||||
public class XMLTileSetParser extends DefaultHandler
|
||||
implements TileSetParser
|
||||
{
|
||||
/**
|
||||
* This method is called when an element is fully parsed. The
|
||||
* complete parsed data for the element is passed in the given
|
||||
* string.
|
||||
*
|
||||
* @param qName the element name.
|
||||
* @param str the full parsed data for the element.
|
||||
*/
|
||||
protected void finishElement (String qName, String str)
|
||||
{
|
||||
if (qName.equals("imagefile")) {
|
||||
_model.imgFile = str;
|
||||
|
||||
} else if (qName.equals("rowwidth")) {
|
||||
_model.rowWidth = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (qName.equals("rowheight")) {
|
||||
_model.rowHeight = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (qName.equals("tilecount")) {
|
||||
_model.tileCount = StringUtil.parseIntArray(str);
|
||||
|
||||
// calculate the total number of tiles in the tileset
|
||||
for (int ii = 0; ii < _model.tileCount.length; ii++) {
|
||||
_model.numTiles += _model.tileCount[ii];
|
||||
}
|
||||
|
||||
} else if (qName.equals("offsetpos")) {
|
||||
getPoint(str, _model.offsetPos);
|
||||
|
||||
} else if (qName.equals("gapdist")) {
|
||||
getPoint(str, _model.gapDist);
|
||||
|
||||
} else if (qName.equals("tileset")) {
|
||||
// construct the tileset on tag close and add it to the
|
||||
// list of tilesets constructed thus far
|
||||
_tilesets.add(_tset);
|
||||
|
||||
// prepare to read another tileset object
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
public void startElement (String uri, String localName,
|
||||
String qName, Attributes attributes)
|
||||
{
|
||||
_tag = qName;
|
||||
|
||||
if (_tag.equals("tileset")) {
|
||||
_info.tsid = getTileSetId(attributes.getValue("tsid"));
|
||||
_model.tsid = getTileSetId(attributes.getValue("tsid"));
|
||||
|
||||
String str = attributes.getValue("name");
|
||||
_info.name = (str == null) ? DEF_NAME : str;
|
||||
_model.name = (str == null) ? DEF_NAME : str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,42 +86,7 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
// for the elements we're tracking at this point, so proceed
|
||||
// with saving off element values for use when we construct
|
||||
// the tileset object.
|
||||
String str = _chars.toString().trim();
|
||||
|
||||
if (qName.equals("imagefile")) {
|
||||
_info.imgfile = str;
|
||||
|
||||
} else if (qName.equals("rowwidth")) {
|
||||
_info.rowwidth = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (qName.equals("rowheight")) {
|
||||
_info.rowheight = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (qName.equals("tilecount")) {
|
||||
_info.tilecount = StringUtil.parseIntArray(str);
|
||||
|
||||
// calculate the total number of tiles in the tileset
|
||||
for (int ii = 0; ii < _info.tilecount.length; ii++) {
|
||||
_info.numtiles += _info.tilecount[ii];
|
||||
}
|
||||
|
||||
} else if (qName.equals("passable")) {
|
||||
_info.passable = StringUtil.parseIntArray(str);
|
||||
|
||||
} else if (qName.equals("offsetpos")) {
|
||||
getPoint(str, _info.offsetpos);
|
||||
|
||||
} else if (qName.equals("gapdist")) {
|
||||
getPoint(str, _info.gapdist);
|
||||
|
||||
} else if (qName.equals("tileset")) {
|
||||
// construct the tileset on tag close and add it to the
|
||||
// list of tilesets constructed thus far
|
||||
_tilesets.add(_info.constructTileSet());
|
||||
|
||||
// prepare to read another tileset object
|
||||
init();
|
||||
}
|
||||
finishElement(qName, _chars.toString().trim());
|
||||
|
||||
// note that we're not within a tag to avoid considering any
|
||||
// characters during this quiescent time
|
||||
@@ -132,7 +140,16 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
protected void init ()
|
||||
{
|
||||
_chars = new StringBuffer();
|
||||
_info = new TileSetInfo();
|
||||
_tset = createTileSet();
|
||||
_model = _tset.getModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs and returns a new tile set object.
|
||||
*/
|
||||
protected TileSet createTileSet ()
|
||||
{
|
||||
return new TileSet();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,64 +199,9 @@ public class XMLTileSetParser extends DefaultHandler
|
||||
/** Temporary storage of character data while parsing. */
|
||||
protected StringBuffer _chars;
|
||||
|
||||
/** Temporary storage of tileset info while parsing. */
|
||||
protected TileSetInfo _info;
|
||||
/** The tile set whose model is populated while parsing. */
|
||||
protected TileSet _tset;
|
||||
|
||||
/**
|
||||
* A class to hold temporary information on a tileset.
|
||||
*/
|
||||
class TileSetInfo
|
||||
{
|
||||
/** The tileset name. */
|
||||
public String name;
|
||||
|
||||
/** The tileset id. */
|
||||
public int tsid;
|
||||
|
||||
/** The tileset full image file path. */
|
||||
public String imgfile;
|
||||
|
||||
/** The width of the tiles in each row. */
|
||||
public int[] rowwidth;
|
||||
|
||||
/** The height of the tiles in each row. */
|
||||
public int[] rowheight;
|
||||
|
||||
/** The number of tiles in each row. */
|
||||
public int[] tilecount;
|
||||
|
||||
/** The passability of each tile. */
|
||||
public int[] passable;
|
||||
|
||||
/** The number of tiles in the tileset. */
|
||||
public int numtiles;
|
||||
|
||||
/** The offset position at which tiles begin in the tile image. */
|
||||
public Point offsetpos;
|
||||
|
||||
/** The gap distance between each tile in the tile image. */
|
||||
public Point gapdist;
|
||||
|
||||
public TileSetInfo ()
|
||||
{
|
||||
offsetpos = new Point();
|
||||
gapdist = new Point();
|
||||
}
|
||||
|
||||
public TileSet constructTileSet ()
|
||||
{
|
||||
// if passability is unspecified, default to all passable
|
||||
if (passable == null) {
|
||||
passable = new int[numtiles];
|
||||
for (int ii = 0; ii < numtiles; ii++) {
|
||||
passable[ii] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// construct a tileset object using all gathered data
|
||||
return new TileSet(
|
||||
name, tsid, imgfile, rowwidth, rowheight, tilecount,
|
||||
passable, offsetpos, gapdist);
|
||||
}
|
||||
}
|
||||
/** The tile set data model populated while parsing. */
|
||||
protected TileSet.TileSetModel _model;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.37 2001/09/28 01:46:10 mdb Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.38 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -10,12 +10,12 @@ import java.util.List;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
import com.threerings.whirled.data.Scene;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.ClusterUtil;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* A scene object represents the data model corresponding to a single
|
||||
@@ -47,8 +47,8 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
_clusters = new ArrayList();
|
||||
_portals = new ArrayList();
|
||||
|
||||
_tiles = new Tile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_deftile = _tilemgr.getTile(deftsid, deftid);
|
||||
_tiles = new MisoTile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_deftile = (MisoTile)_tilemgr.getTile(deftsid, deftid);
|
||||
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||
for (int ii = 0; ii < NUM_LAYERS; ii++) {
|
||||
@@ -73,7 +73,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
public MisoSceneImpl (IsoSceneViewModel model, TileManager tilemgr,
|
||||
String name, ArrayList locations,
|
||||
ArrayList clusters, ArrayList portals,
|
||||
Tile[][][] tiles)
|
||||
MisoTile[][][] tiles)
|
||||
{
|
||||
_model = model;
|
||||
_tilemgr = tilemgr;
|
||||
@@ -110,13 +110,13 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Tile[][][] getTiles ()
|
||||
public MisoTile[][][] getTiles ()
|
||||
{
|
||||
return _tiles;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Tile getDefaultTile ()
|
||||
public MisoTile getDefaultTile ()
|
||||
{
|
||||
return _deftile;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
protected int _version;
|
||||
|
||||
/** The tiles comprising the scene. */
|
||||
public Tile[][][] _tiles;
|
||||
public MisoTile[][][] _tiles;
|
||||
|
||||
/** The default entrance portal. */
|
||||
protected Portal _entrance;
|
||||
@@ -276,7 +276,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
protected ArrayList _portals;
|
||||
|
||||
/** The default tile for the base layer in the scene. */
|
||||
protected Tile _deftile;
|
||||
protected MisoTile _deftile;
|
||||
|
||||
/** The iso scene view data model. */
|
||||
protected IsoSceneViewModel _model;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// $Id: MisoScene.java,v 1.3 2001/10/05 23:58:36 mdb Exp $
|
||||
// $Id: MisoScene.java,v 1.4 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* A scene object represents the data model corresponding to a single
|
||||
@@ -42,12 +42,12 @@ public interface MisoScene
|
||||
/**
|
||||
* Return the tiles that comprise this scene.
|
||||
*/
|
||||
public Tile[][][] getTiles ();
|
||||
public MisoTile[][][] getTiles ();
|
||||
|
||||
/**
|
||||
* Return the default tile for the base layer of the scene.
|
||||
*/
|
||||
public Tile getDefaultTile ();
|
||||
public MisoTile getDefaultTile ();
|
||||
|
||||
/**
|
||||
* Return the locations in this scene. The locations list should
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// $Id: Traverser.java,v 1.2 2001/08/16 23:14:21 mdb Exp $
|
||||
// $Id: Traverser.java,v 1.3 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* The <code>Traverser</code> interface should be implemented by
|
||||
@@ -21,5 +21,5 @@ public interface Traverser
|
||||
*
|
||||
* @return whether the tile is traversable.
|
||||
*/
|
||||
public boolean canTraverse (Tile tile);
|
||||
public boolean canTraverse (MisoTile tile);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//
|
||||
// $Id: AStarPathUtil.java,v 1.4 2001/08/23 00:55:30 shaper Exp $
|
||||
// $Id: AStarPathUtil.java,v 1.5 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.*;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.util.MathUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.Traverser;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* The <code>AStarPathUtil</code> class provides a facility for
|
||||
@@ -43,7 +43,7 @@ public class AStarPathUtil
|
||||
* @return the list of points in the path.
|
||||
*/
|
||||
public static List getPath (
|
||||
Tile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
MisoTile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
int ax, int ay, int bx, int by)
|
||||
{
|
||||
AStarInfo info = new AStarInfo(tiles, tilewid, tilehei, trav, bx, by);
|
||||
@@ -198,7 +198,7 @@ public class AStarPathUtil
|
||||
class AStarInfo
|
||||
{
|
||||
/** The array of tiles being traversed. */
|
||||
public Tile tiles[][][];
|
||||
public MisoTile tiles[][][];
|
||||
|
||||
/** The tile array dimensions. */
|
||||
public int tilewid, tilehei;
|
||||
@@ -219,7 +219,7 @@ class AStarInfo
|
||||
public int destx, desty;
|
||||
|
||||
public AStarInfo (
|
||||
Tile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
MisoTile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
int destx, int desty)
|
||||
{
|
||||
// save off references
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// $Id: BaseTile.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
/**
|
||||
* The miso tile class extends the base tile class to add support for
|
||||
* tile passability.
|
||||
*
|
||||
* @see MisoTileSet
|
||||
*/
|
||||
public class MisoTile extends Tile
|
||||
{
|
||||
/** Whether the tile is passable. */
|
||||
public boolean passable;
|
||||
|
||||
public MisoTile (int tsid, int tid)
|
||||
{
|
||||
super(tsid, tid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// $Id: BaseTileSet.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.threerings.media.tile.*;
|
||||
|
||||
/**
|
||||
* The miso tile set class extends the base tile set class to add
|
||||
* support for tile passability. Passability is used to determine
|
||||
* whether {@link com.threerings.miso.scene.Traverser} objects can
|
||||
* traverse a particular tile in a {@link
|
||||
* com.threerings.miso.scene.MisoScene}.
|
||||
*/
|
||||
public class MisoTileSet extends TileSet
|
||||
{
|
||||
public MisoTileSet ()
|
||||
{
|
||||
_model = new MisoTileSetModel();
|
||||
}
|
||||
|
||||
public Tile createTile (int tid)
|
||||
{
|
||||
MisoTile tile = new MisoTile(_model.tsid, tid);
|
||||
|
||||
// set the tile's passability, defaulting to passable if this
|
||||
// tileset has no passability specified
|
||||
int passable[] = ((MisoTileSetModel)_model).passable;
|
||||
tile.passable = (passable == null || (passable[tid] == 1));
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
protected static class MisoTileSetModel extends TileSetModel
|
||||
{
|
||||
/** Whether each tile is passable. */
|
||||
public int passable[];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: EditableTileSetManager.java,v 1.10 2001/08/29 18:41:46 shaper Exp $
|
||||
// $Id: EditableTileSetManager.java,v 1.11 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class EditableTileSetManager extends TileSetManagerImpl
|
||||
String fname = config.getValue(TILESETS_KEY, (String)null);
|
||||
ArrayList tilesets = null;
|
||||
try {
|
||||
tilesets = new XMLTileSetParser().loadTileSets(fname);
|
||||
tilesets = new XMLMisoTileSetParser().loadTileSets(fname);
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Exception loading tileset [fname=" + fname +
|
||||
", ioe=" + ioe + "].");
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// $Id: XMLMisoTileSetParser.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.*;
|
||||
|
||||
/**
|
||||
* Extends the base XML tile set parser to construct {@link
|
||||
* MisoTileSet} tilesets that provide additional functionality
|
||||
* specific to the miso layer.
|
||||
*/
|
||||
public class XMLMisoTileSetParser extends XMLTileSetParser
|
||||
{
|
||||
protected void finishElement (String qName, String str)
|
||||
{
|
||||
super.finishElement(qName, str);
|
||||
|
||||
if (qName.equals("passable")) {
|
||||
((MisoTileSet.MisoTileSetModel)_model).passable =
|
||||
StringUtil.parseIntArray(str);
|
||||
}
|
||||
}
|
||||
|
||||
protected TileSet createTileSet ()
|
||||
{
|
||||
return new MisoTileSet();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLSceneParser.java,v 1.16 2001/09/21 02:30:35 mdb Exp $
|
||||
// $Id: XMLSceneParser.java,v 1.17 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.xml;
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.threerings.media.tile.*;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.*;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* Parse an XML scene description file and construct a scene object.
|
||||
@@ -103,7 +104,9 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public void characters (char ch[], int start, int length)
|
||||
{
|
||||
// bail if we're not within a meaningful tag
|
||||
if (_tag == null) return;
|
||||
if (_tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_chars.append(ch, start, length);
|
||||
}
|
||||
@@ -131,7 +134,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
|
||||
// create the tile objects in the tile array
|
||||
for (int xx = 0; xx < vals.length; xx += 2) {
|
||||
Tile tile = _tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
MisoTile tile = (MisoTile)_tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
info.tiles[xx / 2][info.rownum][info.lnum] = tile;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +165,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
|
||||
// create the tile objects in the tile array
|
||||
for (int xx = 0; xx < vals.length; xx += 2) {
|
||||
Tile tile = _tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
MisoTile tile = (MisoTile)_tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
int xidx = info.colstart + (xx / 2);
|
||||
info.tiles[xidx][info.rownum][info.lnum] = tile;
|
||||
}
|
||||
@@ -234,7 +237,9 @@ public class XMLSceneParser extends DefaultHandler
|
||||
protected ArrayList toPortalList (ArrayList locs, String[] vals)
|
||||
{
|
||||
// make sure we have an appropriate number of values
|
||||
if ((vals.length % 2) != 0) return null;
|
||||
if ((vals.length % 2) != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// read in all of the portals
|
||||
ArrayList portals = new ArrayList();
|
||||
@@ -342,7 +347,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public ArrayList clusters;
|
||||
|
||||
/** The tile array. */
|
||||
public Tile[][][] tiles;
|
||||
public MisoTile[][][] tiles;
|
||||
|
||||
/** The current layer number being processed. */
|
||||
public int lnum;
|
||||
@@ -359,7 +364,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public SceneInfo ()
|
||||
{
|
||||
int width = _model.scenewid, height = _model.scenehei;
|
||||
tiles = new Tile[width][height][MisoScene.NUM_LAYERS];
|
||||
tiles = new MisoTile[width][height][MisoScene.NUM_LAYERS];
|
||||
clusters = new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.16 2001/10/01 22:18:24 mdb Exp $
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.17 2001/10/08 21:04:26 shaper Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
@@ -80,6 +80,12 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
|
||||
// get the path from here to there
|
||||
Path path = _view.getPath(_sprite, x, y);
|
||||
if (path == null) {
|
||||
_sprite.cancelMove();
|
||||
return;
|
||||
}
|
||||
|
||||
((LineSegmentPath)path).setVelocity(100f/1000f);
|
||||
_sprite.move(path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user