Jump to content

Paths

From HEModdingWiki
Revision as of 15:45, 6 January 2025 by Angryzor (talk | contribs)

Paths are common to all versions of the Hedgehog Engine, and play an important role in many of its features. In essence, paths are 3D splines or curves, which the engine uses for many things, e.g.:

  • Player automation (like autorun volumes and grinding).
  • Camera movement (for cameras like the Rail family of cameras).
  • Confinement of the player to a 2D side view.
  • Movement of ballistic projectiles.
  • Calculation of the player's movement when using gimmicks like springs.
  • Placement of replicated game objects on a curve.
  • Automatic generation of grind rails.

Paths can be contained in either path resources, generated at runtime when objects need them (e.g. for springs or ballistic projectiles), or they can be generated by special set objects in the "Set Path" family.

Structure of a path

Paths in HE are defined as a series of "path segments" connecting "path nodes". Each of these path nodes is composed of 5 components:

  • The position vector, which defines where the path node is located.
  • The forward vector, a normal which defines the tangent to the path at the location of the node.
  • The up vector, a normal which defines which direction is "up" in the game world, similar to the up vector used to calculate a view matrix.
  • The distance along the path where the node is located.
  • A boolean flag that decides whether the segment it starts is a straight segment or an SNS (Smooth Nonuniform Spline) segment.

Resource-defined paths also have a length. Resource-defined paths may additionally describe 2 additional side paths. These can be used to generate triple rails (someone please confirm if this is correct).

Segment types

Straight

Straight path segments are very straightforward: they are straight.

Smooth Nonuniform Spline

Smooth Nonuniform Splines are a specific type of nonuniform cubic spline. Splines are curved paths in 3D space, usually described using a series of points in space called nodes. Nonuniform splines have the specific property that their velocity is not affected by the distance between those nodes (in contrast to more common splines like Catmull-Rom splines). While it is difficult to find much information about "smooth" nonuniform splines, the nomenclature seems to originate from the 4th volume of Game Programming Gems.

As the book describes them, smooth nonuniform splines are C2 continuous. This means that they are continuous in their 2nd derivative, i.e. they have continuous acceleration. This makes them useful for the calculation of movements that shouldn't have any kind of jerky motion, e.g. the movement of a camera.

[TODO: add SNS equations]