void BuildChunk(WorldChunk chunk) { chunk.ChunkContainer = new GameObject(); chunk.ChunkContainer.transform.localScale = new Vector3(Settings.CunkScale, Settings.CunkScale, Settings.CunkScale); if (chunk.HasLocation) { PlaceAtLocation.AddPlaceAtComponent(chunk.ChunkContainer, chunk.ChunkLocation, new PlaceAtLocation.PlaceAtOptions { MaxNumberOfLocationUpdates = 2 }); chunk.ChunkContainer.transform.localEulerAngles = new Vector3(0, chunk.ChunkRotation, 0); } else { chunk.ChunkContainer.transform.position = chunk.Origin; chunk.Bounds = new Bounds(chunk.Origin, new Vector3(chunk.Length, chunk.Length, chunk.Length)); chunk.ChunkContainer.AddComponent <GroundHeight>(); } foreach (var v in chunk.Voxels) { v.Instance = Instantiate(PrefabDatabase.GetEntryById(v.PrefabId), chunk.ChunkContainer.transform); v.Instance.transform.localPosition = new Vector3(v.i, v.j, v.k); } //if (Elements.ChunkPlanePrefab != null) //{ // chunk.ChunkPlaneInstance = Instantiate(Elements.ChunkPlanePrefab, chunk.ChunkContainer.transform); // chunk.ChunkPlaneInstance.transform.localPosition = new Vector3(0, -0.5f, 0); // //chunk.ChunkPlaneInstance.transform.localScale = new Vector3(5, 1, 5); // chunk.ChunkPlaneInstance.transform.localScale = new Vector3(chunk.Length/10, 1, chunk.Length/10); // //chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureScale = new Vector2(50, 50); // chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureScale = new Vector2(chunk.Length, chunk.Length); // chunk.ChunkPlaneInstance.GetComponent<MeshRenderer>().material.mainTextureOffset = new Vector2(0.5f, 0.5f); //} }
private void Start() { points = new Vector3[Path.Locations.Length]; for (var i = 0; i < points.Length; i++) { points[i] = Path.Locations[i].ToVector3(); } spline = Misc.BuildSpline(Path.SplineType, points, SplineSampleSize, Path.Alpha); var sample = spline.SamplePoints(ObjectCount); for (var i = 0; i < sample.Length; i++) { var location = new Location() { Latitude = sample[i].z, Longitude = sample[i].x, Altitude = sample[i].y, AltitudeMode = AltitudeMode }; var instance = PlaceAtLocation.CreatePlacedInstance(Prefab, location, PlacementSettings, DebugMode); instance.name = $"{gameObject.name} - {i}"; } }
public void AddLocation(Location location) { var instance = PlaceAtLocation.CreatePlacedInstance(Prefab, location, PlacementOptions, DebugMode); instance.name = $"{gameObject.name} - {locations.Count}"; locations.Add(location); instances.Add(instance); }
/// <summary> /// 장애물 위치 조정후 콜백 함수 /// </summary> /// <param name="obj"></param> /// <param name="location"></param> /// <param name="count"></param> void ItemObjectUpdatedEvent(GameObject obj, ARLocation.Location location, int count) { ARLocation.PlaceAtLocation scriptA = obj.GetComponent <ARLocation.PlaceAtLocation>(); Destroy(scriptA); //ItemObjectController objSc = obj.GetComponent<ItemObjectController>(); //if (objSc.type.Equals("4") || objSc.type.Equals("5")) //{ // // Debug.Log("type-" + objSc.type + ", x-" + obj.transform.position.x + ", z-" + obj.transform.position.z); // obj.transform.rotation = Quaternion.Euler(new Vector3(-5, 33.3f, 0)); //} }
public void LoadLocationObjects(string message) { var opts = new PlaceAtLocation.PlaceAtOptions() { HideObjectUntilItIsPlaced = true, MaxNumberOfLocationUpdates = 0, MovementSmoothing = 0.05f, UseMovingAverage = false }; Debug.Log(message); var objects = JArray.Parse(message); foreach (JObject location in objects) { Debug.Log(location); double lat = double.Parse((string)location["location"]["latitude"]); double lng = double.Parse((string)location["location"]["longitude"]); JToken sensorData = location["data"]; var entry = new Location() { Latitude = lat, Longitude = lng, Altitude = 0, AltitudeMode = AltitudeMode.GroundRelative }; //Create Game object GameObject newGameObject = Instantiate(Resources.Load("POIPrefab")) as GameObject; newGameObject.transform.SetParent(this.transform); //Create 3D text TextMeshPro textMesh = newGameObject.GetComponentsInChildren <TextMeshPro>(true)[0]; foreach (JObject data in sensorData) { textMesh.text = textMesh.text + (string)data["name"] + ": " + "<color=yellow>" + (string)data["value"] + "</color>" + System.Environment.NewLine; } //Put new Game Object to the Scene PlaceAtLocation.AddPlaceAtComponent(newGameObject, entry, opts); gameObjects.Add(entry, newGameObject); Debug.Log($"{lat}, {lng}, {name}"); } }
void PlaceEntryAtLocation(Entry entry) { var prefab = PrefabDatabase.GetEntryById(entry.MeshId); if (prefab == null) { Debug.LogWarning($"Invalid prefab '{entry.MeshId}'"); return; } var location = entry.Location; var options = new PlaceAtLocation.PlaceAtOptions { }; entry.Instance = PlaceAtLocation.CreatePlacedInstance(prefab, location, options, false); entry.Instance.transform.localEulerAngles = new Vector3(0, entry.Rotation, 0); }
/// <summary> /// 배 위치 조정후 콜백 함수 /// </summary> /// <param name="obj"></param> /// <param name="location"></param> /// <param name="count"></param> void ObjectUpdatedEvent(GameObject obj, ARLocation.Location location, int count) { ARLocation.PlaceAtLocation scriptA = obj.GetComponent <ARLocation.PlaceAtLocation>(); Destroy(scriptA); ShipData shipData = obj.GetComponent <ShipObjectScript>().GetShipData(); float f = float.Parse(shipData.sog); _mapVC.SetShipMap(obj); //TODO: 여기서 미니맵 좌표 찍어줘야함. if (f > 0) { Vector2 newPs = SetNewPostion(obj.transform.position.x, obj.transform.position.z, shipData.regDate, shipData.sog, float.Parse(shipData.cog)); obj.transform.position = new Vector3(newPs.x, obj.transform.position.y, newPs.y); obj.GetComponent <ShipObjectScript>().SetFirstMoveCoroutineAction(); } else { return; } }
void BuildGameObjects() { foreach (var entry in _dataEntries) { var Prefab = PrefabDatabase.GetEntryById(entry.meshId); if (!Prefab) { Debug.LogWarning($"[ARLocation#WebMapLoader]: Prefab {entry.meshId} not found."); continue; } var PlacementOptions = new PlaceAtLocation.PlaceAtOptions() { MovementSmoothing = entry.movementSmoothing, MaxNumberOfLocationUpdates = entry.maxNumberOfLocationUpdates, UseMovingAverage = entry.useMovingAverage, HideObjectUntilItIsPlaced = entry.hideObjectUtilItIsPlaced }; var location = new Location() { Latitude = entry.lat, Longitude = entry.lng, Altitude = entry.altitude, AltitudeMode = entry.getAltitudeMode(), Label = entry.name }; var instance = PlaceAtLocation.CreatePlacedInstance(Prefab, location, PlacementOptions, DebugMode); _stages.Add(instance); } }