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,7 +1,7 @@
//
// $Id: EditableMisoScene.java,v 1.18 2002/09/23 21:54:50 mdb Exp $
// $Id: EditableMisoScene.java,v 1.19 2003/01/31 23:10:45 mdb Exp $
package com.threerings.miso.scene.tools;
package com.threerings.miso.tools;
import java.awt.Rectangle;
@@ -9,9 +9,9 @@ import com.threerings.media.tile.ObjectTile;
import com.threerings.media.tile.Tile;
import com.threerings.media.tile.TileUtil;
import com.threerings.miso.scene.DisplayMisoScene;
import com.threerings.miso.scene.MisoSceneModel;
import com.threerings.miso.scene.SceneObject;
import com.threerings.miso.client.DisplayMisoScene;
import com.threerings.miso.client.DisplayObjectInfo;
import com.threerings.miso.data.MisoSceneModel;
import com.threerings.miso.tile.BaseTile;
import com.threerings.miso.tile.BaseTileSet;
@@ -70,7 +70,7 @@ public interface EditableMisoScene
*
* @return the new scene object instance.
*/
public SceneObject addSceneObject (
public DisplayObjectInfo addObject (
ObjectTile tile, int x, int y, int fqTileId);
/**
@@ -81,7 +81,7 @@ public interface EditableMisoScene
/**
* Removes the specified object from the scene.
*/
public boolean removeSceneObject (SceneObject scobj);
public boolean removeObject (DisplayObjectInfo scobj);
/**
* Returns a reference to the miso scene model that reflects the
@@ -1,11 +1,12 @@
//
// $Id: EditableMisoSceneImpl.java,v 1.24 2002/09/23 23:07:11 mdb Exp $
// $Id: EditableMisoSceneImpl.java,v 1.25 2003/01/31 23:10:45 mdb Exp $
package com.threerings.miso.scene.tools;
package com.threerings.miso.tools;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -21,10 +22,11 @@ import com.threerings.miso.tile.BaseTile;
import com.threerings.miso.tile.BaseTileSet;
import com.threerings.miso.tile.MisoTileManager;
import com.threerings.miso.scene.DisplayMisoSceneImpl;
import com.threerings.miso.scene.MisoSceneModel;
import com.threerings.miso.scene.SceneObject;
import com.threerings.miso.scene.util.IsoUtil;
import com.threerings.miso.client.DisplayMisoSceneImpl;
import com.threerings.miso.client.DisplayObjectInfo;
import com.threerings.miso.client.util.IsoUtil;
import com.threerings.miso.data.MisoSceneModel;
import com.threerings.miso.data.ObjectInfo;
/**
* The default implementation of the {@link EditableMisoScene} interface.
@@ -111,20 +113,22 @@ public class EditableMisoSceneImpl
}
// documentation inherited
public SceneObject addSceneObject (
public DisplayObjectInfo addObject (
ObjectTile tile, int x, int y, int fqTileId)
{
// sanity check
if (x > Short.MAX_VALUE || y > Short.MAX_VALUE ||
x < Short.MIN_VALUE || y < Short.MIN_VALUE) {
throw new IllegalArgumentException(
"Invalid tile coordinates [x=" + x + ", y=" + y + "]");
}
// create a scene object record and add it to the list
EditableSceneObject scobj = (EditableSceneObject)
createSceneObject(x, y, tile);
scobj.fqTileId = fqTileId;
_objects.add(scobj);
DisplayObjectInfo info = new DisplayObjectInfo(fqTileId, x, y);
initObject(info, tile);
_objects.add(info);
// toggle the "covered" flag on in all base tiles below this
// object tile
setObjectTileFootprint(tile, x, y, true);
return scobj;
return info;
}
// documentation inherited
@@ -136,12 +140,12 @@ public class EditableMisoSceneImpl
}
// documentation inherited
public boolean removeSceneObject (SceneObject scobj)
public boolean removeObject (DisplayObjectInfo info)
{
if (_objects.remove(scobj)) {
if (_objects.remove(info)) {
// toggle the "covered" flag off on the base tiles in this object
// tile's footprint
setObjectTileFootprint(scobj.tile, scobj.x, scobj.y, false);
setObjectTileFootprint(info.tile, info.x, info.y, false);
return true;
} else {
return false;
@@ -152,68 +156,26 @@ public class EditableMisoSceneImpl
public MisoSceneModel getMisoSceneModel ()
{
// we need to flush the object layer to the model prior to
// returning it
int ocount = _objects.size();
// but only do it if we've actually got some objects
if (ocount > 0) {
int[] otids = new int[ocount*3];
String[] actions = new String[ocount];
byte[] prios = new byte[ocount];
for (int ii = 0; ii < ocount; ii++) {
EditableSceneObject scobj = (EditableSceneObject)
_objects.get(ii);
otids[3*ii] = scobj.x;
otids[3*ii+1] = scobj.y;
otids[3*ii+2] = scobj.fqTileId;
actions[ii] = scobj.action;
prios[ii] = scobj.priority;
// returning it; first split our objects into two lists
ArrayList ilist = new ArrayList();
ArrayList ulist = new ArrayList();
for (int ii = 0, ll = _objects.size(); ii < ll; ii++) {
ObjectInfo info = (ObjectInfo)_objects.get(ii);
if (info.isInteresting()) {
// convert to a plain object info record
ilist.add(new ObjectInfo(info));
} else {
ulist.add(info);
}
// stuff the new arrays into the model
_model.objectTileIds = otids;
_model.objectActions = actions;
_model.objectPrios = prios;
}
// now populate the scene model appropriately
MisoSceneModel.populateObjects(_model, ilist, ulist);
// and we're ready to roll
return _model;
}
// documentation inherited
protected SceneObject createSceneObject (int x, int y, ObjectTile tile)
{
return new EditableSceneObject(x, y, tile);
}
// documentation inherited
protected SceneObject expandObject (
int col, int row, int tsid, int tid, int fqTid, int objidx)
throws NoSuchTileException, NoSuchTileSetException
{
// do the actual object creation
EditableSceneObject scobj = (EditableSceneObject)
super.expandObject(col, row, tsid, tid, fqTid, objidx);
// we need this to track object layer mods
scobj.fqTileId = fqTid;
// pass on the objecty goodness
return scobj;
}
/** Used to report information on objects in this scene. */
protected static class EditableSceneObject extends SceneObject
{
public int fqTileId;
public EditableSceneObject (int x, int y, ObjectTile tile)
{
super(x, y, tile);
}
}
/** The default tileset with which to fill the base layer. */
protected BaseTileSet _defaultBaseTileSet;
@@ -1,15 +1,16 @@
//
// $Id: MisoSceneParser.java,v 1.2 2002/02/02 01:09:53 mdb Exp $
// $Id: MisoSceneParser.java,v 1.3 2003/01/31 23:10:46 mdb Exp $
package com.threerings.miso.scene.tools.xml;
package com.threerings.miso.tools.xml;
import java.io.IOException;
import java.io.FileInputStream;
import org.xml.sax.SAXException;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSet;
import com.threerings.miso.scene.MisoSceneModel;
import com.threerings.miso.data.MisoSceneModel;
/**
* A simple class for parsing a standalone miso scene model.
@@ -18,17 +19,34 @@ public class MisoSceneParser
{
/**
* Constructs a miso scene parser that parses scenes with the
* specified XML path prefix. See the {@link
* MisoSceneRuleSet#MisoSceneRuleSet} documentation for more
* specified XML path prefix and a standard scene rule set. See the
* {@link MisoSceneRuleSet#MisoSceneRuleSet} documentation for more
* information.
*/
public MisoSceneParser (String prefix)
{
// create and configure our digester
_digester = new Digester();
MisoSceneRuleSet set = new MisoSceneRuleSet();
set.setPrefix(prefix);
_digester.addRuleSet(set);
init(prefix, set);
}
/**
* Constructs a miso scene parser that parses scenes with the
* specified XML path prefix, using the supplied rule set. The rule
* set should leave a {@link MisoSceneModel} at the top of the
* digester's stack.
*/
public MisoSceneParser (String prefix, RuleSet rules)
{
init(prefix, rules);
}
/** Constructor helper function. */
protected void init (String prefix, RuleSet rules)
{
// create and configure our digester
_digester = new Digester();
_digester.addRuleSet(rules);
_digester.addSetNext(prefix, "setSceneModel",
MisoSceneModel.class.getName());
}
@@ -1,16 +1,20 @@
//
// $Id: MisoSceneRuleSet.java,v 1.11 2002/09/23 23:53:33 mdb Exp $
// $Id: MisoSceneRuleSet.java,v 1.12 2003/01/31 23:10:46 mdb Exp $
package com.threerings.miso.scene.tools.xml;
package com.threerings.miso.tools.xml;
import java.util.ArrayList;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSetBase;
import com.samskivert.xml.CallMethodSpecialRule;
import com.samskivert.xml.SetFieldRule;
import com.samskivert.xml.SetPropertyFieldsRule;
import com.threerings.miso.Log;
import com.threerings.miso.scene.MisoSceneModel;
import com.threerings.miso.data.MisoSceneModel;
import com.threerings.miso.data.ObjectInfo;
/**
* Used to parse a {@link MisoSceneModel} from XML.
@@ -58,31 +62,37 @@ public class MisoSceneRuleSet extends RuleSetBase
new SetFieldRule(digester, "vheight"));
digester.addRule(_prefix + "/base",
new SetFieldRule(digester, "baseTileIds"));
digester.addRule(_prefix + "/object",
new SetFieldRule(digester, "objectTileIds"));
digester.addRule(_prefix + "/actions",
new SetFieldRule(digester, "objectActions"));
digester.addRule(_prefix + "/priorities",
new SetFieldRule(digester, "objectPrios"));
// we have to unfuck the objectActions field in the event that
// there's one object in the objects element which has a blank
// action string (which the parser will parse as a zero length
// array, when we want a length one array with a blank string)
digester.addRule(_prefix, new CallMethodSpecialRule(digester) {
digester.addObjectCreate(_prefix + "/objects",
ArrayList.class.getName());
digester.addObjectCreate(_prefix + "/objects/object",
ObjectInfo.class.getName());
digester.addSetNext(_prefix + "/objects/object", "add",
Object.class.getName());
digester.addRule(_prefix + "/objects/object",
new SetPropertyFieldsRule(digester));
digester.addRule(_prefix + "/objects", new CallMethodSpecialRule(
digester) {
public void parseAndSet (String bodyText, Object target)
throws Exception
{
MisoSceneModel model = (MisoSceneModel)target;
if (model.objectTileIds.length > 0 &&
model.objectActions.length == 0) {
model.objectActions = new String[1];
ArrayList ilist = (ArrayList)target;
ArrayList ulist = new ArrayList();
MisoSceneModel model = (MisoSceneModel)this.digester.peek(1);
// filter interesting and uninteresting into two lists
for (int ii = 0; ii < ilist.size(); ii++) {
ObjectInfo info = (ObjectInfo)ilist.get(ii);
if (!info.isInteresting()) {
ilist.remove(ii--);
ulist.add(info);
}
}
// create our object priorities if we don't have 'em
if (model.objectPrios == null) {
model.objectPrios = new byte[model.objectActions.length];
}
// now populate the model
MisoSceneModel.populateObjects(model, ilist, ulist);
}
});
}
@@ -1,13 +1,16 @@
//
// $Id: MisoSceneWriter.java,v 1.8 2002/09/23 23:07:11 mdb Exp $
// $Id: MisoSceneWriter.java,v 1.9 2003/01/31 23:10:46 mdb Exp $
package com.threerings.miso.scene.tools.xml;
package com.threerings.miso.tools.xml;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import com.megginson.sax.DataWriter;
import com.samskivert.util.StringUtil;
import com.threerings.miso.scene.MisoSceneModel;
import com.threerings.miso.data.MisoSceneModel;
import com.threerings.miso.data.ObjectInfo;
/**
* Generates an XML representation of a {@link MisoSceneModel}.
@@ -42,11 +45,53 @@ public class MisoSceneWriter
writer.dataElement("viewheight", Integer.toString(model.vheight));
writer.dataElement("base",
StringUtil.toString(model.baseTileIds, "", ""));
writer.dataElement("object",
StringUtil.toString(model.objectTileIds, "", ""));
writer.dataElement("actions",
StringUtil.joinEscaped(model.objectActions));
writer.dataElement("priorities",
StringUtil.toString(model.objectPrios, "", ""));
// write our uninteresting object tile information
writer.startElement("objects");
for (int ii = 0; ii < model.objectTileIds.length; ii++) {
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "tileId", "", "",
String.valueOf(model.objectTileIds[ii]));
attrs.addAttribute("", "x", "", "",
String.valueOf(model.objectXs[ii]));
attrs.addAttribute("", "y", "", "",
String.valueOf(model.objectYs[ii]));
writer.emptyElement("", "object", "", attrs);
}
// write our uninteresting object tile information
for (int ii = 0; ii < model.objectInfo.length; ii++) {
ObjectInfo info = model.objectInfo[ii];
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "tileId", "", "",
String.valueOf(info.tileId));
attrs.addAttribute("", "x", "", "", String.valueOf(info.x));
attrs.addAttribute("", "y", "", "", String.valueOf(info.y));
if (!StringUtil.blank(info.action)) {
attrs.addAttribute("", "action", "", "", info.action);
}
if (info.priority != 0) {
attrs.addAttribute("", "priority", "", "",
String.valueOf(info.priority));
}
if (info.sx != 0 || info.sy != 0) {
attrs.addAttribute("", "sx", "", "",
String.valueOf(info.sx));
attrs.addAttribute("", "sy", "", "",
String.valueOf(info.sy));
attrs.addAttribute("", "sorient", "", "",
String.valueOf(info.sorient));
}
if (info.zations != 0) {
attrs.addAttribute("", "zations", "", "",
String.valueOf(info.zations));
}
writer.emptyElement("", "object", "", attrs);
}
writer.endElement("objects");
}
}