Tutorials: Path Construction


Paths can be defined by typing .path.txt files manually, or by using a third party path editor. Michael Schmidlkofer has written an excellent editor which he makes available here.

Path Terminology

In order to understand paths, it is a good idea to clarify the terminolgy.

Point
A point is a x- and y-coordinate pair using relative coordinates (i.e. it is scrolled around along with the background image). A point has attributes, or values that are used to affect object standing between them.

Scale-attribute
Affects an object's scale, so that he can appear to walk closer to and farther from the user's perspective.

Color-attribute
This attribute affects an object's lighting filter. A color of black (0,0,0) will cause the object to appear entirely dark, and white (255,255,255) will cause an object to appear fully lit. A color such as blue (0,0,255) will filter out all the red and green light, making the object appear blue in color.

Z-attribute
This attribute affects how high an object will "float" above the path in a certain area.

Triangle
A triangle is a made of three connected points, of course. It is significant because each position in the triangle will use the proximity of the three surrounding points to determine the average attribute for that position.

Edge
Any line of a triangle that is not common to another triangle is called and edge, because it forms the boundary between on and off the path.

Line
Any of the line segments that form a side of a triangle, including edges.

Criteria for a Valid Path

Here are the rules you must follow to define a valid path:

  • No lines may intersect, except sides shared between two triangles or where endpoints meet
  • Every position in the path must be reachable from every other position
  • Any connected triangles must share two, and only two, points
  • Three or more triangles cannot share the same two points

According to these rules, there may be "holes" in the path polygon, but not "islands" or separate isolated polygons.

Path Text Format

This human-readable format has been created so that third-party editors may be constructed, and without the fear of incompatibility with future revisons of a binary path resource format.

A path text file is simply a list of points with attributes and a list of triangles made by connecting those points.

The path shown above can be represented with the following text file called Demo.path.txt (except this demostration is abbreviated to save space):

point A { x=48 y=145 }
point B { x=56 y=102 scale=1000 color=50,0,100 z=35 }
point C { x=113 y=45 }
.
.
.
point AA { x=120 y=179 }

triangle 1 { points=A,B,I }
triangle 2 { points=A,I,AA }
triangle 3 { points=A,H,AA }	  
.
.
.
triangle 29 { points=J,B,I }	  

The scale, color and z attributes are demonstrated on point B.

Points may have any alphanumeric name, and triangle names are optional, since they are never referenced by name.

A point must always be declared before the triangle that uses it, and the maximum number of points or triangles is 255. Some validity checking is performed, but it is possible to fool 2path into creating an invalid path. So be sure to follow the above rules!

See Also...