Jump to content

Paths: Difference between revisions

From HEModdingWiki
No edit summary
No edit summary
Line 14: Line 14:
Paths in HE are defined as a series of "path segments" connecting "path nodes". Each of these path nodes is composed of 5 components:
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 position, a world space 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 normal, a normalized vector which defines which direction is "up". Changing this vector will make the path roll.
* 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 tangent, a normalized vector which defines the tangent to the path at the location of the node, i.e. which way is "forward".
* The distance along the path where the node is located.
* 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.
* A boolean flag that decides whether the segment it starts is a straight segment or an SNS (Smooth Nonuniform Spline) segment.
Line 33: Line 33:


[TODO: add SNS equations]
[TODO: add SNS equations]
== Path types ==
There are 3 major types of path in use in the engine. These types associate some form of automatic behavior with the spline, so make sure to choose the correct one:
=== Grind (GR) ===
Grind paths are used to define paths for the player to grind on. If you land on a GR spline with the player character you will automatically start grinding. In Sonic Frontiers+ this type of path also generates a grind rail model.
=== Side View (SV) ===
Side View paths are used to keep sonic on a 2D plane in 2D segments of a stage. If Sonic is in 2D mode, e.g. by being inside a [[DimensionVolume]] or because the stage is marked as 2D, he will automatically constrain himself to any nearby SV paths.
=== Object (OBJ) ===
Object paths do not have any automatic behavior, and are instead referred to by [[set objects]] for various artist defined behaviors. They can for example be used to guide the movement of a [[camera]] or other object, or they can be used to spawn a series of rings on a path.

Revision as of 14:33, 19 January 2025

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, a world space vector which defines where the path node is located.
  • The normal, a normalized vector which defines which direction is "up". Changing this vector will make the path roll.
  • The tangent, a normalized vector which defines the tangent to the path at the location of the node, i.e. which way is "forward".
  • 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]

Path types

There are 3 major types of path in use in the engine. These types associate some form of automatic behavior with the spline, so make sure to choose the correct one:

Grind (GR)

Grind paths are used to define paths for the player to grind on. If you land on a GR spline with the player character you will automatically start grinding. In Sonic Frontiers+ this type of path also generates a grind rail model.

Side View (SV)

Side View paths are used to keep sonic on a 2D plane in 2D segments of a stage. If Sonic is in 2D mode, e.g. by being inside a DimensionVolume or because the stage is marked as 2D, he will automatically constrain himself to any nearby SV paths.

Object (OBJ)

Object paths do not have any automatic behavior, and are instead referred to by set objects for various artist defined behaviors. They can for example be used to guide the movement of a camera or other object, or they can be used to spawn a series of rings on a path.