From db91329aff56d56ca97649cc1076264d5bde3d12 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Fri, 20 Jul 2001 08:17:10 +0000 Subject: [PATCH] Moved tile edge length into IsoSceneView since it's specific to rendering the tiles from an isometric perspective. Added comments and minor clean-up. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@88 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/media/tile/Tile.java | 20 +++-------- .../com/threerings/media/tile/TileSet.java | 33 ++++++++++++------- .../threerings/miso/client/IsoSceneView.java | 11 +++++-- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/java/com/threerings/media/tile/Tile.java b/src/java/com/threerings/media/tile/Tile.java index 55e400045..5672705de 100644 --- a/src/java/com/threerings/media/tile/Tile.java +++ b/src/java/com/threerings/media/tile/Tile.java @@ -1,5 +1,5 @@ // -// $Id: Tile.java,v 1.5 2001/07/18 22:45:35 shaper Exp $ +// $Id: Tile.java,v 1.6 2001/07/20 08:17:10 shaper Exp $ package com.threerings.miso.tile; @@ -24,21 +24,6 @@ public class Tile public static final int HALF_HEIGHT = HEIGHT / 2; public static final int HALF_WIDTH = WIDTH / 2; - public static final float EDGE_LENGTH = (float) - Math.sqrt((HALF_WIDTH * HALF_WIDTH) + (HALF_HEIGHT * HALF_HEIGHT)); - - /** - * Construct a new tile with the specified identifiers. Intended - * only for use by the TileManager. Do not use this method. - * - * @see com.threerings.miso.TileManager#getTile - */ - public Tile (short tsid, short tid) - { - this.tsid = tsid; - this.tid = tid; - } - /** * Construct a new tile with the specified identifiers. Intended * only for use by the TileManager. Do not use this method. @@ -51,6 +36,9 @@ public class Tile this.tid = (short) tid; } + /** + * Return a string representation of the tile information. + */ public String toString () { StringBuffer buf = new StringBuffer(); diff --git a/src/java/com/threerings/media/tile/TileSet.java b/src/java/com/threerings/media/tile/TileSet.java index 9a0c1de24..615181d7b 100644 --- a/src/java/com/threerings/media/tile/TileSet.java +++ b/src/java/com/threerings/media/tile/TileSet.java @@ -1,5 +1,5 @@ // -// $Id: TileSet.java,v 1.8 2001/07/18 22:45:35 shaper Exp $ +// $Id: TileSet.java,v 1.9 2001/07/20 08:17:10 shaper Exp $ package com.threerings.miso.tile; @@ -15,20 +15,22 @@ import java.awt.image.*; * provides a clean interface for the TileManager to retrieve * individual tile images from a particular tile in the tileset. * - * The width of each tile in every tileset is a constant Tile.WIDTH in - * pixels. The tile count in each row can vary. The height of the - * tiles in each row can also vary. This information is obtained from - * the config object. + *

The width of each tile in every tileset is a constant + * Tile.WIDTH in pixels. The tile count in each row can vary. The + * height of the tiles in each row can also vary. This information is + * obtained from the config object. * - * Tiles are retrieved from the tile set by the TileManager, and are - * referenced by their tile id (essentially the tile number, assuming - * the tile at the top-left of the image is tile id 0 and tiles are - * numbered left to right, top to bottom, in ascending order. - * - * @see com.threerings.miso.TileManager + *

Tiles are retrieved from the tile set by the TileManager, and + * are referenced by their tile id (essentially the tile number, + * assuming the tile at the top-left of the image is tile id 0 and + * tiles are numbered left to right, top to bottom, in ascending + * order. */ public class TileSet { + /** + * Construct a new TileSet object with the given parameters. + */ public TileSet (String name, int tsid, String imgFile, int[] rowHeight, int[] tileCount) { @@ -43,16 +45,25 @@ public class TileSet _numTiles += _tileCount[ii]; } + /** + * Return the tileset identifier. + */ public int getId () { return _tsid; } + /** + * Return the tileset name. + */ public String getName () { return _name; } + /** + * Return the number of tiles in the tileset. + */ public int getNumTiles () { return _numTiles; diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index 6b35441cf..65361ae60 100644 --- a/src/java/com/threerings/miso/client/IsoSceneView.java +++ b/src/java/com/threerings/miso/client/IsoSceneView.java @@ -1,5 +1,5 @@ // -// $Id: IsoSceneView.java,v 1.12 2001/07/20 07:09:56 shaper Exp $ +// $Id: IsoSceneView.java,v 1.13 2001/07/20 08:17:10 shaper Exp $ package com.threerings.miso.scene; @@ -215,13 +215,13 @@ public class IsoSceneView implements SceneView int xdist = (int) MathUtil.distance(_lineX[0].x, _lineX[0].y, _lineY[1].x, _lineY[1].y); - tpos.x = (int)(xdist / Tile.EDGE_LENGTH); + tpos.x = (int)(xdist / TILE_EDGE_LENGTH); // determine distance of mouse pos along the y-axis int ydist = (int) MathUtil.distance(_lineY[0].x, _lineY[0].y, _lineY[1].x, _lineY[1].y); - tpos.y = (int)(ydist / Tile.EDGE_LENGTH); + tpos.y = (int)(ydist / TILE_EDGE_LENGTH); // Log.info("[mX="+mX+", bX="+bX+", mY="+mY+", bY="+bY+"]"); // Log.info("x-axis=" + MathUtil.lineToString(_lineX[0], _lineX[1])); @@ -258,6 +258,11 @@ public class IsoSceneView implements SceneView protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2; protected static final int DEF_CENTER_Y = -(9 * Tile.HEIGHT); + // length of a tile edge as rendered from an isometric perspective + public static final float TILE_EDGE_LENGTH = (float) + Math.sqrt((Tile.HALF_WIDTH * Tile.HALF_WIDTH) + + (Tile.HALF_HEIGHT * Tile.HALF_HEIGHT)); + protected Point _lineX[], _lineY[]; protected Rectangle _bounds;