|
TrackFlow Pro Documentation 1
Generate roller coasters, railroads, conveyors and more with a physics aware spline and meshing system.
|
This page will serve as a second glance at what exactly TrackFlowPro is doing under the hood.
This project is designed to allow you to build 3D space curves with consistent rotation minimizing frames over their arc length. You can use it as a basis to build many different systems that rely on frame aware constructions, like roller coasters, conveyor belts, railroads, road networks, pathing data, and much more. The system features a few different addons that are useful in the construction of these systems, the main one being the TrackFlowSpawner. This component can either build an extruded mesh along the curve, or instantiate objects along the curve. Both options come with a plethora of customization configurations.
The concept of frames in TrackFlow Pro is directly analogous to the mathematical definition of them in the context of space curves. At each point in space, the curve has a set of three basis vectors, which orient it in space. This means it defines a longitudinal, lateral and vertical direction at each point in space. These directions are all orthogonal to each other, and they rotate smoothly along the curve by default.
You can view the frames at each knot in the inspector, by selecting a GameObject with a TrackFlowSpline component on it. The blue arrow displays the tangent (longitudinal), the red arrow displays the normal (lateral) vector, and the green arrow displays the binormal (vertical). You can rotate these in the editor by holding shift and clicking the handles at the end of the frame vectors. Note the direction that each one will rotate the frame with. Dragging the tangent vector will rotate the frame about the normal vector, rotating the normal vector will rotate the frame about the binormal vector, and rorating the binormal vector rotates the frame about the tangent.
By default the curve will smoothly rotate its frame orientation to match the orientation at each control point. So by rotating the curve about the binormal, you can control "up" at that point, and the curve will smoothly orient itself in that position at that point. This is controlled by the knot settings StartUpMode, which is by default set to UseKnotB, which orients the start of the segment with the given binormal vector. As well as the MathNextFrame setting on the knots, which smoothly orient the frame between the two knots.
In addition to the roll introduced by rotating the frame handles, you can add an additional roll modifier by clicking on any knot and opening the TrackModifiers > Roll Profile settings menu. Here you can add a roll profile amplitude (in degrees) over the segment with an animation curve. You can control how the roll is applied over the normalized arc length of the segment by opening and editing the animation curve, by default it will roll to the amplitude value at 50% of the segment length, then smoothly roll from there to the next frame orientation.
Within the TrackFlowSpline component the first two settings to get familiar with are visible in the inspector at Settings > Closed, and Spline Settings > Use Spline. The first of these do exactly what it sounds like, allows you to close the curve so it forms a loop. The second one places the TrackFlowSpline component into one of its two main modes: Segment Mode or Spline Mode, they both do fundamentally different things within the underlying ArcFrame library, which is not documented here.
In segment mode, each control node can have its own curve type, which can be selected by clicking on the knot in the inspector and clicking the CurveType dropdown, or selecting one or more knots in the inspector (shift click) which opens the TrackFlowSplineOverlay (if not check the toolbar for a button with "TF" on it) and you can select the curve type there as well, currently one of Line, Arc, or Clothoid.
Also in segment mode, the orientation of the control point frame controls the start tangent of the curve at that point. To rotate the knots in the editor, press shift and click to drag the knot
Not all frame orientations of two knots will yield a pleasing shape, this is mainly if you are using Clothoid mode. This is because the underlying ArcFrame curve library has to quickly solve the clothoid parameters in real time. While ArcFrame is capable of drawing 2D clothoids using conventional methods (nonlinear optimization), currently we restrict TrackFlowSpline with using a special case of clothoid for 3D, which has a fast solution for many orientations, but not all. In the case of failure to generate valid clothoid parameters, TrackFlowSpline will generate a line output, many times slightly adjusting the parameters (orientation and rotation) is enough to generate a valid solution again.
When you select spline mode, the system changes from generating a specific curve type between each control point, and instead uses all of the control points to build a mathematical spline object that passes through each one. Currently TrackFlow Pro supports cubic Bezier splines or Catmull-Rom splines, both have their uses. Also in spline mode, knot handles will pop up in the inspector at each control point, you can drag these around to set the input and output tangents for each knot. By default the spline mode curve does not follow the frame **tangent** at each knot. This is because you need to pack the control point array with the input and output tangent handles (two extra data points), and the frame is not a go However it will follow the frame **binormal** as explained above.
The curves generated by TrackFlowSpline come from another library I developed (ArcFrame) which generates points along any curve in any dimension, it can use interpolation to calculate (or solve using nonlinear optimization) the curve parameters which generate a specific type of curve between two points in N-dimensional space OR it can extrapolate intrinsic curve data, which is the curvature, torsion, their derivatives, an an arc length.
Here in TrackFlow Pro we only utilize the "interpolation". Though I have plans for extrapolated curves, which would allow for much more control over the overall shape, at the cost of not being able to place control points in space, those would be calculated for you.