/* * nowDestinationパラメータを変化させ、目標地点の変更を行う。removeとあるが実際にはListからは削除せず対象となる要素を変えるだけである。 */ public void removeNextDestination() { //tagList.RemoveAt (0); int index = tagList.FindIndex(x => x.nowDestination) + 1; TagPlacement pastDistination = tagList.Find(x => x.nowDestination); if (pastDistination != null) { pastDistination.isOnNavMesh = false; pastDistination.nowDestination = false; } if (index < tagList.Count) { tagList [index].nowDestination = true; } else { /*foreach(TagPlacement item in tagList){ * item.isOnNavMesh = true; * }*/ } if (tagList.Count == 0) { isExisting = false; } }
/* * HoloLens上のRoute(Routeオブジェクト)を逐次取得 * Routeオブジェクトにおいて次の目標地点を設定し、そこをDestinationとして設定 * HoloLensは基本的にDestinationと現在地点を歩行可能エリア上で最短で結びそれをローカル経路としている */ void Update() { route = mkRoute.getRoute(); //経路を逐次取得 if (route != null && mkPlane.makedPlane) //Routeがnullでない and 歩行可能エリアを計算するための床面推定がすんでいる { if (oldDestination != route.getNextDestination() || !oldDestination.isOnNavMesh) { //前回のDestinaitonが現在のDestinationと違っていたら(つまり、Destinationに到着するというプロセスが発生したら)。または、初めて設置するoldDestiantion(このループの中でoldDesitinationにnextDestinaitonが入るため、実質的にはnextDestination)が歩行可能エリアに設置できない時 //要約すると、Destiantionが置けないまたはDestinantionに到着した時このifに入る if (route.isFinished) //案内が終わっている場合、True { mkSounds.guidanceFinish = true; return; } this.transform.position = new Vector3(route.getNextDestination().getOriginToDestination().x, 0.0f, route.getNextDestination().getOriginToDestination().y); //Destinaitonは便宜的に円柱のオブジェクトになっているがそれの位置決定 oldDestination = route.getNextDestination(); //oldDestinaitonを更新 if (humanNav.reachedDestination()) { oldDestination.isOnNavMesh = true; //Destinaitonに到着した時、oldDestiantionのisOnNavMeshをtrueにしてoldDestiantionが更新されるようにする } else { oldDestination.isOnNavMesh = false; } } } else { route = mkRoute.getRoute(); } }
/* * 次の目標地点を返す */ public TagPlacement getNextDestination() { if (tagList.FindIndex(x => x.nowDestination) + 1 < tagList.Count) { var i = tagList [tagList.FindIndex(x => x.nowDestination) + 1]; return(i); } isFinished = true; var tmp = new TagPlacement(0.0f, 0.0f); tmp.isOnNavMesh = true; return(tmp); }
/* * nowDestinaitonの属性が付けられ最初の目標地点となる。このメソッドは、経路の先頭のTagPlacementに対してのみ使う。 */ public void setRouteOriginVec(TagPlacement p) { p.nowDestination = true; tagList.Insert(0, p); }
/* * 経路にTagPlacement tを追加する。 */ public void setTagPlacement(TagPlacement t) { isExisting = true; tagList.Add(t); setOriginVec(tagList.LastIndexOf(t)); }