diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java index 98f983b85..e55e28c24 100644 --- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java +++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java @@ -1,5 +1,5 @@ // -// $Id: DisplayMisoSceneImpl.java,v 1.46 2001/11/29 19:30:51 mdb Exp $ +// $Id: DisplayMisoSceneImpl.java,v 1.47 2001/11/29 23:08:27 mdb Exp $ package com.threerings.miso.scene; @@ -48,7 +48,7 @@ public class DisplayMisoSceneImpl for (int column = 0; column < shei; column++) { for (int row = 0; row < swid; row++) { // first do the base layer - int tsid = model.baseTileIds[swid*column+row]; + int tsid = model.baseTileIds[swid*row+column]; if (tsid > 0) { int tid = (tsid & 0xFFFF); tsid >>= 16; @@ -63,7 +63,7 @@ public class DisplayMisoSceneImpl } // then the fringe layer - tsid = model.fringeTileIds[swid*column+row]; + tsid = model.fringeTileIds[swid*row+column]; if (tsid > 0) { int tid = (tsid & 0xFFFF); tsid >>= 16; @@ -82,8 +82,8 @@ public class DisplayMisoSceneImpl // now populate the object layer for (int i = 0; i < ocount; i+= 3) { - int row = model.objectTileIds[i]; - int col = model.objectTileIds[i+1]; + int col = model.objectTileIds[i]; + int row = model.objectTileIds[i+1]; int tsid = model.objectTileIds[i+2]; int tid = (tsid & 0xFFFF); tsid >>= 16; @@ -96,7 +96,7 @@ public class DisplayMisoSceneImpl // we have to generate a shadow for this object tile in the // base layer so that we can prevent sprites from walking on // the object - generateObjectShadow(row, col); + setObjectTileFootprint(otile, col, row, new ShadowTile(col, row)); } } @@ -129,38 +129,29 @@ public class DisplayMisoSceneImpl return buf.append("]").toString(); } - /** - * Place shadow tiles in the footprint of the object tile at the given - * coordinates in the scene. This method should be called when an - * object tile is added to the scene. - * - * @param x the tile x-coordinate. - * @param y the tile y-coordinate. - */ - protected void generateObjectShadow (int x, int y) - { - setObjectTileFootprint(x, y, new ShadowTile(x, y)); - } - /** * Place the given tile in the footprint of the object tile at the * given coordinates in the scene. * + * @param otile the object tile whose footprint should be set. * @param x the tile x-coordinate. * @param y the tile y-coordinate. * @param stamp the tile to place in the object footprint. */ - protected void setObjectTileFootprint (int x, int y, BaseTile stamp) + protected void setObjectTileFootprint ( + ObjectTile otile, int x, int y, BaseTile stamp) { - ObjectTile tile = _object.getTile(y, x); - int endx = Math.max(0, (x - tile.getBaseWidth() + 1)); - int endy = Math.max(0, (y - tile.getBaseHeight() + 1)); + int endx = Math.max(0, (x - otile.getBaseWidth() + 1)); + int endy = Math.max(0, (y - otile.getBaseHeight() + 1)); for (int xx = x; xx >= endx; xx--) { for (int yy = y; yy >= endy; yy--) { - _base.setTile(yy, xx, stamp); + _base.setTile(xx, yy, stamp); } } + + // Log.info("Set object tile footprint [tile=" + otile + ", sx=" + x + + // ", sy=" + y + ", ex=" + endx + ", ey=" + endy + "]."); } /** The base layer of tiles. */ diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index 761e37bb6..7d2c0ba17 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.73 2001/11/27 22:17:42 mdb Exp $ +// $Id: IsoSceneView.java,v 1.74 2001/11/29 23:08:27 mdb Exp $ package com.threerings.miso.scene; @@ -229,10 +229,10 @@ public class IsoSceneView implements SceneView // draw the base and fringe tile images Tile tile; - if ((tile = base.getTile(yy, xx)) != null) { + if ((tile = base.getTile(xx, yy)) != null) { tile.paint(gfx, _polys[xx][yy]); } - if ((tile = fringe.getTile(yy, xx)) != null) { + if ((tile = fringe.getTile(xx, yy)) != null) { tile.paint(gfx, _polys[xx][yy]); } } @@ -271,7 +271,7 @@ public class IsoSceneView implements SceneView ObjectTileLayer tiles = _scene.getObjectLayer(); for (int yy = 0; yy < tiles.getHeight(); yy++) { for (int xx = 0; xx < tiles.getWidth(); xx++) { - ObjectTile tile = tiles.getTile(yy, xx); + ObjectTile tile = tiles.getTile(xx, yy); if (tile != null) { generateObjectBounds(tile, xx, yy); } @@ -575,7 +575,7 @@ public class IsoSceneView implements SceneView Rectangle drect = poly.getBounds().intersection(r); int tx = coord >> 16, ty = coord & 0x0000FFFF; _dirtyItems.appendDirtyObject( - tiles.getTile(ty, tx), poly, tx, ty, drect); + tiles.getTile(tx, ty), poly, tx, ty, drect); // Log.info("Dirtied item: Object(" + tx + ", " + // ty + ")"); } diff --git a/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java b/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java index 257fc8f5b..2b7ceb7b2 100644 --- a/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java +++ b/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java @@ -1,5 +1,5 @@ // -// $Id: EditableMisoSceneImpl.java,v 1.4 2001/11/29 00:18:15 mdb Exp $ +// $Id: EditableMisoSceneImpl.java,v 1.5 2001/11/29 23:08:28 mdb Exp $ package com.threerings.miso.tools.scene; @@ -10,6 +10,7 @@ import com.threerings.media.tile.Tile; import com.threerings.media.tile.TileManager; import com.threerings.miso.tile.BaseTile; +import com.threerings.miso.tile.ShadowTile; import com.threerings.miso.scene.DisplayMisoSceneImpl; import com.threerings.miso.scene.MisoSceneModel; @@ -41,6 +42,15 @@ public class EditableMisoSceneImpl // we need this to track object layer mods _objectTileIds = new int[_model.baseTileIds.length]; + + // populate our non-spare array + int[] otids = model.objectTileIds; + for (int i = 0; i < otids.length; i += 3) { + int x = otids[i]; + int y = otids[i+1]; + int fqTileId = otids[i+2]; + _objectTileIds[model.width*y + x] = fqTileId; + } } // documentation inherited @@ -59,7 +69,7 @@ public class EditableMisoSceneImpl // documentation inherited public void setBaseTile (int x, int y, BaseTile tile, int fqTileId) { - _base.setTile(y, x, tile); + _base.setTile(x, y, tile); // update the model as well _model.baseTileIds[_model.width*y + x] = fqTileId; } @@ -67,7 +77,7 @@ public class EditableMisoSceneImpl // documentation inherited public void setFringeTile (int x, int y, Tile tile, int fqTileId) { - _fringe.setTile(y, x, tile); + _fringe.setTile(x, y, tile); // update the model as well _model.fringeTileIds[_model.width*y + x] = fqTileId; } @@ -81,45 +91,82 @@ public class EditableMisoSceneImpl if (prev != null) { clearObjectTile(x, y); } - _object.setTile(y, x, tile); + _object.setTile(x, y, tile); + // set the footprint in the base layer + setObjectTileFootprint(tile, x, y, new ShadowTile(x, y)); // stick this value into our non-sparse object layer _objectTileIds[_model.width*y + x] = fqTileId; - } - - // documentation inherited - public void clearBaseTile (int x, int y) - { - _base.setTile(y, x, _defaultBaseTile); - // clear it out in the model - _model.baseTileIds[_model.width*y + x] = _defaultBaseTileId; - } - - // documentation inherited - public void clearFringeTile (int x, int y) - { - _fringe.setTile(y, x, null); - // clear it out in the model - _model.fringeTileIds[_model.width*y + x] = 0; - } - - // documentation inherited - public void clearObjectTile (int x, int y) - { - setObjectTileFootprint(x, y, _defaultBaseTile); - // clear it out in our non-sparse array - _objectTileIds[_model.width*y + x] = 0; // we don't have to worry about setting the footprint in the model // because footprints are always inferred from the contents of the // object layer and the base layer in the model can simply contain // the default tiles } + // documentation inherited + public void clearBaseTile (int x, int y) + { + _base.setTile(x, y, _defaultBaseTile); + // clear it out in the model + _model.baseTileIds[_model.width*y + x] = _defaultBaseTileId; + } + + // documentation inherited + public void clearFringeTile (int x, int y) + { + _fringe.setTile(x, y, null); + // clear it out in the model + _model.fringeTileIds[_model.width*y + x] = 0; + } + + // documentation inherited + public void clearObjectTile (int x, int y) + { + ObjectTile tile = _object.getTile(x, y); + if (tile != null) { + // clear the footprint in the base layer + setObjectTileFootprint(tile, x, y, _defaultBaseTile); + // clear out the tile itself + _object.setTile(x, y, null); + } + // clear it out in our non-sparse array + _objectTileIds[_model.width*y + x] = 0; + } + // documentation inherited public MisoSceneModel getMisoSceneModel () { // we need to flush the object layer to the model prior to // returning it + int otileCount = 0; + int cols = _object.getWidth(); + int rows = _object.getHeight(); + // first count how many object tiles we have + for (int i = 0; i < _objectTileIds.length; i++) { + if (_objectTileIds[i] != 0) { + otileCount++; + } + } + + // now create and populate the new tileid array + int[] otids = new int[otileCount*3]; + int otidx = 0; + for (int r = 0; r < rows; r++) { + for (int c = 0; c < cols; c++) { + int tsid = _objectTileIds[_model.width*r + c]; + if (tsid == 0) { + continue; + } + otids[otidx++] = c; + otids[otidx++] = r; + otids[otidx++] = tsid; + } + } + + // stuff the new array into the model + _model.objectTileIds = otids; + + // and we're ready to roll return _model; }