单人骑行
This commit is contained in:
1 parent
f557e2f5df
commit
398628017c
2600 files changed
+427818
-6
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f6ee75d0d54714fb4d2f90016a28bc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2da7d3c8a2ec8054fa19b088b2a8c9d9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
using GeoJSON.Net.Geometry;
|
||||
using Mapbox.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using TurfCS;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
public static class MockData
|
||||
{
|
||||
public static double totaldistance;
|
||||
public static List<Vector2d> vl;
|
||||
/// <summary>
|
||||
/// 获取模拟的骑行记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Vector2d> GetRideList()
|
||||
{
|
||||
string json = "{'Type':'LineString','TotalDistance':19.17906,'List':[{'Point':[26.092100000000002,119.33686000000002],'Elevation':7.6198},{'Point':[26.09211,119.33749000000002],'Elevation':7.5859},{'Point':[26.092170000000003,119.33840000000001],'Elevation':7.421},{'Point':[26.092260000000003,119.33921000000001],'Elevation':7.3133},{'Point':[26.092270002098761,119.33999000005943],'Elevation':7.2394},{'Point':[26.092280000000002,119.34077],'Elevation':7.2701},{'Point':[26.092240000956789,119.34129500009136],'Elevation':7.3416},{'Point':[26.092200000000002,119.34182000000001],'Elevation':7.4177},{'Point':[26.092083338752424,119.34270666844074],'Elevation':7.5033},{'Point':[26.09196667208499,119.34359333511317],'Elevation':7.2596},{'Point':[26.09185,119.34448],'Elevation':6.8727},{'Point':[26.091680000000004,119.34505000000001],'Elevation':6.4546},{'Point':[26.091536672044878,119.34593333550309],'Elevation':6.0312},{'Point':[26.091393338710645,119.34681666884185],'Elevation':5.751},{'Point':[26.091250000000002,119.3477],'Elevation':5.6373},{'Point':[26.091230000000003,119.34794000000001],'Elevation':5.6052},{'Point':[26.091225001411136,119.3485800001182],'Elevation':5.5997},{'Point':[26.091220000000003,119.34922000000002],'Elevation':5.6907},{'Point':[26.091330000000003,119.34997000000001],'Elevation':6.0231},{'Point':[26.091440000000002,119.35021],'Elevation':6.4916},{'Point':[26.09157,119.35095000000001],'Elevation':7.0092},{'Point':[26.091600000000003,119.3516],'Elevation':7.3641},{'Point':[26.091767507390937,119.35244499640774],'Elevation':7.4909},{'Point':[26.091935009859512,119.353289995235],'Elevation':6.9736},{'Point':[26.092102507405667,119.35413499648182],'Elevation':6.7797},{'Point':[26.092270000000003,119.35498000000001],'Elevation':6.5711},{'Point':[26.092405001867032,119.35571999903352],'Elevation':6.4206},{'Point':[26.092540000000003,119.35646000000001],'Elevation':6.3653},{'Point':[26.09269,119.35732000000002],'Elevation':7.251},{'Point':[26.092710000000004,119.35761000000001],'Elevation':8.2263},{'Point':[26.092703339253426,119.35853666675888],'Elevation':9.8464},{'Point':[26.092696672586847,119.35946333341218],'Elevation':11.8545},{'Point':[26.09269,119.36039000000001],'Elevation':13.6159},{'Point':[26.092665001414368,119.36103000007358],'Elevation':15.1102},{'Point':[26.092640000000003,119.36167],'Elevation':16.3984},{'Point':[26.0925,119.36225],'Elevation':17.1179},{'Point':[26.092270000000003,119.36289000000001],'Elevation':17.3805},{'Point':[26.092200000000002,119.36334000000001],'Elevation':17.3022},{'Point':[26.092180000000003,119.36363000000001],'Elevation':17.2282},{'Point':[26.092190000000002,119.36396],'Elevation':17.2224},{'Point':[26.092290000000002,119.36435000000002],'Elevation':17.1729},{'Point':[26.092100000000002,119.36453000000002],'Elevation':17.1065},{'Point':[26.092000000000002,119.36473000000001],'Elevation':17.0503},{'Point':[26.091910000000002,119.36502000000002],'Elevation':17.1392},{'Point':[26.09193,119.36525],'Elevation':17.2636},{'Point':[26.092150000000004,119.36569000000001],'Elevation':17.4486},{'Point':[26.09233,119.36581000000001],'Elevation':17.7034},{'Point':[26.092540000000003,119.36588],'Elevation':18.1077},{'Point':[26.092750000000002,119.36589000000001],'Elevation':18.5083},{'Point':[26.092950000000002,119.36582000000001],'Elevation':18.892},{'Point':[26.093110000000003,119.36572000000001],'Elevation':19.2643},{'Point':[26.09335,119.36544],'Elevation':19.6256},{'Point':[26.094033333311039,119.36542333352864],'Elevation':20.1707},{'Point':[26.094716666620165,119.36540666686258],'Elevation':21.2487},{'Point':[26.0954,119.36539],'Elevation':22.396},{'Point':[26.09605,119.36548],'Elevation':23.9715},{'Point':[26.09615,119.36567000000001],'Elevation':25.3392},{'Point':[26.096753333417059,119.36562333380944],'Elevation':26.626},{'Point':[26.097356666819095,119.36557666713746],'Elevation':28.1709},{'Point':[26.09796,119.36553],'Elevation':30.077},{'Point':[26.098260000000003,119.36556000000002],'Elevation':32.1094},{'Point':[26.09888000013564,119.36572999910875],'Elevation':34.3101},{'Point':[26.099500000000003,119.36590000000001],'Elevation':36.7362},{'Point':[26.099970000000003,119.36599000000001],'Elevation':39.7763},{'Point':[26.100720000000003,119.36591000000001],'Elevation':43.1691},{'Point':[26.101160000000004,119.36591000000001],'Elevation':46.6581},{'Point':[26.10181,119.36598000000001],'Elevation':50.4232},{'Point':[26.10208,119.36621000000001],'Elevation':53.9898},{'Point':[26.102210000000003,119.36674000000001],'Elevation':57.5845},{'Point':[26.101960000000002,119.36725000000001],'Elevation':61.2459},{'Point':[26.101530000000004,119.36721000000001],'Elevation':64.7154},{'Point':[26.100900000000003,119.36697000000001],'Elevation':68.1881},{'Point':[26.100415000136522,119.36697500001934],'Elevation':71.7923},{'Point':[26.09993,119.36698000000001],'Elevation':75.4172},{'Point':[26.099330000000002,119.36702000000001],'Elevation':79.066},{'Poin
Line truncated
|
||||
|
||||
using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
|
||||
{
|
||||
JObject jo = (JObject)JToken.ReadFrom(reader);
|
||||
totaldistance = (double)jo["TotalDistance"];
|
||||
vl = new List<Vector2d>();
|
||||
foreach (var point in jo["List"])
|
||||
{
|
||||
var s = point["Point"];
|
||||
Vector2d points = new Vector2d(Math.Round(Convert.ToDouble(s[0]), 5), Math.Round(Convert.ToDouble(s[1]), 5));
|
||||
vl.Add(points);
|
||||
}
|
||||
return vl;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Vector2d> GetRideList(string json)
|
||||
{
|
||||
using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
|
||||
{
|
||||
JObject jo = (JObject)JToken.ReadFrom(reader);
|
||||
vl = new List<Vector2d>();
|
||||
foreach (var point in jo["List"])
|
||||
{
|
||||
var s = point["Point"];
|
||||
Vector2d points = new Vector2d(Math.Round(Convert.ToDouble(s[0]), 5), Math.Round(Convert.ToDouble(s[1]), 5));
|
||||
vl.Add(points);
|
||||
}
|
||||
return vl;
|
||||
}
|
||||
}
|
||||
public static Vector2d Along(double distance)
|
||||
{
|
||||
var list = vl.Select(p => new GeoJSON.Net.Geometry.GeographicPosition(p.x, p.y));
|
||||
LineString lineString = new LineString(list);
|
||||
var pt1 = Turf.Along(lineString, distance);
|
||||
var ll =((GeographicPosition)((GeoJSON.Net.Geometry.Point)pt1.Geometry).Coordinates);
|
||||
return new Vector2d(ll.Latitude, ll.Longitude);
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算速度
|
||||
/// 参考 http://bikecalculator.com/index.html
|
||||
/// </summary>
|
||||
/// <param name="elevationv">海拔</param>
|
||||
/// <param name="gradev">坡度%</param>
|
||||
/// <param name="powerv">功率</param>
|
||||
/// <param name="rweightv">体重</param>
|
||||
/// <param name="bweightv">自行车重量</param>
|
||||
/// <returns>km/h</returns>
|
||||
public static double CalculateSpeed(double elevationv, double gradev, double powerv, double rweightv, double bweightv)
|
||||
{
|
||||
if (powerv < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (gradev < -10)
|
||||
{
|
||||
gradev = -10;
|
||||
}
|
||||
var tireValues = new double[] { 0.005, 0.004, 0.012 };
|
||||
var aeroValues = new double[] { 0.388, 0.445, 0.420, 0.300, 0.233, 0.200 };
|
||||
var units = 0;
|
||||
|
||||
//温度
|
||||
var temperaturev = 25;
|
||||
|
||||
//海拔
|
||||
//var elevationv = 100;
|
||||
|
||||
//坡度
|
||||
//var gradev = 6 * 0.01 * -1;
|
||||
|
||||
//风,转换成m/s
|
||||
var headwindv = 0 / 3.6;
|
||||
|
||||
var frontalArea = aeroValues[0];
|
||||
|
||||
var transv = 0.95; // no one knows what this is, so why bother presenting a choice?
|
||||
var rollingRes = tireValues[0];
|
||||
|
||||
//应该是空气密度
|
||||
var density = (1.293 - 0.00426 * temperaturev) * Math.Exp(-elevationv / 7000.0);
|
||||
|
||||
|
||||
//全空气阻力参数
|
||||
var a2 = 0.5 * frontalArea * density; // full air resistance parameter
|
||||
var twt = 9.8 * (rweightv + bweightv); // total weight in newtons
|
||||
var tres = twt * (gradev * 0.01 + rollingRes); // gravity and rolling resistance
|
||||
|
||||
//var powerv = 195;
|
||||
|
||||
var v = Newton(a2, headwindv, tres, transv, powerv) * 3.6;// convert to km/h
|
||||
|
||||
//Trace.WriteLine($"速度为:{ v }");
|
||||
|
||||
var t1 = makeDecimal2(v * (units == 1 ? 1.609 : 1.0));
|
||||
return double.Parse(t1, CultureInfo.InvariantCulture);
|
||||
}
|
||||
private static double Newton(double aero, double hw, double tr, double tran, double p)
|
||||
{
|
||||
var vel = 20D;
|
||||
var MAX = 10;
|
||||
var TOL = 0.05;
|
||||
for (int i = 0; i < MAX; i++)
|
||||
{
|
||||
var tv = vel + hw;
|
||||
var aeroEff = (tv > 0.0) ? aero : -aero; // wind in face, must reverse effect
|
||||
var f = vel * (aeroEff * tv * tv + tr) - tran * p; // the function
|
||||
var fp = aeroEff * (3.0 * vel + hw) * tv + tr; // the derivative
|
||||
var vNew = vel - f / fp;
|
||||
if (Math.Abs(vNew - vel) < TOL)
|
||||
{
|
||||
return vNew; // success
|
||||
}
|
||||
vel = vNew;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
private static string makeDecimal2(double value)
|
||||
{
|
||||
if (value != 0)
|
||||
{
|
||||
var x = Math.Round(value * 100);
|
||||
int d;
|
||||
if (x < 100)
|
||||
{
|
||||
d = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
d = Convert.ToInt32(Math.Floor(x / 100), CultureInfo.InvariantCulture);
|
||||
};
|
||||
var c = x % 100;
|
||||
var g = (c >= 10) ? "" : "0";
|
||||
return "" + d + "." + g + c;
|
||||
}
|
||||
return value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec3c835a32499e84e8d2f93d713d461a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,174 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Utils;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace Ride.Scripts
|
||||
{
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
[Header("Character")]
|
||||
[SerializeField]
|
||||
GameObject character;
|
||||
[SerializeField]
|
||||
float characterSpeed;
|
||||
[SerializeField]
|
||||
Animator characterAnimator;
|
||||
|
||||
//[Header("References")]
|
||||
//[SerializeField]
|
||||
//AstronautDirections directions;
|
||||
//[SerializeField]
|
||||
//Transform startPoint;
|
||||
//[SerializeField]
|
||||
//Transform endPoint;
|
||||
[SerializeField]
|
||||
AbstractMap map;
|
||||
[SerializeField]
|
||||
GameObject rayPlane;
|
||||
//[SerializeField]
|
||||
//Transform _movementEndPoint;
|
||||
|
||||
[SerializeField]
|
||||
LayerMask layerMask;
|
||||
|
||||
Ray ray;
|
||||
RaycastHit hit;
|
||||
LayerMask raycastPlane;
|
||||
float clicktime;
|
||||
bool moving;
|
||||
bool characterDisabled;
|
||||
private List<Vector2d> rideList;
|
||||
void Start()
|
||||
{
|
||||
characterAnimator = GetComponentInChildren<Animator>();
|
||||
//初始化玩家坐标
|
||||
currentlatlong = map.WorldToGeoPosition(transform.localPosition);
|
||||
nextlatlong = currentlatlong;
|
||||
totalDistance = 0;
|
||||
//StartCoroutine("Timer");
|
||||
//if (!Application.isEditor)
|
||||
//{
|
||||
// this.enabled = false;
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
//gameStatus idle start pause finish
|
||||
|
||||
private Vector2d currentlatlong; //当前坐标
|
||||
private Vector2d nextlatlong; //下一个点的坐标
|
||||
private double totalDistance;
|
||||
void Update()
|
||||
{
|
||||
if (characterDisabled)
|
||||
return;
|
||||
|
||||
//CamControl();
|
||||
|
||||
bool click = false;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
clicktime = Time.time;
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (Time.time - clicktime > 0.15f)
|
||||
{
|
||||
click = true;
|
||||
}
|
||||
}
|
||||
//开始骑行
|
||||
//if (click)
|
||||
{
|
||||
StartCoroutine("Walk");
|
||||
}
|
||||
}
|
||||
IEnumerator Walk()
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
//读取当前速度以及骑行距离
|
||||
double distance = MockData.CalculateSpeed(Random.Range(100,300), 10, 100, 65, 7) / 3600;
|
||||
if (totalDistance + distance <= MockData.totaldistance)
|
||||
{
|
||||
totalDistance += distance;
|
||||
//计算下一个点的位置
|
||||
nextlatlong = MockData.Along(totalDistance);
|
||||
|
||||
if (distance > 0)
|
||||
{
|
||||
CamControl();
|
||||
//设定动画状态
|
||||
characterAnimator.SetBool("IsRide", true);
|
||||
nextPos = map.GeoToWorldPosition(nextlatlong);
|
||||
//转向
|
||||
StartCoroutine(LookAtNextPos());
|
||||
//让人物移动 TODO 可以继续分点增加动画的流畅度
|
||||
transform.localPosition = nextPos;
|
||||
//StartCoroutine(MoveTo());
|
||||
}
|
||||
else
|
||||
{
|
||||
moving = false;
|
||||
characterAnimator.SetBool("IsRide", false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
moving = false;
|
||||
characterAnimator.SetBool("IsRide", false);
|
||||
}
|
||||
}
|
||||
|
||||
#region Character : Movement
|
||||
List<Vector3> futurePositions = new List<Vector3>();
|
||||
bool interruption;
|
||||
|
||||
|
||||
Vector3 nextPos;
|
||||
Vector3 prevPos;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Character : Rotation
|
||||
IEnumerator LookAtNextPos()
|
||||
{
|
||||
Quaternion neededRotation = Quaternion.LookRotation(character.transform.position - nextPos);
|
||||
Quaternion thisRotation = character.transform.localRotation;
|
||||
|
||||
float t = 0;
|
||||
while (t < 1.0f)
|
||||
{
|
||||
t += Time.deltaTime / 0.25f;
|
||||
var rotationValue = Quaternion.Slerp(thisRotation, neededRotation, t);
|
||||
character.transform.rotation = Quaternion.Euler(0, rotationValue.eulerAngles.y, 0);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CameraControl
|
||||
[Header("CameraSettings")]
|
||||
[SerializeField]
|
||||
Camera cam;
|
||||
Vector3 previousPos = Vector3.zero;
|
||||
Vector3 deltaPos = Vector3.zero;
|
||||
|
||||
void CamControl()
|
||||
{
|
||||
if (cam != null)
|
||||
{
|
||||
deltaPos = transform.position - previousPos;
|
||||
//deltaPos.y = 0;
|
||||
cam.transform.position = Vector3.Lerp(cam.transform.position, cam.transform.position + deltaPos, Time.time);
|
||||
previousPos = transform.position;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b302b86be2917240a96a5b47007701d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerData : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e420a61df06f8b428bbd6b9f11190a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
namespace Mapbox.Unity.MeshGeneration.Factories
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Mapbox.Unity.Map;
|
||||
using Data;
|
||||
using Modifiers;
|
||||
using Mapbox.Utils;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using System.Collections;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
public class RouteController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
AbstractMap _map;
|
||||
|
||||
[SerializeField]
|
||||
MeshModifier[] MeshModifiers;
|
||||
[SerializeField]
|
||||
Material _material;
|
||||
|
||||
[SerializeField]
|
||||
[Range(1, 10)]
|
||||
private float UpdateFrequency = 2;
|
||||
|
||||
private int _counter;
|
||||
|
||||
GameObject _directionsGO;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (_map == null)
|
||||
{
|
||||
_map = FindObjectOfType<AbstractMap>();
|
||||
}
|
||||
_map.OnInitialized += CreateRoute;
|
||||
_map.OnUpdated += CreateRoute;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
foreach (var modifier in MeshModifiers)
|
||||
{
|
||||
modifier.Initialize();
|
||||
}
|
||||
|
||||
StartCoroutine(QueryTimer());
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
_map.OnInitialized -= CreateRoute;
|
||||
_map.OnUpdated -= CreateRoute;
|
||||
}
|
||||
|
||||
public IEnumerator QueryTimer()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(UpdateFrequency);
|
||||
CreateRoute();
|
||||
}
|
||||
}
|
||||
void CreateRoute()
|
||||
{
|
||||
var meshData = new MeshData();
|
||||
var dat = new List<Vector3>();
|
||||
|
||||
List<Vector2d> points = MockData.vl;
|
||||
if (points == null)
|
||||
{
|
||||
points = MockData.GetRideList();
|
||||
}
|
||||
{
|
||||
foreach (var point in points)
|
||||
{
|
||||
Vector3 item = _map.GeoToWorldPosition(point);//point.x, point.y, _map.CenterMercator, _map.WorldRelativeScale);
|
||||
//item.y = (float)(_map.QueryElevationInUnityUnitsAt(point))+0.3f;
|
||||
item.y += 0.5f;
|
||||
dat.Add(item);
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
|
||||
foreach (MeshModifier mod in MeshModifiers.Where(x => x.Active))
|
||||
{
|
||||
mod.Run(feat, meshData, _map.WorldRelativeScale * 8);
|
||||
|
||||
}
|
||||
CreateGameObject(meshData);
|
||||
}
|
||||
}
|
||||
|
||||
GameObject CreateGameObject(MeshData data)
|
||||
{
|
||||
if (_directionsGO != null)
|
||||
{
|
||||
_directionsGO.Destroy();
|
||||
}
|
||||
_directionsGO = new GameObject("direction waypoint " + " entity");
|
||||
var mesh = _directionsGO.AddComponent<MeshFilter>().mesh;
|
||||
mesh.subMeshCount = data.Triangles.Count;
|
||||
|
||||
mesh.SetVertices(data.Vertices);
|
||||
_counter = data.Triangles.Count;
|
||||
for (int i = 0; i < _counter; i++)
|
||||
{
|
||||
var triangle = data.Triangles[i];
|
||||
mesh.SetTriangles(triangle, i);
|
||||
}
|
||||
|
||||
_counter = data.UV.Count;
|
||||
for (int i = 0; i < _counter; i++)
|
||||
{
|
||||
var uv = data.UV[i];
|
||||
mesh.SetUVs(i, uv);
|
||||
}
|
||||
|
||||
mesh.RecalculateNormals();
|
||||
_directionsGO.AddComponent<MeshRenderer>().material = _material;
|
||||
|
||||
return _directionsGO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cdee5ecffe869b40913ef4eb53fd993
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RouteData
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e343b676bd532340a23969ea51e7e94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user