Paths: Difference between revisions
No edit summary |
|||
Line 11: | Line 11: | ||
Paths can be contained in either [[Resources|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. | Paths can be contained in either [[Resources|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 == | == Structure of a path == | ||
Paths in HE are defined as a series of "path segments" connecting "path nodes". Each of these path nodes is | Paths in HE are composed of the following things: | ||
* Path segments / nodes, which define the path itself. | |||
* The path type, which associates automatic behavior to the path. | |||
* The side paths (for resource-defined paths). These can be used to generate triple rails (someone please confirm if this is correct). | |||
* The path length (for resource-defined paths). | |||
== Segments and nodes == | |||
The basic shape of the path is defined as a series of "path segments" connecting "path nodes". Each of these path nodes is a combination of 5 properties: | |||
* The position, a world space vector which defines where the path node is located. | * The position, a world space vector which defines where the path node is located. | ||
Line 19: | Line 27: | ||
* 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. | ||
=== Segment types === | |||
Segments come in multiple types that decide how they are interpolated. The type of each segment can be set individually from any of the following types: | |||
== Segment types == | |||
=== Straight === | ==== Straight ==== | ||
Straight path segments are very straightforward: they are straight. | Straight path segments are very straightforward: they are straight. | ||
=== Smooth Nonuniform Spline === | ==== 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 [https://archive.org/details/gameprogrammingg0000unse 4th volume of Game Programming Gems]. | 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 [https://archive.org/details/gameprogrammingg0000unse 4th volume of Game Programming Gems]. | ||
Revision as of 15:12, 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 composed of the following things:
- Path segments / nodes, which define the path itself.
- The path type, which associates automatic behavior to the path.
- The side paths (for resource-defined paths). These can be used to generate triple rails (someone please confirm if this is correct).
- The path length (for resource-defined paths).
Segments and nodes
The basic shape of the path is defined as a series of "path segments" connecting "path nodes". Each of these path nodes is a combination of 5 properties:
- 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.
Segment types
Segments come in multiple types that decide how they are interpolated. The type of each segment can be set individually from any of the following 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 path, so make sure to choose the correct one for your purpose.
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. You can still manually refer to these paths in objects though. Autorun volumes for example tend to be more reliable if the SV path is selected as a target manually, as this will prevent Sonic from launching off the path during turns.
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.