本文整理汇总了C#中Vertex.addAdjVert方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.addAdjVert方法的具体用法?C# Vertex.addAdjVert怎么用?C# Vertex.addAdjVert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.addAdjVert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buildGraph
private List<Vertex> buildGraph(Vector3 start, Vector3 end)
{
//I can build the graph once in the future
List<Vertex> allVertices = new List<Vertex>();
int counter = 0;
double connectToStartDist = Double.MaxValue;
double connectToEndDist = Double.MaxValue;
Vertex connectToStart = null;
Vertex connectToEnd = null;
foreach (Transform t in transform) {
Waypoint w = t.gameObject.GetComponent<Waypoint>();
Vertex temp = new Vertex(w.location());
allVertices.Add (temp);
if(Vector3.Distance(start, w.location ()) < connectToStartDist) {
connectToStartDist = Vector3.Distance(start, w.location ());
connectToStart = temp;
}
if(Vector3.Distance(end, w.location ()) < connectToEndDist) {
connectToEndDist = Vector3.Distance(end, w.location ());
connectToEnd = temp;
}
}
//allVertices has all vertices in the graph
foreach (Transform t in transform) { //for each waypoint
Waypoint w = t.gameObject.GetComponent<Waypoint>();
foreach (Vector3 tempAdj in w.getAdjacent()) { //for each adjacent Vector3
foreach (Vertex vert in allVertices) {
if (vert.isSameLocation(tempAdj)) {
allVertices[counter].addAdjVert(vert);
break;
}
}
}
counter++;
}
startVertex = new Vertex(start);
endVertex = new Vertex(end);
startVertex.addAdjVert(connectToStart);
connectToEnd.addAdjVert(endVertex);
allVertices.Add(startVertex);
allVertices.Add(endVertex);
return allVertices;
}