动态海拔图,全路线小地图,骑行记录上传增加截图
This commit is contained in:
1 parent
65fc5b5c50
commit
725b510748
11 files changed
+4294
-4675
No files matched your search
@@ -7,6 +7,7 @@ using System.Collections;
|
||||
using Mapbox.Unity.MeshGeneration.Modifiers;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using System;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@@ -18,7 +19,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
MeshModifier SnapModifier;
|
||||
[SerializeField]
|
||||
Material _material;
|
||||
|
||||
[SerializeField]
|
||||
[Range(1, 10)]
|
||||
private float UpdateFrequency = 2;
|
||||
@@ -36,14 +36,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
_map = FindObjectOfType<AbstractMap>();
|
||||
}
|
||||
// _map.OnInitialized += _map_OnInitialized; ;
|
||||
// _map.OnInitialized += _map_OnInitialized; ;
|
||||
//_map.OnUpdated += _map_OnUpdated; ;
|
||||
//_map.OnTileFinished += _map_OnTileFinished; ;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void _map_OnUpdated()
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
Debug.Log("_map_OnUpdated");
|
||||
}
|
||||
@@ -59,7 +59,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
if (!initComplete)
|
||||
{
|
||||
Debug.Log(47);
|
||||
CreateRoute(obj);
|
||||
initComplete = true;
|
||||
}
|
||||
@@ -71,6 +70,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
cyclingCotroller = transform.parent.GetComponent<CyclingController>();
|
||||
playerController = FindObjectOfType<PlayerController>();
|
||||
_map.OnTileFinished += _map_OnTileFinished;
|
||||
StartCoroutine(QueryTimer());
|
||||
//CreateRoute();
|
||||
}
|
||||
@@ -85,9 +85,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Debug.Log(88);
|
||||
yield return new WaitForSeconds(UpdateFrequency);
|
||||
CreateRoute(null);
|
||||
yield return new WaitForSeconds(UpdateFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +99,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
if (mapData != null)
|
||||
{
|
||||
foreach (var mapDataItem in mapData.List)
|
||||
//foreach (var mapDataItem in mapData.List)
|
||||
for (int i = 0; i < mapData.List.Count; i++)
|
||||
{
|
||||
var point = mapDataItem.Point;
|
||||
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
var distance = TurfCS.Turf.Distance(TurfCS.Turf.Point(new double[] { playerController.Nextlatlong.x, playerController.Nextlatlong.y }), TurfCS.Turf.Point(new double[] { point[0], point[1]}));
|
||||
if (distance<10)
|
||||
item.y += 0.3f;
|
||||
if (!posInScreen(item) && i > playerController.CurrentIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (posInScreen(item))
|
||||
{
|
||||
item.y += 0.3f;
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +119,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//处理海拔高度的问题
|
||||
//SnapModifier.Run(feat, meshData, tile);
|
||||
CreatMapRoute(feat);//创建路线
|
||||
CreateMiniMapRoute(feat);//创建小地图路线
|
||||
//CreateMiniMapRoute(feat);//创建小地图路线
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +129,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Vector3 viewPos = Camera.main.WorldToViewportPoint(position);
|
||||
Vector3 dir = (position - camreatra.position).normalized;
|
||||
float dot = Vector3.Dot(camreatra.forward, dir);
|
||||
if (dot > 0 && viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1)
|
||||
if (dot > -1 && viewPos.x > -1 && viewPos.x < 2 && viewPos.y > -1 && viewPos.y < 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -155,9 +157,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
//处理海拔高度的问题
|
||||
SnapModifier.Run(feat, meshData, tile);
|
||||
CreatMapRoute(feat);//创建路线
|
||||
CreateMiniMapRoute(feat);//创建小地图路线
|
||||
//SnapModifier.Run(feat, meshData, tile);
|
||||
//CreatMapRoute(feat);//创建路线
|
||||
//CreateMiniMapRoute(feat);//创建小地图路线
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +179,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.endColor = c;
|
||||
lineRender.startColor = c;
|
||||
//设置宽度
|
||||
lineRender.SetWidth(0.5f, 0.5f);
|
||||
lineRender.SetWidth(0.2f, 0.2f);
|
||||
lineRender.SetVertexCount(dat.Count);
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
//lineRender.numCapVertices = 90;
|
||||
@@ -190,33 +193,5 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.numCornerVertices = 90;
|
||||
|
||||
}
|
||||
void CreateMiniMapRoute(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapRoute != null)
|
||||
{
|
||||
_mipMapRoute.Destroy();
|
||||
}
|
||||
_mipMapRoute = new GameObject("MiniMapRoute");
|
||||
_mipMapRoute.transform.parent = transform;
|
||||
var lineRender = _mipMapRoute.AddComponent<LineRenderer>();
|
||||
lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.white;
|
||||
lineRender.startColor = Color.white;
|
||||
//设置宽度
|
||||
lineRender.SetWidth(3f, 3f);
|
||||
lineRender.SetVertexCount(dat.Count);
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
//lineRender.numCapVertices = 90;
|
||||
float alpha = 1.0f;
|
||||
//Gradient gradient = new Gradient();
|
||||
//gradient.SetKeys(
|
||||
// new GradientColorKey[] { new GradientColorKey(Color.green, 0.0f), new GradientColorKey(Color.red, 1.0f) },
|
||||
// new GradientAlphaKey[] { new GradientAlphaKey(alpha, 0.0f), new GradientAlphaKey(alpha, 1.0f) }
|
||||
//);
|
||||
//lineRender.colorGradient = gradient;
|
||||
lineRender.numCornerVertices = 90;
|
||||
_mipMapRoute.layer = 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user