...
Sub InitializeSpline(s As lgMathCatmullRomSpline) As Boolean
If nodes.Length < 4 Then Return False
s.Initialize(Utils.MathVec2Array(nodes), False)
Return True
End Sub
Sub InitializePathPreview As Boolean
preview_timestamp = 0
preview_completion = 0
preview_path_complete = False
active_path = Paths.get(SelectedPath.Number)
nodes = Utils.ExtrapolatedPath(active_path.nodes)
Dim result = InitializeSpline(preview_spline) As Boolean
If result Then preview_progress_calc.Initialize(preview_spline, 100)
Return result
End Sub
Sub DrawPathPreview(shape_renderer As lgShapeRenderer, viewport As Rect)
If SelectedPath.IsUpdated(True) Then InitializePathPreview
If Not(active_path.IsInitialized) _
Or Not(active_path.Settings.IsInitialized) _
Or active_path.Settings.Size == 0 _
Or SelectedPath.Number < 0 _
Or nodes.Length < 4 Then Return _
'-------------------------------------------
Dim speed = Utils.ToNumber(active_path.Settings.Get ("speed" )) * 0.5 As Double
Dim itrpl = Maps.Interpolation.Get(active_path.Settings.Get ("interpolation")) As lgMathInterpolation
If preview_path_complete Then
preview_timestamp = 0
preview_completion = 0
preview_progress_calc.Reset
preview_path_complete = False
End If
Dim delay = 300 * 1 / speed As Int
Dim shape_size As Double
Dim multiplier As Double
Dim min_shape_size = Constants.ENDNODE_RADIUS / 3 As Double
If preview_completion >= 1 Then
ApplyPreviewPathDelay(delay)
multiplier = Min(delay, DateTime.Now - preview_timestamp) / delay
shape_size = min_shape_size + ((Constants.ENDNODE_RADIUS - min_shape_size) * multiplier)
preview_spline_motion.Set(active_path.LastNode.x, active_path.LastNode.y)
Else
multiplier = 0
shape_size = min_shape_size
preview_progress_calc.Update(speed, volume.LibGDX.Graphics.DeltaTime, False)
preview_completion = preview_progress_calc.PathCompletion
preview_spline.ValueAt(preview_spline_motion, itrpl.apply(preview_completion))
End If
shape_renderer.Begin(shape_renderer.SHAPETYPE_Filled)
shape_renderer.SetColorRGBA(1.0, 0.0, 0.0, 1.0 * (1 - multiplier))
shape_renderer.Circle( _
viewport.CenterX + preview_spline_motion.x, _
viewport.CenterY + preview_spline_motion.y, _
shape_size _
)
shape_renderer.End
End Sub
Sub ApplyPreviewPathDelay(delay As Int)
If preview_timestamp == 0 Then
preview_timestamp = DateTime.now
else if DateTime.Now - preview_timestamp >= delay Then
preview_timestamp = 0
preview_path_complete = True
End If
End Sub
...