348 lines
10 KiB
C#
348 lines
10 KiB
C#
|
|
using ARLocation;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using ARPlus;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using Util;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class ARDataManager : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
// Start is called before the first frame update
|
|||
|
|
|
|||
|
|
private ARSceneManager arscenemgr_ = null;
|
|||
|
|
|
|||
|
|
private GameObject goCL_;
|
|||
|
|
private GameObject[] goMax_;
|
|||
|
|
private GameObject[] goBW_;
|
|||
|
|
|
|||
|
|
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
var go = GameObject.Find("/ARSceneManager");
|
|||
|
|
arscenemgr_ = go.GetComponent<ARSceneManager>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddClToScene()
|
|||
|
|
{
|
|||
|
|
if (goCL_ != null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
double[][] rcdata = GetCLData();
|
|||
|
|
LocationPath locPath = BuildCLLocationPath(rcdata);
|
|||
|
|
|
|||
|
|
GameObject renderClGameObject = arscenemgr_.GetRenderCL();
|
|||
|
|
|
|||
|
|
goCL_ = new GameObject("RendCLInstance");
|
|||
|
|
MoveAlongPath moveAlongPath = goCL_.AddComponent<MoveAlongPath>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
moveAlongPath.PathSettings = renderClGameObject.GetComponent<RenderOption>().pathSettings;
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer = renderClGameObject.GetComponent<LineRenderer>();
|
|||
|
|
moveAlongPath.PlacementSettings = renderClGameObject.GetComponent<RenderOption>().placementSettings;
|
|||
|
|
moveAlongPath.SetLocationPath(locPath);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void AddBwToScene()
|
|||
|
|
{
|
|||
|
|
if (goBW_ != null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
List<double[][]> bwdata = GetBWData();
|
|||
|
|
goBW_ = new GameObject[bwdata.Count];
|
|||
|
|
|
|||
|
|
for (int i = 0; i < bwdata.Count; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
LocationPath locPath = BuildBWLocationPath(bwdata[i]);
|
|||
|
|
|
|||
|
|
GameObject renderBwGameObject = arscenemgr_.GetRenderBW();
|
|||
|
|
|
|||
|
|
GameObject goBWItem_ = new GameObject("RendBWInstance-" + (i + 1).ToString());
|
|||
|
|
goBW_[i] = goBWItem_;
|
|||
|
|
MoveAlongPath moveAlongPath = goBWItem_.AddComponent<MoveAlongPath>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
moveAlongPath.PathSettings = renderBwGameObject.GetComponent<RenderOption>().pathSettings;
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer = renderBwGameObject.GetComponent<LineRenderer>();
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.loop = true;
|
|||
|
|
moveAlongPath.PlacementSettings = renderBwGameObject.GetComponent<RenderOption>().placementSettings;
|
|||
|
|
moveAlongPath.SetLocationPath(locPath);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AddMaxToScene()
|
|||
|
|
{
|
|||
|
|
if (goMax_ != null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
|
|||
|
|
// double[][] rcdata = GetMaxData();
|
|||
|
|
var rcdata = GetGeoData("Max");
|
|||
|
|
goMax_ = new GameObject[rcdata.Count];
|
|||
|
|
for (int i = 0; i < rcdata.Count; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
LocationPath locPath = BuildLocationPath(rcdata[i]);
|
|||
|
|
|
|||
|
|
GameObject renderMaxMaGameObject = arscenemgr_.GetRenderMax();
|
|||
|
|
|
|||
|
|
GameObject goMaxItem_ = new GameObject("RendMaxInstance-" + (i + 1).ToString());
|
|||
|
|
goMax_[i] = goMaxItem_;
|
|||
|
|
MoveAlongPath moveAlongPath = goMaxItem_.AddComponent<MoveAlongPath>();
|
|||
|
|
moveAlongPath.PathSettings = renderMaxMaGameObject.GetComponent<RenderOption>().pathSettings;
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer = renderMaxMaGameObject.GetComponent<LineRenderer>();
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>߶ζ<DFB6><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㹹<EFBFBD><E3B9B9>һ<EFBFBD><D2BB>ֱ<EFBFBD>ߣ<EFBFBD>
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.positionCount = 2;
|
|||
|
|
// // <20><><EFBFBD>ÿ<EFBFBD><C3BF>ȣ<EFBFBD><C8A3><EFBFBD>ʼ<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.startWidth = 0.1f;
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.endWidth = 0.1f;
|
|||
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>֧<EFBFBD>ֽ<EFBFBD><D6BD>䣩
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.startColor = Color.red;
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.endColor = Color.blue;
|
|||
|
|
// // <20><><EFBFBD>ò<EFBFBD><C3B2>ʣ<EFBFBD><CAA3><EFBFBD>ָ<EFBFBD><D6B8>Shader<65><72>
|
|||
|
|
moveAlongPath.PathSettings.LineRenderer.material = new Material(Shader.Find("Sprites/Default"));
|
|||
|
|
moveAlongPath.PlacementSettings = renderMaxMaGameObject.GetComponent<RenderOption>().placementSettings;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// GameObject renderMaxMaGameObject = arscenemgr_.GetRenderMax();
|
|||
|
|
// goMax_ = new GameObject("RendMaxInstance");
|
|||
|
|
// MoveAlongPath moveAlongPath = goMax_.AddComponent<MoveAlongPath>();
|
|||
|
|
// moveAlongPath.PathSettings = renderMaxMaGameObject.GetComponent<RenderOption>().pathSettings;
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer = renderMaxMaGameObject.GetComponent<LineRenderer>();
|
|||
|
|
// // <20><><EFBFBD><EFBFBD><EFBFBD>߶ζ<DFB6><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㹹<EFBFBD><E3B9B9>һ<EFBFBD><D2BB>ֱ<EFBFBD>ߣ<EFBFBD>
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.positionCount = 2;
|
|||
|
|
// // // <20><><EFBFBD>ÿ<EFBFBD><C3BF>ȣ<EFBFBD><C8A3><EFBFBD>ʼ<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.startWidth = 0.1f;
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.endWidth = 0.1f;
|
|||
|
|
// // // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>֧<EFBFBD>ֽ<EFBFBD><D6BD>䣩
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.startColor = Color.red;
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.endColor = Color.blue;
|
|||
|
|
// // // <20><><EFBFBD>ò<EFBFBD><C3B2>ʣ<EFBFBD><CAA3><EFBFBD>ָ<EFBFBD><D6B8>Shader<65><72>
|
|||
|
|
// moveAlongPath.PathSettings.LineRenderer.material = new Material(Shader.Find("Sprites/Default"));
|
|||
|
|
// moveAlongPath.PlacementSettings = renderMaxMaGameObject.GetComponent<RenderOption>().placementSettings;
|
|||
|
|
// moveAlongPath.SetLocationPath(locPath);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IReadOnlyList<Coords> GetGeoData(string name)
|
|||
|
|
{
|
|||
|
|
var data = DataManager.geoDataDictionary[name];
|
|||
|
|
return data;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<double[][]> GetBWData()
|
|||
|
|
{
|
|||
|
|
List<double[][]> listCoords = new List<double[][]>();
|
|||
|
|
double[][] lineCoords1 = new double[4][];
|
|||
|
|
|
|||
|
|
double[] coord11 = new double[3];
|
|||
|
|
coord11[0] = 31.8494395;
|
|||
|
|
coord11[1] = 117.3096992;
|
|||
|
|
coord11[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord12 = new double[3];
|
|||
|
|
coord12[0] = 31.8493477;
|
|||
|
|
coord12[1] = 117.3099519;
|
|||
|
|
coord12[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord13 = new double[3];
|
|||
|
|
coord13[0] = 31.8492647;
|
|||
|
|
coord13[1] = 117.3099106;
|
|||
|
|
coord13[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord14 = new double[3];
|
|||
|
|
coord14[0] = 31.8493563;
|
|||
|
|
coord14[1] = 117.3096577;
|
|||
|
|
coord14[2] = 10;
|
|||
|
|
|
|||
|
|
lineCoords1[0] = coord11;
|
|||
|
|
lineCoords1[1] = coord12;
|
|||
|
|
lineCoords1[2] = coord13;
|
|||
|
|
lineCoords1[3] = coord14;
|
|||
|
|
|
|||
|
|
|
|||
|
|
listCoords.Add(lineCoords1);
|
|||
|
|
|
|||
|
|
double[][] lineCoords2 = new double[4][];
|
|||
|
|
|
|||
|
|
double[] coord21 = new double[3];
|
|||
|
|
coord21[0] = 31.849531;
|
|||
|
|
coord21[1] = 117.3094462;
|
|||
|
|
coord21[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord22 = new double[3];
|
|||
|
|
coord22[0] = 31.8494394;
|
|||
|
|
coord22[1] = 117.309699;
|
|||
|
|
coord22[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord23 = new double[3];
|
|||
|
|
coord23[0] = 31.8493563;
|
|||
|
|
coord23[1] = 117.3096577;
|
|||
|
|
coord23[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord24 = new double[3];
|
|||
|
|
coord24[0] = 31.849448;
|
|||
|
|
coord24[1] = 117.3094049;
|
|||
|
|
coord24[2] = 10;
|
|||
|
|
|
|||
|
|
lineCoords2[0] = coord21;
|
|||
|
|
lineCoords2[1] = coord22;
|
|||
|
|
lineCoords2[2] = coord23;
|
|||
|
|
lineCoords2[3] = coord24;
|
|||
|
|
|
|||
|
|
|
|||
|
|
listCoords.Add(lineCoords2);
|
|||
|
|
|
|||
|
|
return listCoords;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
LocationPath BuildBWLocationPath(double[][] data)
|
|||
|
|
{
|
|||
|
|
//MoveAlongPath.PathSettingsData psData = new MoveAlongPath.PathSettingsData();
|
|||
|
|
|
|||
|
|
LocationPath locPath = ScriptableObject.CreateInstance<LocationPath>();
|
|||
|
|
|
|||
|
|
Location[] locs = new Location[4];
|
|||
|
|
for (int i = 0; i < 4; i++)
|
|||
|
|
{
|
|||
|
|
locs[i] = new Location(data[i][0], data[i][1], data[i][2])
|
|||
|
|
{
|
|||
|
|
AltitudeMode = AltitudeMode.Absolute
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
locPath.Locations = locs;
|
|||
|
|
locPath.SplineType = SplineType.LinearSpline;
|
|||
|
|
locPath.Alpha = 0.5f;
|
|||
|
|
locPath.SceneViewScale = 1.0f;
|
|||
|
|
|
|||
|
|
//psData.LocationPath = locPath;
|
|||
|
|
|
|||
|
|
return locPath;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double[][] GetCLData() //RiverCenterline
|
|||
|
|
{
|
|||
|
|
double[][] lineCoords = new double[6][];
|
|||
|
|
|
|||
|
|
double[] coord1 = new double[3];
|
|||
|
|
coord1[0] = 31.8498255;
|
|||
|
|
coord1[1] = 117.306568;
|
|||
|
|
coord1[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord2 = new double[3];
|
|||
|
|
coord2[0] = 31.8493595;
|
|||
|
|
coord2[1] = 117.3083875;
|
|||
|
|
coord2[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord3 = new double[3];
|
|||
|
|
coord3[0] = 31.8490076;
|
|||
|
|
coord3[1] = 117.3097962;
|
|||
|
|
coord3[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord4 = new double[3];
|
|||
|
|
coord4[0] = 31.8489553;
|
|||
|
|
coord4[1] = 117.3100114;
|
|||
|
|
coord4[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord5 = new double[3];
|
|||
|
|
coord5[0] = 31.8479532;
|
|||
|
|
coord5[1] = 117.3123266;
|
|||
|
|
coord5[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord6 = new double[3];
|
|||
|
|
coord5[0] = 31.8474537;
|
|||
|
|
coord5[1] = 117.3130791;
|
|||
|
|
coord5[2] = 10;
|
|||
|
|
|
|||
|
|
lineCoords[0] = coord1;
|
|||
|
|
lineCoords[1] = coord2;
|
|||
|
|
lineCoords[2] = coord3;
|
|||
|
|
lineCoords[3] = coord4;
|
|||
|
|
lineCoords[4] = coord5;
|
|||
|
|
lineCoords[5] = coord6;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
return lineCoords;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
LocationPath BuildCLLocationPath(double[][] data)
|
|||
|
|
{
|
|||
|
|
//MoveAlongPath.PathSettingsData psData = new MoveAlongPath.PathSettingsData();
|
|||
|
|
|
|||
|
|
LocationPath locPath = ScriptableObject.CreateInstance<LocationPath>();
|
|||
|
|
|
|||
|
|
Location[] locs = new Location[6];
|
|||
|
|
for (int i = 0; i < 6; i++)
|
|||
|
|
{
|
|||
|
|
locs[i] = new Location(data[i][0], data[i][1], data[i][2])
|
|||
|
|
{
|
|||
|
|
AltitudeMode = AltitudeMode.Absolute
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
locPath.Locations = locs;
|
|||
|
|
locPath.SplineType = SplineType.LinearSpline;
|
|||
|
|
locPath.Alpha = 0.5f;
|
|||
|
|
locPath.SceneViewScale = 1.0f;
|
|||
|
|
|
|||
|
|
//psData.LocationPath = locPath;
|
|||
|
|
|
|||
|
|
return locPath;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double[][] GetMaxData() //RiverCenterline
|
|||
|
|
{
|
|||
|
|
double[][] lineCoords = new double[2][];
|
|||
|
|
|
|||
|
|
double[] coord1 = new double[3];
|
|||
|
|
coord1[0] = 31.8732576897494;
|
|||
|
|
coord1[1] = 117.13843113088807;
|
|||
|
|
coord1[2] = 10;
|
|||
|
|
|
|||
|
|
double[] coord2 = new double[3];
|
|||
|
|
coord2[0] = 31.873258780793716;
|
|||
|
|
coord2[1] = 117.1380031964643;
|
|||
|
|
coord2[2] = 10;
|
|||
|
|
|
|||
|
|
|
|||
|
|
lineCoords[0] = coord1;
|
|||
|
|
lineCoords[1] = coord2;
|
|||
|
|
|
|||
|
|
return lineCoords;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LocationPath BuildLocationPath(Coords data)
|
|||
|
|
{
|
|||
|
|
// Debug.Log(data.coords.Count);
|
|||
|
|
var _data = data.coords;
|
|||
|
|
MoveAlongPath.PathSettingsData psData = new MoveAlongPath.PathSettingsData();
|
|||
|
|
LocationPath locPath = ScriptableObject.CreateInstance<LocationPath>();
|
|||
|
|
Location[] locs = new Location[_data.Count];
|
|||
|
|
for (int i = 0; i < _data.Count; i++)
|
|||
|
|
{
|
|||
|
|
locs[i] = new Location(_data[i].x, _data[i].y, _data[i].z)
|
|||
|
|
{
|
|||
|
|
AltitudeMode = AltitudeMode.Absolute
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
//
|
|||
|
|
locPath.Locations = locs;
|
|||
|
|
locPath.SplineType = SplineType.LinearSpline;
|
|||
|
|
locPath.Alpha = 0.5f;
|
|||
|
|
locPath.SceneViewScale = 1.0f;
|
|||
|
|
return locPath;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|