public WalkerSave(GameObject go) : base(go) { Walker w = go.GetComponent <Walker>(); //save origin and destination as coordinates Structure o = w.Origin; if (o != null) { origin = new Node(o.X, o.Y); } Structure d = w.Destination; if (d != null) { destination = new Node(d.X, d.Y); } prevx = w.Prevx; prevy = w.Prevy; laborPoints = w.LaborPoints; movementDistance = w.MovementDistance; stuck = w.Stuck; returningHome = w.ReturningHome; direction = new Node3d(w.Direction); order = w.Order; path = w.Path; visitedSpots = w.VisitedSpots; }
public bool IsNeighbor(Node3d input) { if (!IsPositionEqualTo (input)) { int distX = Mathf.Abs (this.gridX - input.gridX); int distY = Mathf.Abs (this.gridY - input.gridY); int distZ = Mathf.Abs(this.gridZ - input.gridZ); return (distX + distY+distZ) <= 3; } return false; }
public ObjSave(GameObject go) { Vector3 pos = go.transform.position; Vector3 rot = go.transform.eulerAngles; position = new Node3d(pos); rotation = new Node3d(rot); tag = go.tag; name = go.name; Obj mo = go.GetComponent <Obj>(); location = new Node(mo.X, mo.Y); resourcePath = mo.resourcePath; rightclick = mo.rightclick; }
void CreateGrid() { grid = new Node3d[gridX, gridY, gridZ]; Vector3 worldBottomLeft = transform.position - Vector3.right * gridSize.x / 2 - Vector3.forward * gridSize.y / 2 - Vector3.up * gridSize.z / 2; for (int x = 0; x < gridX; x++) { for (int y = 0; y < gridY; y++) { for (int z = 0; z < gridZ; z++) { Vector3 worldPoint = worldBottomLeft + Vector3.right * (x * nodeDiameter + nodeRadius) + Vector3.forward * (y * nodeDiameter + nodeRadius) + Vector3.up * (z * nodeDiameter + nodeRadius); bool walkable = (Physics.CheckSphere (worldPoint, nodeRadius, walkableMask)); if (Physics.CheckSphere (worldPoint, nodeRadius, unwalkableMask)) { walkable = false; } grid [x, y, z] = new Node3d (walkable, worldPoint, x, y, z); } } } }
public List<Node3d> GetNeighbors(Node3d node) { List<Node3d> neighbors = new List<Node3d> (); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { for (int z = -1; z <= 1; z++) { //check if it's origin if (x == 0 && y == 0) continue; int checkX = node.gridX + x; int checkY = node.gridY + y; int checkZ = node.gridZ + z; if (checkX >= 0 && checkX < gridX && checkY >= 0 && checkY < gridY && checkZ >= 0 && checkZ < gridZ) { neighbors.Add (grid [checkX, checkY, checkZ]); } } } } return neighbors; }
public static List <PointIndex> CullClosestPoints(List <Point3d> points, List <RFNode> existingNodes, ref int lastNodeIndex, double tol) { var outPoints = new List <PointIndex>(); BoundingBox empty = BoundingBox.Empty; // Create PointIndexes var existingPointIndices = new List <PointIndex>(points.Count); for (int i = 0; i < existingNodes.Count; i++) { PointIndex pointIndex = new PointIndex(); pointIndex.Index = existingNodes[i].No; pointIndex.Point = existingNodes[i].Location; existingPointIndices.Add(pointIndex); empty.Union(pointIndex.Point); } var list2 = new List <PointIndex>(points.Count); for (int i = 0; i < points.Count; i++) { PointIndex pointIndex = new PointIndex(); pointIndex.Index = -1; pointIndex.Point = points[i]; list2.Add(pointIndex); empty.Union(pointIndex.Point); } empty.Inflate(tol); Node3d <PointIndex> val = new Node3d <PointIndex>((Coordinates3d <PointIndex>)PointIndexCoordinates, empty, 30); int firstItem = 0; if (existingNodes.Count > 0) { val.AddRange(existingPointIndices); // list to compare points to } else { var node = list2[0]; node.Index = 1; firstItem = 1; lastNodeIndex = 1; val.Add(node); // list to compare points to outPoints.Add(node); } for (int j = firstItem; j <= list2.Count - 1; j++) { PointIndex pointIndex2 = list2[j]; while (true) { Index3d <PointIndex> val2 = val.NearestItem(pointIndex2); if (val2 == null) { lastNodeIndex++; pointIndex2.Index = lastNodeIndex; val.Add(pointIndex2); outPoints.Add(pointIndex2); break; } PointIndex item = val2.Item; double num4 = pointIndex2.Point.DistanceTo(item.Point); if (num4 > tol || double.IsNaN(num4)) { lastNodeIndex++; pointIndex2.Index = lastNodeIndex; val.Add(pointIndex2); outPoints.Add(pointIndex2); break; } pointIndex2.Point = Point3d.Unset; pointIndex2.Index = val2.Item.Index; outPoints.Add(pointIndex2); break; } List <PointIndex> itemsGlobal = val.ItemsGlobal; } return(outPoints); }
public CameraSave(CameraController cc) { position = new Node3d(cc.transform.position); rotation = new Node3d(cc.transform.eulerAngles); }
public override bool Equals(System.Object obj) { Node3d n = obj as Node3d; return(X == n.X && Y == n.Y && Z == n.Z); }
public bool IsPositionEqualTo(Node3d input) { return (input.gridX == this.gridX) && (input.gridY == this.gridY) && (input.gridZ == this.gridZ); }
public ValuedPoint(Node3d <double> position) : base(position) { Value = position.Z; }
doProcessFigures() { bool exists = false; ObjectId idDictHist = Dict.getNamedDictionary("HISTORY", out exists); if (exists) { bool def = true; bool answer = false; PromptStatus ps = UserInput.getUserInputYesNo("Command PF has been executed on this drawing - Continue?", def, out answer); if (ps == PromptStatus.OK) { if (answer == false) { return; } } else { return; } } if (BaseObjs._acadDocs.Count > 4) { bool def = false; bool answer = false; PromptStatus ps = UserInput.getUserInputYesNo(string.Format("There are {0} drawings open on this machine. Do you wish to continue?", BaseObjs._acadDocs.Count.ToString()), def, out answer); if (ps == PromptStatus.OK) { if (answer == false) { return; } } else { return; } } string JN = string.Empty; string TOP = string.Empty; string nameFile = string.Empty; string nameFileMod = string.Empty; ResultBuffer rb = null; ObjectId idDictPPF2 = Dict.getNamedDictionary("PPF2", out exists); if (!exists) { Application.ShowAlertDialog("Dictionary PPF2 is missing - Breaklines will be named \'TEMP\'"); string nameFull = BaseObjs.docFullName; JN = BaseObjs.docName.Substring(0, 4); TOP = "TEMP"; } else { using (BaseObjs._acadDoc.LockDocument()) { rb = Dict.getXRec(idDictPPF2, "strTOP"); } TypedValue[] tvs = rb.AsArray(); if (tvs.Length > 0) { JN = tvs[0].Value.ToString(); TOP = tvs[1].Value.ToString(); nameFile = tvs[2].Value.ToString(); nameFileMod = tvs[3].Value.ToString(); } } AeccSurveyDocument survDoc = BaseObjsCom.aeccSurvDoc; AeccSurveyProjects survProjs = survDoc.Projects; AeccSurveyProject survProj = null; try { foreach (AeccSurveyProject sProj in survProjs) { if (sProj.Name == JN) { survProj = sProj; survProj.Open(); break; } } } catch (System.Exception ex) { //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 146"); BaseObjs.writeDebug(ex.Message + " PF.cs: line: 146"); } AeccSurveyFigures survFigures = survProj.Figures; List <ObjectId> idPolys3d = new List <ObjectId>(); List <Node3d> nodes3d = new List <Node3d>(); foreach (AeccSurveyFigure figure in survFigures) { AeccSurveyFigureNodes nodes = figure.FigureNodes; foreach (AeccSurveyFigureNode node in nodes) { Node3d node3d = new Node3d(node.X, node.Y, node.Z, node.Bulge); nodes3d.Add(node3d); } ObjectId idPoly3d = buildPoly3dFromNodes(nodes3d); Layer.setLayer(idPoly3d, figure.Layer); idPolys3d.Add(idPoly3d); } survProj.Close(); TransferObjs.transferObjects(idPolys3d, TemplateCONT, nameFileMod); TransferObjs.transferObjects(idPolys3d, TemplateTOPO, nameFile); string handleLastEnt = string.Empty; try { handleLastEnt = idPolys3d[idPolys3d.Count - 1].getHandle().ToString(); } catch (System.Exception ex) { //Application.ShowAlertDialog(ex.Message + " PF.cs: line: 176"); BaseObjs.writeDebug(ex.Message + " PF.cs: line: 176"); } CgPnt_Group.deletePntGroup(Path.GetFileName(nameFileMod)); rb = new ResultBuffer(new TypedValue(1005, handleLastEnt)); Dict.addXRec(idDictHist, "lastENT", rb); }
void Update() { if (calculatePaths) { CalcOnePathPerFrame (); } currentTargetNode = grid.NodeFromWorldPoint (target.position); if (previousTargetNode != null) { //if current target node != previous target node, then calculate all paths if (!currentTargetNode.IsPositionEqualTo (previousTargetNode) && currentTargetNode.walkable) { calculatePaths = true; //CalculateAllPaths (); } // if (!currentTargetNode.IsNeighbor (previousTargetNode)) // previousTargetNode = currentTargetNode; } // else { previousTargetNode = currentTargetNode; // } }
void RetracePath(Node3d startNode, Node3d endNode, int x) { List<Node3d> path = new List<Node3d> (); Node3d currentNode = endNode; while (currentNode != startNode) { path.Add (currentNode); currentNode = currentNode.parent; } path.Reverse (); grid.paths [x] = path; seekerMoveControllers [x].SetPath3d (path); }
int GetDistance(Node3d nodeA, Node3d nodeB) { int diffX = nodeA.gridX - nodeB.gridX; int diffY = nodeA.gridY - nodeB.gridY; int diffZ = nodeA.gridZ - nodeB.gridZ; return Mathf.FloorToInt (Mathf.Sqrt (diffX * diffX + diffY * diffY + diffZ * diffZ)); }