Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.newdawn.slick.util.pathfinding.navmesh
Class Space

    java.lang.Object
      org.newdawn.slick.util.pathfinding.navmesh.Space

    public class Space

extends java.lang.Object

A quad space within a navigation mesh

Author:
  kevin

Constructor Summary
`Space(float x, float y, float width, float height)` Create a new space

Method Summary
`boolean` | `canMerge(Space other)` Check if the given space can be merged with this one.
`void` | `clearCost()` Clear the costing values across the whole map
`boolean` | `contains(float xp, float yp)` Check if this space contains a given point
`void` | `fill(Space target, float sx, float sy, float cost)` Fill the spaces based on the cost from a given starting point
`float` | `getCost()` Get the cost to get to this node at the moment
`float` | `getHeight()` Get the height of the space
`Link` | `getLink(int index)` Get the link from this space to another at a particular index
`int` | `getLinkCount()` Get the number of links
`float` | `getWidth()` Get the width of the space
`float` | `getX()` Get the x coordinate of the top corner of the space
`float` | `getY()` Get the y coordinate of the top corner of the space
`boolean` | `hasJoinedEdge(Space other)` Check if this space has an edge that is joined with another
`void` | `link(Space other)` Link this space to another by creating a link and finding the point at which the spaces link up
`Space` | `merge(Space other)` Merge this space with another
`boolean` | `pickLowestCost(Space target, NavPath path)` Pick the lowest cost route from this space to another on the path
`java.lang.String` | `toString()` Get the string representation of this instance

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

Constructor Detail

### Space

    public Space(float x,
                 float y,
                 float width,
                 float height)

  Create a new space

  Parameters:
    `x` - The x coordinate of the top corner of the space
    `y` - The y coordinate of the top corner of the space
    `width` - The width of the space
    `height` - The height of the space

Method Detail

### getWidth

    public float getWidth()

  Get the width of the space

  Returns:
    The width of the space

### getHeight

    public float getHeight()

  Get the height of the space

  Returns:
    The height of the space

### getX

    public float getX()

  Get the x coordinate of the top corner of the space

  Returns:
    The x coordinate of the top corner of the space

### getY

    public float getY()

  Get the y coordinate of the top corner of the space

  Returns:
    The y coordinate of the top corner of the space

### link

    public void link(Space other)

  Link this space to another by creating a link and finding the point at which the spaces link up

  Parameters:
    `other` - The other space to link to

### hasJoinedEdge

    public boolean hasJoinedEdge(Space other)

  Check if this space has an edge that is joined with another

  Parameters:
    `other` - The other space to check against
  Returns:
    True if the spaces have a shared edge

### merge

    public Space merge(Space other)

  Merge this space with another

  Parameters:
    `other` - The other space to merge with
  Returns:
    The result space created by joining the two

### canMerge

    public boolean canMerge(Space other)

  Check if the given space can be merged with this one. It must have an adjacent edge and have the same height or width as this space.

  Parameters:
    `other` - The other space to be considered
  Returns:
    True if the spaces can be joined together

### getLinkCount

    public int getLinkCount()

  Get the number of links

  Returns:
    The number of links from the space to others

### getLink

    public Link getLink(int index)

  Get the link from this space to another at a particular index

  Parameters:
    `index` - The index of the link to retrieve
  Returns:
    The link from this space to another

### contains

    public boolean contains(float xp,
                            float yp)

  Check if this space contains a given point

  Parameters:
    `xp` - The x coordinate to check
    `yp` - The y coordinate to check
  Returns:
    True if this space container the coordinate given

### fill

    public void fill(Space target,
                     float sx,
                     float sy,
                     float cost)

  Fill the spaces based on the cost from a given starting point

  Parameters:
    `target` - The target space we're heading for
    `sx` - The x coordinate of the starting point
    `sy` - The y coordinate of the starting point
    `cost` - The cost up to this point

### clearCost

    public void clearCost()

  Clear the costing values across the whole map

### getCost

    public float getCost()

  Get the cost to get to this node at the moment

  Returns:
    The cost to get to this node

### pickLowestCost

    public boolean pickLowestCost(Space target,
                                  NavPath path)

  Pick the lowest cost route from this space to another on the path

  Parameters:
    `target` - The target space we're looking for
    `path` - The path to add the steps to
  Returns:
    True if the path was found

### toString

    public java.lang.String toString()

  Get the string representation of this instance

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    The string representation of this instance

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 New Dawn Software. All Rights Reserved.