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:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user