private void SpawnPrefab(VectorEntity ve, UnityTile tile, Vector2d latLong) { GameObject go; var featureId = ve.Feature.Data.Id; if (_objects.ContainsKey(featureId)) { go = _objects[featureId]; go.SetActive(true); go.transform.SetParent(ve.GameObject.transform, false); } else { go = Instantiate(_options.prefab); _prefabList.Add(go); _objects.Add(featureId, go); _objectPosition.Add(featureId, latLong); go.transform.SetParent(ve.GameObject.transform, false); } PositionScaleRectTransform(ve, tile, go, latLong); if (_options.AllPrefabsInstatiated != null) { _options.AllPrefabsInstatiated(_prefabList); } }
public override void Run(VectorEntity ve, UnityTile tile) { if (_colliderStrategy != null) { _colliderStrategy.AddColliderTo(ve); } }
public override void Run(VectorEntity ve, UnityTile tile) { var min = Math.Min(_options.materials.Length, ve.MeshFilter.mesh.subMeshCount); var mats = new Material[min]; if (!_options.projectMapImagery) { for (int i = 0; i < min; i++) { mats[i] = _options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)]; } } else { for (int i = 0; i < min; i++) { mats[i] = Instantiate(_options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)]); } mats[0].mainTexture = tile.GetRasterData(); mats[0].mainTextureScale = new Vector2(1f, 1f); } ve.MeshRenderer.materials = mats; }
public override void Run(VectorEntity ve, UnityTile tile) { //replace the feature only once per lat/lon if (ShouldSpawnFeature(ve.Feature)) { SpawnPrefab(ve, tile); } }
//Send in the parameters needed public void Initialize(VectorEntity ve, GameObject Canvas, GameObject Text, GameObject UiImage, Dictionary <string, Sprite> SpriteSet) { _ve = ve; _Canvas = Canvas; _Text = Text; _UiImage = UiImage; _SpriteSet = SpriteSet; }
public void Initialize(VectorEntity ve) { VectorEntity = ve; Transform = transform; Data = ve.Feature; //var label = ve.GameObject.GetComponent<CustomLabelTextSetter>(); //label.SetName(Data.Properties["name"].ToString()); }
public override void Run(VectorEntity ve, UnityTile tile) { if (map == null) { map = FindObjectOfType <AbstractMap>(); } OnPoolItem(ve); }
public override void Run(VectorEntity ve, UnityTile tile) { // if collider exists. remove it. RemoveColliderFrom(ve); if (_colliderStrategy != null) { _colliderStrategy.AddColliderTo(ve); } }
public override void Run(VectorEntity ve, UnityTile tile) { //create a very small random offset to avoid z-fighting Vector3 randomOffset = Random.insideUnitSphere; randomOffset *= 0.01f; ve.GameObject.transform.localPosition += randomOffset; }
public override void Run(VectorEntity ve, UnityTile tile) { int selpos = ve.Feature.Points[0].Count / 2; var met = ve.Feature.Points[0][selpos]; IFeaturePropertySettable settable = null; GameObject go; if (_objects.ContainsKey(ve.GameObject)) { go = _objects[ve.GameObject]; settable = go.GetComponent <IFeaturePropertySettable>(); if (settable != null) { go = (settable as MonoBehaviour).gameObject; settable.Set(ve.Feature.Properties); } // set gameObject transform go.name = ve.Feature.Data.Id.ToString(); go.transform.localPosition = met; go.transform.localScale = Constants.Math.Vector3One; if (!_options.scaleDownWithWorld) { go.transform.localScale = Vector3.one / tile.TileScale; } return; } else { go = Instantiate(_options.prefab); _prefabList.Add(go); _objects.Add(ve.GameObject, go); } go.name = ve.Feature.Data.Id.ToString(); go.transform.position = met; go.transform.SetParent(ve.GameObject.transform, false); go.transform.localScale = Constants.Math.Vector3One; settable = go.GetComponent <IFeaturePropertySettable>(); if (settable != null) { settable.Set(ve.Feature.Properties); } if (!_options.scaleDownWithWorld) { go.transform.localScale = Vector3.one / tile.TileScale; } if (_options.AllPrefabsInstatiated != null) { _options.AllPrefabsInstatiated(_prefabList); } }
public override void Run(VectorEntity ve, UnityTile tile) { //replace the feature only once per lat/lon Vector2d latLong = Vector2d.zero; if (ShouldSpawnFeature(ve.Feature, out latLong)) { SpawnPrefab(ve, tile, latLong); } }
public override void OnPoolItem(VectorEntity vectorEntity) { if (_options.style == StyleTypes.Satellite) { foreach (var material in vectorEntity.MeshRenderer.sharedMaterials) { DestroyImmediate(material, true); } } }
public void AddColliderTo(VectorEntity ve) { if (_colliders.ContainsKey(ve.GameObject)) { _colliders[ve.GameObject].sharedMesh = ve.Mesh; } else { _colliders.Add(ve.GameObject, ve.GameObject.AddComponent <MeshCollider>()); } }
//public override void Run(VectorEntity ve, UnityTile tile) //{ // ve.MeshRenderer.enabled = false; //} public override void Run(VectorEntity ve, UnityTile tile) { tile.MeshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; tile.MeshRenderer.allowOcclusionWhenDynamic = true; tile.MeshRenderer.shadowCastingMode = ShadowCastingMode.Off; ve.MeshFilter.mesh.SetTriangles(ve.MeshFilter.mesh.triangles, 0); ve.MeshFilter.mesh.subMeshCount = 1; ve.MeshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; ve.MeshRenderer.materials = Materials; }
public override void Run (VectorEntity fb, UnityTile tile) { try { // Get the static singleton instance. markerScript = GeoPosition.Instance; // Perform any operation - here height of the buildings are measured. markerScript.performAction (); } catch (Exception ex) { Debug.LogException (ex); } }
public void RemoveColliderFrom(VectorEntity ve) { var existingCollider = ve.GameObject.GetComponent <Collider>(); if (existingCollider == null) { return; } DestroyImmediate(existingCollider); _colliderStrategy?.Reset(); }
public override void Run(VectorEntity ve, UnityTile tile) { foreach (var t in _types) { _tempId = ve.GameObject.GetInstanceID() + t.Type.FullName; if (!_scripts.Contains(_tempId)) { ve.GameObject.AddComponent(t.Type); _scripts.Add(_tempId); } } }
public void AddColliderTo(VectorEntity ve) { if (_colliders.ContainsKey(ve.GameObject)) { _colliders[ve.GameObject].center = ve.Mesh.bounds.center; _colliders[ve.GameObject].size = ve.Mesh.bounds.size; } else { _colliders.Add(ve.GameObject, ve.GameObject.AddComponent <BoxCollider>()); } }
public void AddColliderTo(VectorEntity ve) { if (_colliders.ContainsKey(ve.GameObject)) { _colliders[ve.GameObject].center = ve.Mesh.bounds.center; _colliders[ve.GameObject].radius = ve.Mesh.bounds.extents.magnitude; } else { _colliders.Add(ve.GameObject, ve.GameObject.AddComponent <SphereCollider>()); } }
public void RemoveColliderFrom(VectorEntity ve) { var existingCollider = ve.GameObject.GetComponent <Collider>(); if (existingCollider != null) { existingCollider.Destroy(); if (_colliderStrategy != null) { _colliderStrategy.Reset(); } } }
public override void Run(VectorEntity ve, UnityTile tile) { if (_features.ContainsKey(ve.GameObject)) { _features[ve.GameObject].Initialize(ve); } else { _tempFeature = ve.GameObject.AddComponent <FeatureBehaviour>(); _features.Add(ve.GameObject, _tempFeature); _tempFeature.Initialize(ve); } }
public override void Run(VectorEntity ve, UnityTile tile) { if (_detectors.ContainsKey(ve.GameObject)) { _detectors[ve.GameObject].Initialize(_marker, ve); } else { _tempDetector = ve.GameObject.AddComponent <FeatureSelectionDetector>(); _detectors.Add(ve.GameObject, _tempDetector); _tempDetector.Initialize(_marker, ve); } }
public override void OnPoolItem(VectorEntity vectorEntity) { if (_objects.ContainsKey(vectorEntity.GameObject)) { foreach (var item in _objects[vectorEntity.GameObject]) { item.SetActive(false); _pool.Enqueue(item); } _objects[vectorEntity.GameObject].Clear(); _objects.Remove(vectorEntity.GameObject); } }
public override void Run(VectorEntity ve, UnityTile tile) { var min = Math.Min(_options.materials.Length, ve.MeshFilter.sharedMesh.subMeshCount); var mats = new Material[min]; if (_options.style == StyleTypes.Custom) { for (int i = 0; i < min; i++) { mats[i] = _options.customStyleOptions.materials[i].Materials[UnityEngine.Random.Range(0, _options.customStyleOptions.materials[i].Materials.Length)]; } } else if (_options.style == StyleTypes.Satellite) { for (int i = 0; i < min; i++) { mats[i] = Instantiate(_options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)]); } mats[0].mainTexture = tile.GetRasterData(); mats[0].mainTextureScale = new Vector2(1f, 1f); } else { float renderMode = 0.0f; switch (_options.style) { case StyleTypes.Light: renderMode = GetRenderMode(_options.lightStyleOpacity); break; case StyleTypes.Dark: renderMode = GetRenderMode(_options.darkStyleOpacity); break; case StyleTypes.Color: renderMode = GetRenderMode(_options.colorStyleColor.a); break; default: break; } for (int i = 0; i < min; i++) { mats[i] = _options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)]; mats[i].SetFloat("_Mode", renderMode); } } ve.MeshRenderer.materials = mats; }
public override void Run(VectorEntity ve, UnityTile tile) { UiImage = new GameObject("Image", typeof(Image)); UiImage.transform.SetParent(Canvas.transform); Text = new GameObject("Text", typeof(Text)); Text.transform.SetParent(Canvas.transform); Text.GetComponent <Text>().font = Resources.GetBuiltinResource <Font>("Arial.ttf"); Text.GetComponent <Text> ().fontSize = 10; UiGenerator = Instantiate(Resources.Load <GameObject>("UiGenerator")); UiGenerator.transform.position = new Vector3(0, 0, 0); UiGenerator.transform.SetParent(Canvas.transform); _infoPanel = UiGenerator.GetComponent <infoPanel>(); _infoPanel.Initialize(ve, Canvas, Text, UiImage, _SpriteSet); }
public override void Run(VectorEntity ve, UnityTile tile) { if (map == null) { map = FindObjectOfType <AbstractMap>(); } ; if (ve != null && ve.GameObject != null) { Instantiate(WellPrefab).transform.SetParent(ve.GameObject.transform, false); } OnPoolItem(ve); }
public override void Run(VectorEntity ve, UnityTile tile) { _spawnedCount = 0; var collider = ve.GameObject.GetComponent <Collider>(); var bounds = collider.bounds; var center = bounds.center; center.y = 0; var area = (int)(bounds.size.x * bounds.size.z); int spawnCount = Mathf.Min(area / _spawnRateInSquareMeters, _maxSpawn); while (_spawnedCount < spawnCount) { var x = Random.Range(-bounds.extents.x, bounds.extents.x); var z = Random.Range(-bounds.extents.z, bounds.extents.z); var ray = new Ray(bounds.center + new Vector3(x, 100, z), Vector3.down * 2000); RaycastHit hit; //Debug.DrawRay(ray.origin, ray.direction * 1000, Color.yellow, 1000); if (Physics.Raycast(ray, out hit, 150, _layerMask)) { //Debug.DrawLine(ray.origin, hit.point, Color.red, 1000); var index = Random.Range(0, _prefabs.Length); var transform = ((GameObject)Instantiate(_prefabs[index], ve.Transform, false)).transform; transform.position = hit.point; if (_randomizeRotation) { transform.localEulerAngles = new Vector3(0, Random.Range(-180f, 180f), 0); } if (!_scaleDownWithWorld) { transform.localScale = Vector3.one / tile.TileScale; } if (_randomizeScale) { var scale = transform.localScale; var y = Random.Range(scale.y * .7f, scale.y * 1.3f); scale.y = y; transform.localScale = scale; } _spawnedCount++; } } }
public override void Run(VectorEntity ve, UnityTile tile) { var min = ve.MeshFilter.sharedMesh.subMeshCount; var mats = new Material[min]; Vector2d latLon = GameObject.Find("Map").GetComponent <AbstractMap>().WorldToGeoPosition(ve.Transform.position); float sample_data = 10; for (int i = 0; i < min; i++) { Material mat = new Material(Shader.Find("Specular")); mat.color = dataToColor(sample_data); mats[i] = mat; } ve.MeshRenderer.materials = mats; }
public override void Run(VectorEntity ve, UnityTile tile) { var fixedLocationProvider = new FixedLocationData(); var feature = ve.Feature; int id = 0; float heading = 0.0f; string locationName = string.Empty; string latitudeLongitudeString; Vector2d latitudeLongitude = Vector2d.zero; if (feature.Properties.ContainsKey(_syncLocationIdKey)) { if (!int.TryParse(feature.Properties[_syncLocationIdKey].ToString(), out id)) { Debug.Log("No property with key : " + _syncLocationIdKey + "found!"); } } if (feature.Properties.ContainsKey(_syncLocationNameKey)) { locationName = feature.Properties[_syncLocationNameKey].ToString(); if (string.IsNullOrEmpty(locationName)) { Debug.Log("No property with key : " + _syncLocationNameKey + "found!"); } } if (feature.Properties.ContainsKey(_syncLocationPositionKey)) { latitudeLongitudeString = feature.Properties[_syncLocationPositionKey].ToString(); latitudeLongitude = Conversions.StringToLatLon(latitudeLongitudeString); } if (feature.Properties.ContainsKey(_syncLocationHeadingKey)) { if (!float.TryParse(feature.Properties[_syncLocationHeadingKey].ToString(), out heading)) { Debug.Log("No property with key : " + _syncLocationHeadingKey + "found!"); } } fixedLocationProvider.SetLocation(id, locationName, "sync-point", latitudeLongitude, heading); }
internal void Show(VectorEntity selectedFeature) { if (selectedFeature == null) { Clear(); return; } _selectedFeature = selectedFeature; transform.position = new Vector3(0, 0, 0); var mesh = selectedFeature.MeshFilter; if (mesh != null) { _targetVerts = mesh.mesh.vertices; Snap(); } gameObject.SetActive(true); }
private void GenBlankLineUsers(int VectorUserCount, VectorEntity Vec, List<User> VectorUserList) { double area = Vec.Area; GeoXYLine flag = Vec.Flag as GeoXYLine; VectorUserList.AddRange(this.GenBlankClutterUser(VectorUserCount, area, flag)); }
private GeoXYPoint GetPointNewName(VectorEntity vetorE, GeoXYPoint geoNode) { foreach (GeoXYPoint point in this.GeoProvider.GeoNodeList) { if (point.ID == geoNode.ID) { vetorE.Flag = point; geoNode = point; } } return geoNode; }
private void AppendVector(VectorEntity ve, string VectorName) { if (!(!(ve.Name == VectorName) || this.InVectorList(ve))) { ve.Density = 0f; this.m_VectorMap.SelectedVectorList.Add(ve); this.m_ApplyBtn.Enabled = true; } }
private void setGeoLineToVectorEntity(GeoDataProvider geoDataProvider, VectorEntity vetEntity) { List<GeoXYLine> geoLineList = geoDataProvider.GeoProvider.GeoLineList; foreach (GeoXYLine line in geoLineList) { if (line.Name == vetEntity.Name) { vetEntity.Flag = line; vetEntity.Area = line.GetDistance(); } } }
private void setPolygonToVectorEntity(GeoDataProvider geoDataProvider, VectorEntity vetEntity) { foreach (GeoPolygonRegion region in geoDataProvider.GeoProvider.PolygonRegionList) { if (vetEntity.Name == region.Name) { vetEntity.Flag = region; vetEntity.Area = region.RegionArea; } } }
private void AddLineToVectorList(List<GeoXYLine> lines) { lines.ForEach(delegate (GeoXYLine Line) { VectorEntity item = new VectorEntity(Line.Name) { Id = Line.ID, Type = VectorType.Line, Area = Line.GetDistance() / 1000.0, Flag = Line }; this.m_VectorList.Add(item); }); }
private void SetVetorEntityNewName(VectorEntity vetorE) { switch (vetorE.Type) { case VectorType.Point: { GeoXYPoint flag = vetorE.Flag as GeoXYPoint; flag = this.GetPointNewName(vetorE, flag); vetorE.Name = flag.Name; break; } case VectorType.Line: { GeoXYLine geoTrafficLine = vetorE.Flag as GeoXYLine; geoTrafficLine = this.GetLineNewName(vetorE, geoTrafficLine); vetorE.Name = geoTrafficLine.Name; vetorE.Area = geoTrafficLine.GetDistance() / 1000.0; break; } case VectorType.Polygon: { GeoPolygonRegion polyRegion = vetorE.Flag as GeoPolygonRegion; polyRegion = this.GetPolygonNewName(vetorE, polyRegion); vetorE.Name = polyRegion.Name; vetorE.Area = polyRegion.RegionArea; break; } } }
private bool InVectorList(VectorEntity sve) { return this.m_VectorList.Exists(ve => sve.Id.Equals(ve.Id)); }
private List<User> GetVectorUser(VectorEntity Vec, bool isFixure) { int num2; int num = Convert.ToInt32((double) ((Vec.Area * Vec.Density) / ((double) this.m_AreaMap[Vec.Type]))); if (isFixure) { num2 = num; } else { num2 = Poisson.Poissonize((double) num); } Vec.ClutterList = this.GetClutterList(Vec, isFixure); List<User> vectorUserList = new List<User>(); double vectorArea = this.GetVectorArea(Vec); this.AddVectorUsers(Vec, num2, vectorArea, vectorUserList, isFixure); return vectorUserList; }
private void GetVectorPolygonList() { this.m_GeoProvider.PolygonRegionList.ForEach(delegate (GeoPolygonRegion Polygon) { VectorEntity item = new VectorEntity(Polygon.Name) { Id = Polygon.ID, Type = VectorType.Polygon, Area = Polygon.RegionArea, Flag = Polygon }; this.m_VectorList.Add(item); }); }
private double GetVectorArea(VectorEntity Vec) { double num = 0.0; foreach (ClutterEntity entity in Vec.ClutterList) { ClutterKind kind = this.FindClutterKind(entity); entity.Weight = kind.Weight; entity.Indoor = kind.Indoor; num += entity.Area * entity.Weight; } return num; }
private GeoPolygonRegion GetPolygonNewName(VectorEntity vetorE, GeoPolygonRegion polyRegion) { foreach (GeoPolygonRegion region in this.GeoProvider.PolygonRegionList) { if (region.ID == polyRegion.ID) { vetorE.Flag = region; polyRegion = region; } } return polyRegion; }
private void AddVectorUsers(VectorEntity Vec, int VectorUserCount, double VectorArea, List<User> VectorUserList, bool isFixure) { Vec.ClutterList.ForEach(delegate (ClutterEntity ne) { if (ne.Weight != 0) { VectorUserList.AddRange(this.GenClutterUser(ne, VectorUserCount, VectorArea, Vec, isFixure)); } }); }
private void AddPointToVectorList(List<GeoXYPoint> nodes) { nodes.ForEach(delegate (GeoXYPoint Node) { VectorEntity item = new VectorEntity(Node.Name) { Id = Node.ID, Type = VectorType.Point, Area = 1.0, Flag = Node }; this.m_VectorList.Add(item); }); }
private List<User> GenClutterUser(ClutterEntity ne, int VectorUserCount, double VectorArea, VectorEntity Vec, bool isFixure) { double clutterUserCount = ((VectorUserCount * ne.Area) * ne.Weight) / VectorArea; ne.UserList.Clear(); List<User> userList = ne.UserList; this.m_CurrentClutter = ne; this.ProcessService(clutterUserCount, ne.UserList); List<int> userIdxs = new List<int>(); this.GetUserIdxs(userList, userIdxs); List<GeoXYPoint> list3 = this.GenUserPoints(Vec, ne.Id, userIdxs, isFixure); int count = list3.Count; for (int i = 0; i < count; i++) { userList[i].X = list3[i].X; userList[i].Y = list3[i].Y; } this.SetIndoorUsers(userList, ne.Indoor); return userList; }
private List<GeoXYPoint> GetClutterUsersOnLine(VectorEntity Vec, short ClutterId, List<int> UserIdxs, int LayerIndex) { GeoXYLine flag = Vec.Flag as GeoXYLine; GeoXYLine geoXYLine = new GeoXYLine(); geoXYLine.AddPoint(flag.Points.ToArray()); return this.m_GeoProvider.GetGeoInfo.GetClutterPointDict(geoXYLine, ClutterId, UserIdxs); }
private List<GeoXYPoint> GenUserPoints(VectorEntity Vec, short clutterEntityId, List<int> UserIdxs, bool isFixure) { if (Vec.Type == VectorType.Polygon) { return this.GetClutterUsersOnPolygon(Vec, clutterEntityId, UserIdxs, isFixure); } if (Vec.Type == VectorType.Line) { return this.GetClutterUsersOnLine(Vec, clutterEntityId, UserIdxs, 0); } return this.GetClutterUsersOnPoint(Vec, clutterEntityId, UserIdxs, 0); }
private void setPointToVectorEntity(GeoDataProvider geoDataProvider, VectorEntity vetEntity) { List<GeoXYPoint> geoNodeList = geoDataProvider.GeoProvider.GeoNodeList; foreach (GeoXYPoint point in geoNodeList) { if (vetEntity.Name == point.Name) { vetEntity.Flag = point; vetEntity.Area = point.Distance(point); } } }
private List<GeoXYPoint> GetClutterUsersOnPoint(VectorEntity Vec, short ClutterId, List<int> UserIdxs, int LayerIndex) { GeoXYPoint flag = Vec.Flag as GeoXYPoint; List<GeoXYPoint> list = new List<GeoXYPoint>(); int count = UserIdxs.Count; for (int i = 0; i < count; i++) { list.Add(flag); } return list; }
private bool InVectorList(VectorEntity ve) { foreach (VectorEntity entity in this.m_VectorMap.SelectedVectorList) { if (entity.Name == ve.Name) { return true; } } return false; }
private List<ClutterEntity> GetClutterList(VectorEntity Vec, bool isFixure) { if (Vec.Type == VectorType.Polygon) { return this.GetClutterListOnPolygon(Vec.Flag, isFixure); } if (Vec.Type == VectorType.Line) { return this.GetClutterListOnLine(Vec.Flag); } return this.GetClutterListOnNode(Vec.Flag); }
private void GenBlankPolygonUsers(int VectorUserCount, VectorEntity Vec, List<User> VectorUserList) { double area = Vec.Area; GeoPolygonRegion flag = Vec.Flag as GeoPolygonRegion; VectorUserList.AddRange(this.GenBlankClutterUser(VectorUserCount, area, flag)); }
private GeoXYLine GetLineNewName(VectorEntity vetorE, GeoXYLine geoTrafficLine) { foreach (GeoXYLine line in this.GeoProvider.GeoLineList) { if (line.ID == geoTrafficLine.ID) { vetorE.Flag = line; geoTrafficLine = line; } } return geoTrafficLine; }
private List<GeoXYPoint> GetClutterUsersOnPolygon(VectorEntity Vec, short ClutterId, List<int> UserIdxs, bool isFixure) { GeoPolygonRegion flag = Vec.Flag as GeoPolygonRegion; ITrafficMapModelService service = this.m_ServiceContext.Lookup(typeof(ITrafficMapModelService).FullName) as ITrafficMapModelService; return service.PolygonRegionAssist.GetClutterPointDict(flag, ClutterId, UserIdxs, !isFixure); }
private List<User> GetBlankVectorUser(VectorEntity Vec, bool isFixure) { int num2; int num = Convert.ToInt32((double) ((Vec.Area * Vec.Density) / ((double) this.m_AreaMap[Vec.Type]))); if (isFixure) { num2 = num; } else { num2 = Poisson.Poissonize((double) num); } List<User> vectorUserList = new List<User>(); this.m_BlankVectorMap[Vec.Type](num2, Vec, vectorUserList); return vectorUserList; }