Added support for specifying a default tileset for scenes.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2439 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: MisoScenePanel.java,v 1.9 2003/04/19 22:40:34 mdb Exp $
|
// $Id: MisoScenePanel.java,v 1.10 2003/04/21 17:08:56 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -678,7 +678,8 @@ public class MisoScenePanel extends VirtualMediaPanel
|
|||||||
// recompute our object tips
|
// recompute our object tips
|
||||||
computeTips();
|
computeTips();
|
||||||
|
|
||||||
// Log.info("Computed " + _vizobjs.size() + " visible objects.");
|
// Log.info("Computed " + _vizobjs.size() + " visible objects from " +
|
||||||
|
// _blocks.size() + " blocks.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SceneBlock.java,v 1.4 2003/04/19 02:01:08 mdb Exp $
|
// $Id: SceneBlock.java,v 1.5 2003/04/21 17:08:56 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -77,6 +77,17 @@ public class SceneBlock
|
|||||||
for (int ii = 0; ii < _objects.length; ii++) {
|
for (int ii = 0; ii < _objects.length; ii++) {
|
||||||
_objects[ii] = new SceneObject(panel, set.get(ii));
|
_objects[ii] = new SceneObject(panel, set.get(ii));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolve our default tileset
|
||||||
|
int bsetid = model.getDefaultBaseTileSet();
|
||||||
|
try {
|
||||||
|
if (bsetid > 0) {
|
||||||
|
_defset = _panel.getTileManager().getTileSet(bsetid);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.warning("Unable to fetch default base tileset [tsid=" + bsetid +
|
||||||
|
", error=" + e + "].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +121,14 @@ public class SceneBlock
|
|||||||
*/
|
*/
|
||||||
public BaseTile getBaseTile (int tx, int ty)
|
public BaseTile getBaseTile (int tx, int ty)
|
||||||
{
|
{
|
||||||
return _base[index(tx, ty)];
|
BaseTile tile = _base[index(tx, ty)];
|
||||||
|
if (tile == null && _defset != null) {
|
||||||
|
long seed = ((tx^ty) ^ multiplier) & mask;
|
||||||
|
long hash = (seed * multiplier + addend) & mask;
|
||||||
|
int tidx = (int)((hash >> 10) % _defset.getTileCount());
|
||||||
|
tile = (BaseTile)_defset.getTile(tidx);
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -326,6 +344,9 @@ public class SceneBlock
|
|||||||
/** A polygon bounding the footprint of this block. */
|
/** A polygon bounding the footprint of this block. */
|
||||||
protected Polygon _footprint;
|
protected Polygon _footprint;
|
||||||
|
|
||||||
|
/** Used to return a tile where we have none. */
|
||||||
|
protected TileSet _defset;
|
||||||
|
|
||||||
/** Our base tiles. */
|
/** Our base tiles. */
|
||||||
protected BaseTile[] _base;
|
protected BaseTile[] _base;
|
||||||
|
|
||||||
@@ -344,4 +365,9 @@ public class SceneBlock
|
|||||||
// used to link up to our neighbors
|
// used to link up to our neighbors
|
||||||
protected static final int[] DX = { -1, -1, 0, 1, 1, 1, 0, -1 };
|
protected static final int[] DX = { -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||||
protected static final int[] DY = { 0, -1, -1, -1, 0, 1, 1, 1 };
|
protected static final int[] DY = { 0, -1, -1, -1, 0, 1, 1, 1 };
|
||||||
|
|
||||||
|
// for mapping tile coordinates to a pseudo-random tile
|
||||||
|
protected final static long multiplier = 0x5DEECE66DL;
|
||||||
|
protected final static long addend = 0xBL;
|
||||||
|
protected final static long mask = (1L << 48) - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: MisoSceneModel.java,v 1.16 2003/04/19 22:40:34 mdb Exp $
|
// $Id: MisoSceneModel.java,v 1.17 2003/04/21 17:08:57 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.data;
|
package com.threerings.miso.data;
|
||||||
|
|
||||||
@@ -52,6 +52,15 @@ public abstract class MisoSceneModel extends SimpleStreamableObject
|
|||||||
*/
|
*/
|
||||||
public abstract boolean setBaseTile (int fqTileId, int x, int y);
|
public abstract boolean setBaseTile (int fqTileId, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scene models can return a default tileset to be used when no base
|
||||||
|
* tile data exists for a particular tile.
|
||||||
|
*/
|
||||||
|
public int getDefaultBaseTileSet ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates the supplied object set with info on all objects whose
|
* Populates the supplied object set with info on all objects whose
|
||||||
* origin falls in the requested region.
|
* origin falls in the requested region.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SparseMisoSceneModel.java,v 1.3 2003/04/20 00:05:14 mdb Exp $
|
// $Id: SparseMisoSceneModel.java,v 1.4 2003/04/21 17:08:57 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.data;
|
package com.threerings.miso.data;
|
||||||
|
|
||||||
@@ -173,6 +173,9 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
/** The dimensions of a section of our scene. */
|
/** The dimensions of a section of our scene. */
|
||||||
public short swidth, sheight;
|
public short swidth, sheight;
|
||||||
|
|
||||||
|
/** The tileset to use when we have no tile data. */
|
||||||
|
public int defTileSet = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a scene model with the specified bounds.
|
* Creates a scene model with the specified bounds.
|
||||||
*
|
*
|
||||||
@@ -238,6 +241,12 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public int getDefaultBaseTileSet ()
|
||||||
|
{
|
||||||
|
return defTileSet;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void getObjects (Rectangle region, ObjectSet set)
|
public void getObjects (Rectangle region, ObjectSet set)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SparseMisoSceneRuleSet.java,v 1.1 2003/04/19 22:40:34 mdb Exp $
|
// $Id: SparseMisoSceneRuleSet.java,v 1.2 2003/04/21 17:08:57 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tools.xml;
|
package com.threerings.miso.tools.xml;
|
||||||
|
|
||||||
@@ -47,6 +47,8 @@ public class SparseMisoSceneRuleSet implements NestableRuleSet
|
|||||||
// set up rules to parse and set our fields
|
// set up rules to parse and set our fields
|
||||||
dig.addRule(prefix + "/swidth", new SetFieldRule(dig, "swidth"));
|
dig.addRule(prefix + "/swidth", new SetFieldRule(dig, "swidth"));
|
||||||
dig.addRule(prefix + "/sheight", new SetFieldRule(dig, "sheight"));
|
dig.addRule(prefix + "/sheight", new SetFieldRule(dig, "sheight"));
|
||||||
|
dig.addRule(prefix + "/defTileSet",
|
||||||
|
new SetFieldRule(dig, "defTileSet"));
|
||||||
|
|
||||||
String sprefix = prefix + "/sections/section";
|
String sprefix = prefix + "/sections/section";
|
||||||
dig.addObjectCreate(sprefix, Section.class.getName());
|
dig.addObjectCreate(sprefix, Section.class.getName());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SparseMisoSceneWriter.java,v 1.1 2003/04/19 22:40:34 mdb Exp $
|
// $Id: SparseMisoSceneWriter.java,v 1.2 2003/04/21 17:08:57 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tools.xml;
|
package com.threerings.miso.tools.xml;
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ public class SparseMisoSceneWriter implements NestableWriter
|
|||||||
{
|
{
|
||||||
writer.dataElement("swidth", Integer.toString(model.swidth));
|
writer.dataElement("swidth", Integer.toString(model.swidth));
|
||||||
writer.dataElement("sheight", Integer.toString(model.sheight));
|
writer.dataElement("sheight", Integer.toString(model.sheight));
|
||||||
|
writer.dataElement("defTileSet", Integer.toString(model.defTileSet));
|
||||||
|
|
||||||
writer.startElement("sections");
|
writer.startElement("sections");
|
||||||
for (Iterator iter = model.getSections(); iter.hasNext(); ) {
|
for (Iterator iter = model.getSections(); iter.hasNext(); ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user