|
TrackFlow Pro Documentation 1
Generate roller coasters, railroads, conveyors and more with a physics aware spline and meshing system.
|
Instantiate a mesh along the TrackFlowSpline. This is for discrete mesh pieces. If you want a pipe or road those are built into the Mesh settings within TrackFlowSpline. More...
Classes | |
| class | CustomProfileOptions |
| struct | SpawnPlacement |
Public Member Functions | |
| void | NuclearDestruction () |
| Destroys the pool, clears the active object array increments nuclearRegret counter. | |
| void | RecalculateBounds () |
| calculate the bounds of the instantiated object | |
| void | ReleaseSpawnedObjects () |
| void | ClearSpawnedMeshes () |
| void | SeverMesh () |
| GameObject[] | GetSeveredMeshes () |
| TrackFlowSample | Evaluate (float t01) |
| Evaluate the potentially snapped and offset polyline. Fallback to TrackFlowSpline polyline. | |
| bool | TryGetSpawnPreviewPolyline (out ChordErrorSampler.Polyline poly) |
| Get the polyline that we want to display. | |
Public Attributes | |
| bool | ignoreOtherTrackFlowSpawnersForSnap = true |
| bool | ignoreSelfForSnap = true |
| bool | enableSurfaceSnap = false |
| SurfaceSnapDirectionMode | snapDirection = SurfaceSnapDirectionMode.WorldDown |
| float | snapMaxDistance = 100f |
| LayerMask | snapLayerMask = ~0 |
| float | surfaceOffset = 0f |
| bool | alignToSurfaceNormal = true |
| int | upHintSmoothWindow = 3 |
| float | upHintMaxDegPerMeter = 0 |
| int | tangentHintSmoothWindow = 3 |
| float | tangentHintMaxDegPerMeter = 0 |
| float | frameSmooth01 = 0.85f |
| TrackFlowSpline | Spline |
| bool | resampleCurvatureAfterSnap = true |
| If true, recompute arc-length + curvature/torsion after snapping/offset. This keeps curvature preview and g-force colors consistent with the deformed path. | |
| bool | build = true |
| Master enable flag for spawning along the spline. | |
| SpawnMethod | SpawnMethod = SpawnMethod.Object |
| SpawnJitterVolume | jitterVolume = SpawnJitterVolume.Line |
| SpawnJitter | spawnJitter = SpawnJitter.Default |
| bool | preview = false |
| Editor preview for spawner positions. | |
| TrackMeshType | meshType = TrackMeshType.Road |
| Material | meshMaterial |
| float | meshWidth = 1f |
| Width parameter passed to the track mesh builder. For roads this is total road width; for pipes it is outer diameter. | |
| AnimationCurve | meshScale = AnimationCurve.Linear(0f, 1f, 1f, 1f) |
| Scale profile along the spline (x = normalized arc, y = scale factor). | |
| MeshingUtils.MeshUvSettings | meshUvSettings = MeshingUtils.MeshUvSettings.Default |
| TubeOptions | tubeOptions = new() |
| Optional curvature / torsion / g-force vertex color preview. | |
| RoadOptions | roadOptions = new() |
| Road-specific options (thickness, etc.). | |
| UTrackOptions | uTrackOptions = new() |
| CustomProfileOptions | customProfile = new CustomProfileOptions() |
| float | meshQuality = 1 |
| bool | generateMeshCollider = false |
| bool | convexMeshCollider = false |
| bool | cacheDeformedPolyline = true |
| Bounds | prefabBounds = new(Vector3.zero, Vector3.zero) |
| bool | ignorePrefabBounds = false |
| GameObject | ObjectToInstantiate |
| The prefab to place along the spline. | |
| int | maxInstances = 40 |
| Max number of instances allowed. If negative, fill the usable spline length. | |
| bool | forceEvenSpacing = false |
| float | separation |
| Extra spacing between instances along the spline (in meters of arc length). | |
| float | startOffset = 0f |
| Arc length offset from the start of the spline. | |
| Vector3 | localOffset = Vector3.zero |
| Local offset from the spawn position. | |
| bool | ApplyLocalOffsetBeforeSnapping = false |
| float | rollOffsetDegrees = 0f |
| The Y axis of the prefab will be aligned with the binormal of the moving frame. This offset is a clockwise rotation around the tangent when looking along the tangent. | |
Properties | |
| bool | IsInitialized [get, private set] |
| bool | HasDeformedPolyline [get] |
| double | DeformedLength [get] |
Private Member Functions | |
| bool | ShouldIgnoreSnapCollider (Collider col) |
| Evaluate a collider to see if we should ignore it when calculating snap positions. | |
| bool | TryGetNearestValidSnapHit (in Ray ray, out RaycastHit bestHit) |
| bool | TryGetDeformedPolyline (out ChordErrorSampler.Polyline poly) |
| void | RefreshSplineSubscription () |
| Remove Spline rebuilt subscription if we have an old spline reference. | |
| void | UnsubscribeSpline () |
| Transform | GetOrCreateRoot (ref Transform cache, string name, HideFlags editorFlags) |
| Transform | GetOrCreateInstancesRoot () |
| Transform | GetOrCreatePoolRoot () |
| bool | CanMutateGeneratedHierarchy () |
| Check if the spawner should be able to change the scene hierarchy. Don't allow if it is a prefab or otherwise not a real object loaded into an active scene. | |
| void | ResetTransientState () |
| Completely reset the references, useful if we saved a spawner as a prefab with references attached. | |
| void | OnEnable () |
| void | OnDisable () |
| void | CleanupOrphanChildrenEditorNow () |
| void | QueueEditorMaintenance (bool cleanupOrphans=false, bool nuclear=false, bool rebuild=false, bool refreshPool=false) |
| void | CancelEditorMaintenance () |
| void | EditorDelayedMaintenance () |
| void | EditorDelayedRebuild () |
| Add a delay call to rebuild the spline when the editor finishes updating the inspectors. It's okay to stack many of these in a single frame the extras will be ignored. | |
| void | CancelEditorRebuild () |
| void | OnValidate () |
| void | CleanupGeneratedChildrenEditorNow () |
| Cleanup the generated children based on the TrackFlowGeneratedMarker. | |
| void | EnsureObjectPoolInitialized () |
| void | HandleSplineRebuilt (object sender, EventArgs args) |
| ChordErrorSampler.Polyline | ApplySpawnOffsetsPreserveFrames (in ChordErrorSampler.Polyline basePoly) |
| Vector3 Quaternion rotation | GetSpawnOrientation (TrackFlowSample sample, out Vector3 upHintWS) |
| Vector3 Quaternion rotation | GetSpawnOrientation (TrackFlowSample sample, Vector3 effectiveLocalOffset, float effectiveRollOffsetDegrees, out Vector3 upHintWS) |
| void | OnDestroy () |
| GameObject | CreateNewPooledObject () |
| Create a new pooled object, set it inactive reset its transform etc. | |
| void | OnGetPooledObject (GameObject obj) |
| void | OnReleasePooledObject (GameObject obj) |
| void | OnDestroyPooledObject (GameObject obj) |
| void | SyncActiveInstanceCount (int requiredCount) |
| Vector3[] | BuildTangentHints (ChordErrorSampler.Polyline offsetPoly) |
| after building a deformed polyline, the tangents are not following the terrain or other deformities, do a quick forward difference to build new tangents | |
| ChordErrorSampler.Polyline | BuildOffsetPolyline2 (ChordErrorSampler.Polyline basePoly, out Vector3[] upHintsWS) |
| ITrackMeshBuilder | CreateMeshBuilderForSpawner () |
| bool | SpawnerWantsDeform () |
| bool | TryBuildFinalPolyline (out ChordErrorSampler.Polyline poly) |
| apply offsets and deformations to the polyline, cache the result if enabled. if the spawner does not want a deformed polyline, return the base polyline instead. | |
| GameObject | GetOrCreateMeshGO () |
| void | BuildMeshFromSpline () |
| bool | TryBuildPlacementForSlot (in ChordErrorSampler.Polyline poly, float pathLength, int slotIndex, float baseS, float baseT01, out SpawnPlacement placement) |
| void | BuildObjectPlacements (in ChordErrorSampler.Polyline poly, float pathLength, float clampedStart, float blockWidth, int requiredCount) |
| bool | JitterEnabled () |
| uint | InitJitterState (int slotIndex) |
Static Private Member Functions | |
| static TrackFlowSpawnAnchorCache | GetOrBuildAnchorCache (GameObject root) |
| static void | ApplySpawnPose (GameObject obj, Vector3 targetPos, Quaternion targetRot, Vector3 scale) |
| static bool | IsInPrefabStage (GameObject go) |
| static bool | IsPersistentOrPrefabAssetObject (GameObject go) |
| static void | SubscribeToOnEditorQuitting () |
| static void | CleanupAllSpawnedObjectsInScene () |
| Called to ensure we cleanup any spawned objects before the editor closes. | |
| static float | GetPolylineLength (in ChordErrorSampler.Polyline poly, float fallback) |
| static float | WrapOrClampS (float s, float length, bool closed) |
| static uint | Hash32 (uint x) |
| static float | Next01 (ref uint state) |
| static float | Range (ref uint state, float min, float max) |
| static Vector3 | Range (ref uint state, Vector3 min, Vector3 max) |
Private Attributes | |
| TrackFlowSpline | _spline |
| readonly List< SpawnPlacement > | _spawnPlacements = new() |
| ChordErrorSampler.Polyline | _cachedDeformedPolyline |
| bool | _hasCachedDeformedPolyline |
| readonly List< UnityEngine.Mesh > | _meshes = new() |
| readonly List< GameObject > | _meshObjects = new() |
| GameObject | _prevObjectToInstantiate |
| readonly List< GameObject > | activePooledObjects = new() |
| ObjectPool< GameObject > | objectPool |
| TrackFlowSpline | _subscribedSpline |
| Transform | _instancesRoot |
| Transform | _poolRoot |
| bool | _editorMaintenanceQueued |
| bool | _editorWantsCleanupOrphans |
| bool | _editorWantsNuke |
| bool | _editorWantsRebuild |
| bool | _editorWantsPoolRefresh |
| Vector3 | position |
Static Private Attributes | |
| const string | GeneratedMeshName = "_SpawnMesh_Generated" |
| static RaycastHit[] | s_RaycastHits = new RaycastHit[32] |
Instantiate a mesh along the TrackFlowSpline. This is for discrete mesh pieces. If you want a pipe or road those are built into the Mesh settings within TrackFlowSpline.
"Forward" is assumed to be the Z direction; we align prefab Z with spline tangent (blue), and prefab Y with spline binormal (green).
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
after building a deformed polyline, the tangents are not following the terrain or other deformities, do a quick forward difference to build new tangents
| offsetPoly |
|
private |
|
private |
|
private |
Check if the spawner should be able to change the scene hierarchy. Don't allow if it is a prefab or otherwise not a real object loaded into an active scene.
|
staticprivate |
Called to ensure we cleanup any spawned objects before the editor closes.
|
private |
Cleanup the generated children based on the TrackFlowGeneratedMarker.
|
private |
| void TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ClearSpawnedMeshes | ( | ) |
|
private |
|
private |
Create a new pooled object, set it inactive reset its transform etc.
|
private |
|
private |
Add a delay call to rebuild the spline when the editor finishes updating the inspectors. It's okay to stack many of these in a single frame the extras will be ignored.
|
private |
| TrackFlowSample TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.Evaluate | ( | float | t01 | ) |
Evaluate the potentially snapped and offset polyline. Fallback to TrackFlowSpline polyline.
| t01 |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
| GameObject[] TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.GetSeveredMeshes | ( | ) |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
staticprivate |
| void TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.NuclearDestruction | ( | ) |
Destroys the pool, clears the active object array increments nuclearRegret counter.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
| void TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.RecalculateBounds | ( | ) |
calculate the bounds of the instantiated object
|
private |
Remove Spline rebuilt subscription if we have an old spline reference.
| void TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ReleaseSpawnedObjects | ( | ) |
|
private |
Completely reset the references, useful if we saved a spawner as a prefab with references attached.
| void TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.SeverMesh | ( | ) |
|
private |
Evaluate a collider to see if we should ignore it when calculating snap positions.
| col |
|
private |
|
staticprivate |
|
private |
|
private |
apply offsets and deformations to the polyline, cache the result if enabled. if the spawner does not want a deformed polyline, return the base polyline instead.
| poly |
|
private |
|
private |
|
private |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.TryGetSpawnPreviewPolyline | ( | out ChordErrorSampler.Polyline | poly | ) |
Get the polyline that we want to display.
| poly |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.alignToSurfaceNormal = true |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ApplyLocalOffsetBeforeSnapping = false |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.build = true |
Master enable flag for spawning along the spline.
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.cacheDeformedPolyline = true |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.convexMeshCollider = false |
| CustomProfileOptions TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.customProfile = new CustomProfileOptions() |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.enableSurfaceSnap = false |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.forceEvenSpacing = false |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.frameSmooth01 = 0.85f |
|
staticprivate |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.generateMeshCollider = false |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ignoreOtherTrackFlowSpawnersForSnap = true |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ignorePrefabBounds = false |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ignoreSelfForSnap = true |
| SpawnJitterVolume TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.jitterVolume = SpawnJitterVolume.Line |
| Vector3 TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.localOffset = Vector3.zero |
Local offset from the spawn position.
| int TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.maxInstances = 40 |
Max number of instances allowed. If negative, fill the usable spline length.
| Material TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshMaterial |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshQuality = 1 |
| AnimationCurve TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshScale = AnimationCurve.Linear(0f, 1f, 1f, 1f) |
Scale profile along the spline (x = normalized arc, y = scale factor).
| TrackMeshType TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshType = TrackMeshType.Road |
| MeshingUtils.MeshUvSettings TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshUvSettings = MeshingUtils.MeshUvSettings.Default |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.meshWidth = 1f |
Width parameter passed to the track mesh builder. For roads this is total road width; for pipes it is outer diameter.
|
private |
| GameObject TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.ObjectToInstantiate |
The prefab to place along the spline.
|
private |
| Bounds TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.prefabBounds = new(Vector3.zero, Vector3.zero) |
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.preview = false |
Editor preview for spawner positions.
| bool TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.resampleCurvatureAfterSnap = true |
If true, recompute arc-length + curvature/torsion after snapping/offset. This keeps curvature preview and g-force colors consistent with the deformed path.
| RoadOptions TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.roadOptions = new() |
Road-specific options (thickness, etc.).
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.rollOffsetDegrees = 0f |
The Y axis of the prefab will be aligned with the binormal of the moving frame. This offset is a clockwise rotation around the tangent when looking along the tangent.
|
staticprivate |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.separation |
Extra spacing between instances along the spline (in meters of arc length).
| SurfaceSnapDirectionMode TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.snapDirection = SurfaceSnapDirectionMode.WorldDown |
| LayerMask TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.snapLayerMask = ~0 |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.snapMaxDistance = 100f |
| SpawnJitter TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.spawnJitter = SpawnJitter.Default |
| SpawnMethod TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.SpawnMethod = SpawnMethod.Object |
| TrackFlowSpline TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.Spline |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.startOffset = 0f |
Arc length offset from the start of the spline.
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.surfaceOffset = 0f |
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.tangentHintMaxDegPerMeter = 0 |
| int TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.tangentHintSmoothWindow = 3 |
| TubeOptions TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.tubeOptions = new() |
Optional curvature / torsion / g-force vertex color preview.
Pipe-specific options (tube, caps, cross section, wall thickness).
| float TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.upHintMaxDegPerMeter = 0 |
| int TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.upHintSmoothWindow = 3 |
| UTrackOptions TrackFlowPro.Runtime.Core.Meshing.TrackFlowSpawner.uTrackOptions = new() |
|
get |
|
get |
|
getprivate set |