Altered scene width/height and positioning to completely fill the

scene view in the editor.  Fixed IsoSceneView.screenToTile() to work
correctly again.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@85 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-20 07:09:56 +00:00
parent b5d45abd2a
commit 274fd01cef
2 changed files with 26 additions and 20 deletions
@@ -1,5 +1,5 @@
// //
// $Id: DisplayMisoSceneImpl.java,v 1.7 2001/07/20 00:35:09 shaper Exp $ // $Id: DisplayMisoSceneImpl.java,v 1.8 2001/07/20 07:09:56 shaper Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -206,8 +206,8 @@ public class Scene
protected static final short VERSION = 1; protected static final short VERSION = 1;
// scene width/height in tiles // scene width/height in tiles
protected static final int TILE_WIDTH = 21; protected static final int TILE_WIDTH = 55;
protected static final int TILE_HEIGHT = 21; protected static final int TILE_HEIGHT = 55;
// layer identifiers and total number of layers // layer identifiers and total number of layers
protected static final int LAYER_BASE = 0; protected static final int LAYER_BASE = 0;
@@ -1,5 +1,5 @@
// //
// $Id: IsoSceneView.java,v 1.11 2001/07/20 03:50:35 shaper Exp $ // $Id: IsoSceneView.java,v 1.12 2001/07/20 07:09:56 shaper Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
@@ -45,11 +45,16 @@ public class IsoSceneView implements SceneView
{ {
Graphics2D gfx = (Graphics2D)g; Graphics2D gfx = (Graphics2D)g;
// gfx.setColor(Color.red); // clip the drawing region to our desired bounds since we
// gfx.fillRect(0, 0, _bounds.width, _bounds.height); // currently draw tiles willy-nilly in undesirable areas.
Shape oldclip = gfx.getClip();
gfx.setClip(0, 0, _bounds.width, _bounds.height);
// draw the full scene into the offscreen image buffer // draw the full scene into the offscreen image buffer
renderScene(gfx); renderScene(gfx);
// restore the original clipping region
gfx.setClip(oldclip);
} }
protected void renderScene (Graphics2D gfx) protected void renderScene (Graphics2D gfx)
@@ -57,7 +62,7 @@ public class IsoSceneView implements SceneView
int mx = 1; int mx = 1;
int my = 0; int my = 0;
int screenY = Tile.HALF_HEIGHT; int screenY = DEF_CENTER_Y;
for (int ii = 0; ii < TILE_RENDER_ROWS; ii++) { for (int ii = 0; ii < TILE_RENDER_ROWS; ii++) {
// determine starting tile coordinates // determine starting tile coordinates
@@ -68,7 +73,7 @@ public class IsoSceneView implements SceneView
int length = (ty - tx) + 1; int length = (ty - tx) + 1;
// determine starting screen x-position // determine starting screen x-position
int screenX = DEF_CENTER_X - ((length - 1) * Tile.HALF_WIDTH); int screenX = DEF_CENTER_X - ((length) * Tile.HALF_WIDTH);
for (int jj = 0; jj < length; jj++) { for (int jj = 0; jj < length; jj++) {
@@ -109,7 +114,7 @@ public class IsoSceneView implements SceneView
if ((++my) > Scene.TILE_HEIGHT - 1) my = Scene.TILE_HEIGHT - 1; if ((++my) > Scene.TILE_HEIGHT - 1) my = Scene.TILE_HEIGHT - 1;
} }
paintMouseLines(gfx); // paintMouseLines(gfx);
} }
protected void paintMouseLines (Graphics2D gfx) protected void paintMouseLines (Graphics2D gfx)
@@ -188,13 +193,13 @@ public class IsoSceneView implements SceneView
float mX, mY; float mX, mY;
int bX, bY; int bX, bY;
// calculate the x-axis line (from tile origin to end of visible axis) // calculate the x-axis line (from tile origin to right end of x-axis)
mX = 0.5f; mX = 0.5f;
_lineX[0].x = DEF_CENTER_X; _lineX[0].x = DEF_CENTER_X;
bX = (int)-(mX * _lineX[0].x); bX = (int)-(mX * _lineX[0].x);
_lineX[0].y = 0; _lineX[0].y = DEF_CENTER_Y;
_lineX[1].x = _bounds.width; _lineX[1].x = _lineX[0].x + (Tile.HALF_WIDTH * Scene.TILE_WIDTH);
_lineX[1].y = (int)((mX * _lineX[1].x) + bX); _lineX[1].y = _lineX[0].y + (int)((mX * _lineX[1].x) + bX);
// calculate line parallel to the y-axis (from mouse pos to x-axis) // calculate line parallel to the y-axis (from mouse pos to x-axis)
_lineY[0].x = x; _lineY[0].x = x;
@@ -203,14 +208,14 @@ public class IsoSceneView implements SceneView
bY = (int)(_lineY[0].y - (mY * _lineY[0].x)); bY = (int)(_lineY[0].y - (mY * _lineY[0].x));
// determine intersection of x- and y-axis lines // determine intersection of x- and y-axis lines
_lineY[1].x = (int)((bY - bX) / (mX - mY)); _lineY[1].x = (int)((bY - (bX + DEF_CENTER_Y)) / (mX - mY));
_lineY[1].y = (int)((mY * _lineY[1].x) + bY); _lineY[1].y = (int)((mY * _lineY[1].x) + bY);
// determine distance of mouse pos along the x axis // determine distance of mouse pos along the x axis
int xdist = (int) int xdist = (int)
MathUtil.distance(_lineX[0].x, _lineX[0].y, MathUtil.distance(_lineX[0].x, _lineX[0].y,
_lineY[1].x, _lineY[1].y); _lineY[1].x, _lineY[1].y);
tpos.x = (int)((xdist - Tile.EDGE_LENGTH) / Tile.EDGE_LENGTH); tpos.x = (int)(xdist / Tile.EDGE_LENGTH);
// determine distance of mouse pos along the y-axis // determine distance of mouse pos along the y-axis
int ydist = (int) int ydist = (int)
@@ -218,9 +223,9 @@ public class IsoSceneView implements SceneView
_lineY[1].x, _lineY[1].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("[mX="+mX+", bX="+bX+", mY="+mY+", bY="+bY+"]");
//Log.info("x-axis=" + MathUtil.lineToString(_lineX[0], _lineX[1])); // Log.info("x-axis=" + MathUtil.lineToString(_lineX[0], _lineX[1]));
//Log.info("y-axis=" + MathUtil.lineToString(_lineY[0], _lineY[1])); // Log.info("y-axis=" + MathUtil.lineToString(_lineY[0], _lineY[1]));
return tpos; return tpos;
} }
@@ -242,8 +247,8 @@ public class IsoSceneView implements SceneView
} }
// default dimensions of the scene view // default dimensions of the scene view
protected static final int DEF_BOUNDS_WIDTH = 600; protected static final int DEF_BOUNDS_WIDTH = 18 * Tile.WIDTH;
protected static final int DEF_BOUNDS_HEIGHT = 600; protected static final int DEF_BOUNDS_HEIGHT = 37 * Tile.HEIGHT;
// total number of tile rows to render the full view // total number of tile rows to render the full view
protected static final int TILE_RENDER_ROWS = protected static final int TILE_RENDER_ROWS =
@@ -251,6 +256,7 @@ public class IsoSceneView implements SceneView
// starting x/y-positions to render the view // starting x/y-positions to render the view
protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2; protected static final int DEF_CENTER_X = DEF_BOUNDS_WIDTH / 2;
protected static final int DEF_CENTER_Y = -(9 * Tile.HEIGHT);
protected Point _lineX[], _lineY[]; protected Point _lineX[], _lineY[];