public static GameObject MakeNewLinkGo(RouteMan rman, LcLink link, float linkRadius, string cname) { var go = new GameObject(); var linkgo = go.AddComponent <LinkGo>(); linkgo.rman = rman; linkgo.link = link; linkgo.name = link.name; linkgo.linkName = link.name; linkgo.nodeName1 = link.node1.name; linkgo.nodeName2 = link.node2.name; go.name = link.name; // + "-go"; var p1 = link.node1.pt; var p2 = link.node2.pt; var midpt = (p1 + p2) / 2; go.transform.localPosition = midpt; var pcyl = GraphUtil.CreatePipe(link.name, p1, p2, linkRadius, cname); if (rman != null && rman.garnish != RouterGarnishE.none) { var text = link.name; var anglat = GraphUtil.GetAngLatDegrees(p1, p2); GraphUtil.addFloatingTextStatic(go, midpt, text + " ang:" + anglat, cname, anglat + 90); } pcyl.transform.parent = go.transform; return(go); }
public static GameObject MakeLinkGo(SceneMan sman, LcLink link, float linkRadius, string clrname, float alf, bool flatlink = false) { var go = new GameObject(); var linkgo = go.AddComponent <LinkGo>(); linkgo.sman = sman; linkgo.link = link; linkgo.name = link.name; linkgo.linkName = link.name; linkgo.nodeName1 = link.node1.name; linkgo.nodeName2 = link.node2.name; //linkgo.node1 = link.node1.go.GetComponent<NodeGo>(); //linkgo.node2 = link.node2.go.GetComponent<NodeGo>(); go.name = link.name; // + "-go"; var p1 = link.node1.pt; var p2 = link.node2.pt; var midpt = (p1 + p2) / 2; go.transform.localPosition = midpt; GameObject linkcyl; if (flatlink) { linkcyl = GraphUtil.CreateFlatPipe(link.name, p1, p2, linkRadius, clrname, alf); } else { linkcyl = GraphUtil.CreatePipe(link.name, p1, p2, linkRadius, clrname, alf); } if (sman != null && sman.garnish != RouteGarnishE.none) { var text = link.name; var anglat = GraphUtil.GetAngLatDegrees(p1, p2); GraphUtil.addFloatingTextStatic(go, midpt, text + " ang:" + anglat, clrname, anglat + 90); } linkcyl.transform.parent = go.transform; return(go); }
void CreatePathGos() { if (_path == null) { return; // nothing to do } DeletePathGos(); if (pathgo == null) { pathgo = new GameObject("Path-" + gogeninst); gogeninst++; } pathgo.transform.parent = sman.rgo.transform; int i = 0; int ilast = path.waypts.Count - 1; var lclr = sman.getcolorname(SceneMan.RmColorModeE.pathlink); var nclr = sman.getcolorname(SceneMan.RmColorModeE.pathnode); foreach (var w in _path.waypts) { var lnk = w.link; string wname = "way:" + i + " (" + lnk.name + ")"; if (visible) { var pathcyl = GraphUtil.CreatePipe(wname, lnk.node1.pt, lnk.node2.pt, pathRadius, clr: lclr); pathcyl.transform.parent = pathgo.transform; if (i != ilast) { var mkname = "pathsph-" + pathsphcnt; var psph = GraphUtil.CreateMarkerSphere(mkname, w.toNode.pt, size: pathNodeSize, clr: nclr); psph.transform.parent = pathgo.transform; w.toNode.transform = pathgo.transform; //RegionMan.Log("path point i:" + i +" w.tolpt.pt:"+w.tolpt.pt+ " w.tolpt.ptwc:" + w.tolpt.ptwc); } if (showNearestWegPoints) { var npt = w.link.FindClosestPointOnLink(nearestPointRef); var nname = "nearsph-" + pathsphcnt; var pnsph = GraphUtil.CreateMarkerSphere(nname, npt, size: 1.5f * pathNodeSize, clr: "orange"); pnsph.transform.parent = pathgo.transform; } } i++; pathsphcnt++; } if (showNearestPathPoint) { float pathdst = 0; FindClosestPointOnPath(nearestPointRef, out pathdst); var pp = path.MovePositionAlongPath(pathdst); var nspwc = sman.rgo.transform.TransformPoint(pp.pt); var nname = "nearpathsph"; //RegionMan.Log("pp pp.pt:" + pp.pt + " pp.ptwc:" + pp.ptwc); var go = new GameObject(); go.name = nname + "-go"; go.transform.position = nspwc; var cname = "lilac"; var pnsph = GraphUtil.CreateMarkerSphere(nname, nspwc, size: 1.1f * pathNodeSize, clr: cname); if (sman != null) { // if (sman.garnish != RouterGarnishE.none || sman.statusctrl.outMode != StatusCtrl.outModeE.geninfo) if (sman.garnish != RouteGarnishE.none) { //RegionMan.Log("Adding text"); addFloatingText(go, nspwc, "Hello Sphere", cname, yrot: 0, yoff: 1.1f); } } pnsph.transform.parent = go.transform; go.transform.parent = pathgo.transform; } }