Package com.threerings.stage.data

Examples of com.threerings.stage.data.StageLocation


     */
    protected SceneLocation computeEnteringLocation (BodyObject body, StageLocation base,
        int minDistance)
    {
        MisoSceneMetrics metrics = StageSceneUtil.getMetrics();
        StageLocation sloc = base.clone();
        int tx = MisoUtil.fullToTile(sloc.x), ty = MisoUtil.fullToTile(sloc.y);
        int oidx = sloc.orient/2;
        int lidx = (oidx+3)%4; // rotate to the left
        int ridx = (oidx+1)%4; // rotate to the right

View Full Code Here


            if (loc == null) {
                log.warning("Foreign body added to cluster [clrec=" + clrec +
                            ", body=" + body.who() + "].");
                cl.x = 10; cl.y = 10;
            } else {
                StageLocation sloc = (StageLocation) loc.loc;
                cl.x = MisoUtil.fullToTile(sloc.x);
                cl.y = MisoUtil.fullToTile(sloc.y);
            }
            // we'll do everything else when occupant two shows up
            return;
View Full Code Here

     * supplied location.
     */
    protected static SceneLocation getClosestLoc (
        List<SceneLocation>locs, SceneLocation optimalLocation)
    {
        StageLocation loc = (StageLocation) optimalLocation.loc;
        SceneLocation cloc = null;
        float cdist = Integer.MAX_VALUE;
        int cidx = -1;
        for (int ii = 0, ll = locs.size(); ii < ll; ii++) {
            SceneLocation tloc = locs.get(ii);
            StageLocation sl = (StageLocation) tloc.loc;
            float tdist = MathUtil.distance(loc.x, loc.y, sl.x, sl.y);
            if (tdist < cdist) {
                cloc = tloc;
                cdist = tdist;
                cidx = ii;
View Full Code Here

        // the closest full coordinate where a portal may be placed
        Point p = _panel.getFullCoords(centerx, centery);

        // configure the portal with these full coordinates
        _portal = new EditablePortal();
        _portal.loc = new StageLocation(p.x, p.y, (byte)DirectionCodes.NORTH);

        // we want to listen to drags and clicks
        _panel.addMouseListener(this);
        _panel.addMouseMotionListener(this);
        _panel.addExtrasPainter(this);
View Full Code Here

        if (norient == DirectionCodes.NONE) {
            norient = DirectionCodes.NORTH;
        }

        // if our orientation changed, repaint
        StageLocation loc = (StageLocation) _portal.loc;
        if (norient != loc.orient) {
            loc.orient = (byte)norient;
            _panel.repaint();
        }
    }
View Full Code Here

//                      ", tidx=" + tidx + ", tx=" + tx + ", ty=" + ty +
//                      ", sx=" + tset.getXSpot(tidx) +
//                      ", sy=" + tset.getYSpot(tidx) +
//                      ", lx=" + opos.x + ", ly=" + opos.y +
//                      ", fg=" + _metrics.finegran + "].");
            return new StageLocation(opos.x, opos.y, (byte)orient);

        } catch (Exception e) {
            log.warning("Unable to look up object tile for scene object", "tileId", tileId, e);
        }
        return null;
View Full Code Here

        int cx = fx + fwid/2, cy = fy + fhei/2;

        // if it's a 1x1 cluster, return one location in the center of the
        // cluster
        if (cluster.width == 1) {
            StageLocation loc = new StageLocation(
                MisoUtil.toFull(cluster.x, 2), MisoUtil.toFull(cluster.y, 2),
                (byte)DirectionCodes.SOUTHWEST);
            list.add(new SceneLocation(loc, 0));
            return list;
        }

        double radius = (double)fwid/2;
        int clidx = cluster.width-2;
        if (clidx >= CLUSTER_METRICS.length/2 || clidx < 0) {
            log.warning("Requested locs from invalid cluster " + cluster + ".", new Exception());
            return list;
        }

        for (double angle = CLUSTER_METRICS[clidx*2]; angle < Math.PI*2;
             angle += CLUSTER_METRICS[clidx*2+1]) {
            int sx = cx + (int)Math.round(Math.cos(angle) * radius);
            int sy = cy + (int)Math.round(Math.sin(angle) * radius);

            // obtain the orientation facing toward the center
            int orient = 2*(int)(Math.round(angle/(Math.PI/4))%8);
            orient = DirectionUtil.rotateCW(DirectionCodes.SOUTH, orient);
            orient = DirectionUtil.getOpposite(orient);

            // convert them back to full coordinates for the location
            int tx = MathUtil.floorDiv(sx, _metrics.finegran);
            sx = MisoUtil.toFull(tx, sx-(tx*_metrics.finegran));
            int ty = MathUtil.floorDiv(sy, _metrics.finegran);
            sy = MisoUtil.toFull(ty, sy-(ty*_metrics.finegran));
            StageLocation loc = new StageLocation(sx, sy, (byte) orient);
            list.add(new SceneLocation(loc, 0));
        }

        return list;
    }
View Full Code Here

            int yy1 = foot.y-dd, yy2 = foot.y+foot.height+dd-1;
            int xx1 = foot.x-dd, xx2 = foot.x+foot.width+dd-1;

            // get the corners
            spots.add(
                new StageLocation(xx1, yy1, (byte)DirectionCodes.SOUTHWEST));
            spots.add(
                new StageLocation(xx1, yy2, (byte)DirectionCodes.SOUTHEAST));
            spots.add(
                new StageLocation(xx2, yy1, (byte)DirectionCodes.NORTHWEST));
            spots.add(
                new StageLocation(xx2, yy2, (byte)DirectionCodes.NORTHEAST));

            // then the sides
            for (int xx = xx1+1; xx < xx2; xx++) {
                spots.add(
                    new StageLocation(xx, yy1, (byte)DirectionCodes.WEST));
                spots.add(
                    new StageLocation(xx, yy2, (byte)DirectionCodes.EAST));
            }
            for (int yy = yy1+1; yy < yy2; yy++) {
                spots.add(
                    new StageLocation(xx1, yy, (byte)DirectionCodes.SOUTH));
                spots.add(
                    new StageLocation(xx2, yy, (byte)DirectionCodes.NORTH));
            }

            // sort them in order of closeness to the players current
            // coordinate
            spots.sort(new Comparator<StageLocation>() {
                public int compare (StageLocation o1, StageLocation o2) {
                    return dist(o1) - dist(o2);
                }
                private final int dist (StageLocation l) {
                    return Math.round(100*MathUtil.distance(
                                          l.x, l.y, nearto.x, nearto.y));
                }
            });

            // return the first spot that can be "traversed" which we're
            // taking to mean "stood upon"
            for (int ii = 0, ll = spots.size(); ii < ll; ii++) {
                StageLocation loc = spots.get(ii);
                if (pred.canTraverse(traverser, loc.x, loc.y)) {
                    // convert to full coordinates
                    loc.x = MisoUtil.toFull(loc.x, 2);
                    loc.y = MisoUtil.toFull(loc.y, 2);

View Full Code Here

TOP

Related Classes of com.threerings.stage.data.StageLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.