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:
Michael Bayne
2003-01-31 23:10:46 +00:00
parent a11f45dec4
commit e6796b2d55
30 changed files with 1082 additions and 486 deletions
@@ -1,14 +1,12 @@
//
// $Id: MisoSceneModel.java,v 1.10 2002/09/23 23:07:11 mdb Exp $
// $Id: MisoSceneModel.java,v 1.11 2003/01/31 23:10:45 mdb Exp $
package com.threerings.miso.scene;
package com.threerings.miso.data;
import com.samskivert.util.StringUtil;
import java.util.ArrayList;
import com.threerings.io.SimpleStreamableObject;
import com.threerings.miso.Log;
/**
* The scene model is the bare bones representation of the data for a
* scene in the Miso system. From the scene model, one would create an
@@ -29,24 +27,26 @@ public class MisoSceneModel extends SimpleStreamableObject
/** The viewport height in tiles. */
public int vheight;
/** The combined tile ids (tile set id and tile id)
* in compressed format.
* Don't go poking around in here, use the accessor methods. */
/** The combined tile ids (tile set id and tile id) in compressed
* format. Don't go poking around in here, use the accessor
* methods. */
public int[] baseTileIds;
/** The combined tile ids (tile set id and tile id) of the files in
* the object layer in (x, y, tile id) format. */
/** The combined tile ids (tile set id and tile id) of the
* "uninteresting" tiles in the object layer. */
public int[] objectTileIds;
/** The action strings associated with the object tiles in the order
* that the tiles are specified in the {@link #objectTileIds} array.
* Elements of this array may be null but will be converted to the
* empty string during serialization. */
public String[] objectActions;
/** The x coordinate of the "uninteresting" tiles in the object
* layer. */
public short[] objectXs;
/** Render priorities for each object tile in the scene, which are
* used to resolve overlapped object render order conflicts. */
public byte[] objectPrios;
/** The y coordinate of the "uninteresting" tiles in the object
* layer. */
public short[] objectYs;
/** Information records for the "interesting" objects in the object
* layer. */
public ObjectInfo[] objectInfo;
/**
* Get the fully-qualified tile id of the base tile at the specified
@@ -140,11 +140,37 @@ public class MisoSceneModel extends SimpleStreamableObject
MisoSceneModel model = (MisoSceneModel)super.clone();
model.baseTileIds = (int[])baseTileIds.clone();
model.objectTileIds = (int[])objectTileIds.clone();
model.objectActions = (String[])objectActions.clone();
model.objectPrios = (byte[])objectPrios.clone();
model.objectXs = (short[])objectXs.clone();
model.objectYs = (short[])objectYs.clone();
model.objectInfo = (ObjectInfo[])objectInfo.clone();
return model;
}
/**
* Populates the interesting and uninteresting parts of a miso scene
* model given lists of {@link ObjectInfo} records for each.
*/
public static void populateObjects (MisoSceneModel model,
ArrayList ilist, ArrayList ulist)
{
// set up the uninteresting arrays
int ucount = ulist.size();
model.objectTileIds = new int[ucount];
model.objectXs = new short[ucount];
model.objectYs = new short[ucount];
for (int ii = 0; ii < ucount; ii++) {
ObjectInfo info = (ObjectInfo)ulist.get(ii);
model.objectTileIds[ii] = info.tileId;
model.objectXs[ii] = (short)info.x;
model.objectYs[ii] = (short)info.y;
}
// set up the interesting array
int icount = ilist.size();
model.objectInfo = new ObjectInfo[icount];
ilist.toArray(model.objectInfo);
}
/**
* Creates and returns a blank scene model (with zero width and
* height).
@@ -180,7 +206,8 @@ public class MisoSceneModel extends SimpleStreamableObject
model.vheight = vheight;
model.allocateBaseTileArray();
model.objectTileIds = new int[0];
model.objectActions = new String[0];
model.objectPrios = new byte[0];
model.objectXs = new short[0];
model.objectYs = new short[0];
model.objectInfo = new ObjectInfo[0];
}
}
@@ -0,0 +1,120 @@
//
// $Id: ObjectInfo.java,v 1.1 2003/01/31 23:10:45 mdb Exp $
package com.threerings.miso.data;
import com.samskivert.util.StringUtil;
import com.threerings.io.SimpleStreamableObject;
/**
* Contains information about an object in a Miso scene.
*/
public class ObjectInfo extends SimpleStreamableObject
{
/** The fully qualified object tile id. */
public int tileId;
/** The x and y tile coordinates of the object. */
public int x, y;
/** 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;
/** A "spot" associated with this object (specified as an offset from
* the fine coordinates of the object's origin tile). */
public byte sx, sy;
/** The orientation of the "spot" associated with this object. */
public byte sorient;
/** Up to two colorization assignments for this object. */
public int zations;
/**
* Convenience constructor.
*/
public ObjectInfo (int tileId, int x, int y)
{
this.tileId = tileId;
this.x = x;
this.y = y;
}
/**
* Creates an object info that is a copy of the supplied info.
*/
public ObjectInfo (ObjectInfo other)
{
this.tileId = other.tileId;
this.x = other.x;
this.y = other.y;
this.priority = other.priority;
this.action = other.action;
this.sx = other.sx;
this.sy = other.sy;
this.sorient = other.sorient;
this.zations = zations;
}
/**
* Zero argument constructor needed for unserialization.
*/
public ObjectInfo ()
{
}
/**
* Returns the primary colorization assignment.
*/
public int getPrimaryZation ()
{
return (zations & 0xFFFF);
}
/**
* Returns the secondary colorization assignment.
*/
public int getSecondaryZation ()
{
return ((zations >> 16) & 0xFFFF);
}
/**
* Sets the primary and secondary colorization assignments.
*/
public void setZations (short primary, short secondary)
{
zations = ((secondary << 16) | primary);
}
/**
* Returns true if this object info contains non-default data for
* anything other than the tile id and coordinates.
*/
public boolean isInteresting ()
{
return (!StringUtil.blank(action) || priority != 0 ||
sx != 0 || sy != 0 || zations != 0);
}
// documentation inherited
public boolean equals (Object other)
{
if (other instanceof ObjectInfo) {
ObjectInfo ooi = (ObjectInfo)other;
return (x == ooi.x && y == ooi.y && tileId == ooi.tileId);
} else {
return false;
}
}
// documentation inherited
public int hashCode ()
{
return x ^ y ^ tileId;
}
}