# StageSceneUtil (vilya 1.3 API)
Date: 2011-04-06

## com.threerings.stage.util
Class StageSceneUtil

    java.lang.Object
      com.threerings.stage.util.StageSceneUtil

    public class StageSceneUtil

extends Object

Provides scene related utility functions.

Field Summary
`static int` `OBJECT_ORIENTATION` Value to pass to `locationForObject(TileManager, ObjectInfo, int)` and `locationForObject(TileManager, int, int, int, int)`for orientation to indicate it should use the object's orientation.

Constructor Summary
`StageSceneUtil()`

Method Summary
`static void` `coordsToLocation(int cx, int cy, Point loc)` Converts Cartesian coordinates back to full coordinates.
`static StageLocation` `findStandingSpot(Rectangle foot, int dist, com.threerings.media.util.AStarPathUtil.TraversalPred pred, Object traverser, Point nearto, int orient)` Locates a spot to stand near the supplied rectangular footprint.
`static List<SceneLocation>` `getClusterLocs(Cluster cluster)` Computes a list of the valid locations in this cluster.
`static com.threerings.miso.data.ObjectInfo[]` `getIntersectedObjects(com.threerings.media.tile.TileManager tmgr, StageSceneModel model, Rectangle rect)` Returns an array of the objects intersected by the supplied tile coordinate rectangle.
`static com.threerings.miso.util.MisoSceneMetrics` `getMetrics()` Returns the scene metrics we use to do our calculations.
`static Rectangle` `getObjectFootprint(com.threerings.media.tile.TileManager tilemgr, int tileId, int ox, int oy)` Returns the footprint, in absolute tile coordinates, for the specified object with origin as specified.
`static boolean` `getObjectFootprint(com.threerings.media.tile.TileManager tilemgr, int tileId, int ox, int oy, Rectangle foot)` Fills in the footprint, in absolute tile coordinates, for the specified object with origin as specified.
`static boolean` `isPassable(com.threerings.media.tile.TileManager tilemgr, int tileId)` Looks up the base tile set for the specified fully qualified tile identifier and returns true if the associated tile is passable.
`static StageLocation` `locationForObject(com.threerings.media.tile.TileManager tilemgr, int tileId, int tx, int ty)` Does the necessary jiggery pokery to figure out where the specified object's associated location is.
`static StageLocation` `locationForObject(com.threerings.media.tile.TileManager tilemgr, int tileId, int tx, int ty, int orient)` Does the necessary jiggery pokery to figure out where the specified object's associated location is.
`static StageLocation` `locationForObject(com.threerings.media.tile.TileManager tilemgr, com.threerings.miso.data.ObjectInfo info)` Does the necessary jiggery pokery to figure out where the specified object's associated location is.
`static StageLocation` `locationForObject(com.threerings.media.tile.TileManager tilemgr, com.threerings.miso.data.ObjectInfo info, int orient)` Does the necessary jiggery pokery to figure out where the specified object's associated location is.
`static void` `locationToCoords(int lx, int ly, Point coords)` Converts full coordinates to Cartesian coordinates.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### OBJECT_ORIENTATION

    public static final int OBJECT_ORIENTATION

  Value to pass to `locationForObject(TileManager, ObjectInfo, int)` and `locationForObject(TileManager, int, int, int, int)`for orientation to indicate it should use the object's orientation.

  See Also:
    Constant Field Values

Constructor Detail

### StageSceneUtil

    public StageSceneUtil()

Method Detail

### getMetrics

    public static com.threerings.miso.util.MisoSceneMetrics getMetrics()

  Returns the scene metrics we use to do our calculations.

### locationForObject

    public static StageLocation locationForObject(com.threerings.media.tile.TileManager tilemgr,
                                                  com.threerings.miso.data.ObjectInfo info)

  Does the necessary jiggery pokery to figure out where the specified object's associated location is.

### locationForObject

    public static StageLocation locationForObject(com.threerings.media.tile.TileManager tilemgr,
                                                  com.threerings.miso.data.ObjectInfo info,
                                                  int orient)

  Does the necessary jiggery pokery to figure out where the specified object's associated location is.

  Parameters:
    `orient` - - the orientation to use in the returned location, or `OBJECT_ORIENTATION` if the object's orientation should be used

### locationForObject

    public static StageLocation locationForObject(com.threerings.media.tile.TileManager tilemgr,
                                                  int tileId,
                                                  int tx,
                                                  int ty)

  Does the necessary jiggery pokery to figure out where the specified object's associated location is.

  Parameters:
    `tilemgr` - a tile manager that can be used to look up the tile information.
    `tileId` - the fully qualified tile id of the object tile.
    `tx` - the object's x tile coordinate.
    `ty` - the object's y tile coordinate.

### locationForObject

    public static StageLocation locationForObject(com.threerings.media.tile.TileManager tilemgr,
                                                  int tileId,
                                                  int tx,
                                                  int ty,
                                                  int orient)

  Does the necessary jiggery pokery to figure out where the specified object's associated location is.

  Parameters:
    `tilemgr` - a tile manager that can be used to look up the tile information.
    `tileId` - the fully qualified tile id of the object tile.
    `tx` - the object's x tile coordinate.
    `ty` - the object's y tile coordinate.
    `orient` - - the orientation to use in the returned location, or `OBJECT_ORIENTATION` if the tile's orientation should be used

### locationToCoords

    public static void locationToCoords(int lx,
                                        int ly,
                                        Point coords)

  Converts full coordinates to Cartesian coordinates.

### coordsToLocation

    public static void coordsToLocation(int cx,
                                        int cy,
                                        Point loc)

  Converts Cartesian coordinates back to full coordinates.

### getObjectFootprint

    public static Rectangle getObjectFootprint(com.threerings.media.tile.TileManager tilemgr,
                                               int tileId,
                                               int ox,
                                               int oy)

  Returns the footprint, in absolute tile coordinates, for the specified object with origin as specified.

### getObjectFootprint

    public static boolean getObjectFootprint(com.threerings.media.tile.TileManager tilemgr,
                                             int tileId,
                                             int ox,
                                             int oy,
                                             Rectangle foot)

  Fills in the footprint, in absolute tile coordinates, for the specified object with origin as specified.

  Returns:
    true if the object was successfully looked up and the footprint filled in, false if an error occurred trying to look up the associated object tile.

### isPassable

    public static boolean isPassable(com.threerings.media.tile.TileManager tilemgr,
                                     int tileId)

  Looks up the base tile set for the specified fully qualified tile identifier and returns true if the associated tile is passable.

### getClusterLocs

    public static List<SceneLocation> getClusterLocs(Cluster cluster)

  Computes a list of the valid locations in this cluster.

### findStandingSpot

    public static StageLocation findStandingSpot(Rectangle foot,
                                                 int dist,
                                                 com.threerings.media.util.AStarPathUtil.TraversalPred pred,
                                                 Object traverser,
                                                 Point nearto,
                                                 int orient)

  Locates a spot to stand near the supplied rectangular footprint. First a spot will be sought in a tile immediately next to the footprint, then one tile removed, then two, up to the maximum distance specified by `dist`.

  Parameters:
    `foot` - the tile coordinate footprint around which we are attempting to stand.
    `dist` - the maximum number of tiles away from the footprint to search before giving up.
    `pred` - a predicate that will be used to determine whether a particular spot can be stood upon (we're hijacking the meaning of "traverse" in this case, but the interface is otherwise so nice).
    `traverser` - the object that will be passed to the traversal predicate.
    `nearto` - a point (in tile coordinates) which will be used to select from among the valid standing spots, the one nearest to the supplied point will be returned.
    `orient` - if not `DirectionCodes.NONE` this orientation will be used to override the "natural" orientation of the spot which is facing toward the footprint.
  Returns:
    the closest spot to the

### getIntersectedObjects

    public static com.threerings.miso.data.ObjectInfo[] getIntersectedObjects(com.threerings.media.tile.TileManager tmgr,
                                                                              StageSceneModel model,
                                                                              Rectangle rect)

  Returns an array of the objects intersected by the supplied tile coordinate rectangle.

Copyright © 2011. All Rights Reserved.