private void BuildSpline(Location location) { for (var i = 0; i < state.PointCount; i++) { var loc = PathSettings.LocationPath.Locations[i]; state.Points[i] = Location.GetGameObjectPositionForLocation(arLocationRoot.transform, mainCameraTransform, location, loc, HeightRelativeToDevice || HeightGroundRelative); Logger.LogFromMethod("MoveAlongPath", "BuildSpline", $"({gameObject.name}): Points[{i}] = {state.Points[i]}, geo-location = {loc}", DebugMode); } state.Spline = Misc.BuildSpline(PathSettings.LocationPath.SplineType, state.Points, PathSettings.SplineSampleCount, PathSettings.LocationPath.Alpha); }
void DrawPath() { LocationPath locationPath = (LocationPath)target; var pathLocations = locationPath.Locations; if (pathLocations == null || pathLocations.Length < 2) { return; } var viewScale = sceneViewScale.floatValue; var points = new Vector3[pathLocations.Length]; for (var i = 0; i < pathLocations.Length; i++) { var loc = pathLocations[i]; points[i] = Vector3.Scale(loc.ToVector3(), new Vector3(viewScale, 1, viewScale)); } //var points = curve.SamplePoints(100, p => getVec(p, curve.points[0])); var effScale = (1.0f + Mathf.Cos(viewScale * Mathf.PI / 2 - Mathf.PI)); var s = new Vector3(effScale, 1.0f, effScale); var newCPs = new Vector3[locationPath.Locations.Length]; for (var i = 0; i < locationPath.Locations.Length; i++) { // ps.Add(locationPath.locations[i].ToVector3()); var loc = locationPath.Locations[i]; var p = Location.GetGameObjectPositionForLocation( null, new Vector3(), // new Transform(), pathLocations[0], pathLocations[i], true ); Handles.color = Color.blue; Handles.SphereHandleCap(i, Vector3.Scale(p, s), Quaternion.identity, 0.4f, EventType.Repaint); Handles.Label(Vector3.Scale(p, s), loc.Label == "" ? (" Point " + i) : loc.Label); newCPs[i] = Vector3.Scale(p, s); } Spline newPath; if (((SplineType)splineType.enumValueIndex) == SplineType.CatmullromSpline) { newPath = new CatmullRomSpline(newCPs, 100, alpha.floatValue); } else { newPath = new LinearSpline(newCPs); } var newSample = newPath.SamplePoints(1000); for (var i = 0; i < (newSample.Length - 2); i++) { Handles.color = Color.green; Handles.DrawLine(newSample[i + 1], newSample[i]); } }