/// <summary> /// Use this to remove a waypoint from the path and from the scene /// </summary> /// <param name="deletedWaypoint"> The waypoint which is to be deleted </param> public void DeleteWaypoint(Waypoint deletedWaypoint) { //Sending a ROS DELETE Update string curr_id = deletedWaypoint.id; string prev_id = deletedWaypoint.prevPathPoint.id; float x = deletedWaypoint.gameObjectPointer.transform.localPosition.x; float y = deletedWaypoint.gameObjectPointer.transform.localPosition.y; float z = deletedWaypoint.gameObjectPointer.transform.localPosition.z; UserpointInstruction msg = new UserpointInstruction(curr_id, prev_id, x, y, z, "DELETE"); WorldProperties.worldObject.GetComponent <ROSDroneConnection>().PublishWaypointUpdateMessage(msg); // Removing the new waypoint from the dictionary, waypoints array and placement order waypointsDict.Remove(deletedWaypoint.id); waypoints.Remove(deletedWaypoint); waypointsOrder.Remove(deletedWaypoint); // Removing from the path linked list by adjusting the next and previous pointers of the surrounding waypoints deletedWaypoint.prevPathPoint.nextPathPoint = deletedWaypoint.nextPathPoint; // Need to check if this is the last waypoint in the list -- if it has a next or not if (deletedWaypoint.nextPathPoint != null) { deletedWaypoint.nextPathPoint.prevPathPoint = deletedWaypoint.prevPathPoint; } // Removing line collider WaypointProperties tempProperties = deletedWaypoint.gameObjectPointer.GetComponent <WaypointProperties>(); tempProperties.deleteLineCollider(); // Deleting the waypoint gameObject Object.Destroy(deletedWaypoint.gameObjectPointer); }
/// <summary> /// Use this to remove a waypoint from the path and from the scene /// </summary> /// <param name="deletedWaypoint"> The waypoint which is to be deleted </param> public void DeleteWaypoint(Waypoint deletedWaypoint) { // Removing the new waypoint from the dictionary, waypoints array and placement order waypoints.Remove(deletedWaypoint); deletedWaypoints.Add(deletedWaypoint); // Removing from the path linked list by adjusting the next and previous pointers of the surrounding waypoints. Check if first waypoint in the list. if (deletedWaypoint.prevPathPoint != null) { deletedWaypoint.prevPathPoint.nextPathPoint = deletedWaypoint.nextPathPoint; } // Need to check if this is the last waypoint in the list -- if it has a next or not if (deletedWaypoint.nextPathPoint != null) { deletedWaypoint.nextPathPoint.prevPathPoint = deletedWaypoint.prevPathPoint; } // Removing line collider WaypointProperties tempProperties = deletedWaypoint.gameObjectPointer.GetComponent <WaypointProperties>(); tempProperties.DeleteLineCollider(); // Deleting the waypoint gameObject Object.Destroy(deletedWaypoint.gameObjectPointer); }
/// <summary> /// Removes all waypoints from this drone (including the first one). /// </summary> // TODO: Fix @apollo do we still need to fix this? public void DeleteAllWaypoints() { if (!isEmptyWaypointList(waypoints)) { foreach (Waypoint waypoint in waypoints) { deletedWaypoints.Add(waypoint); WaypointProperties tempProperties = waypoint.gameObjectPointer.GetComponent <WaypointProperties>(); tempProperties.DeleteLineCollider(); Object.Destroy(waypoint.gameObjectPointer); } waypoints.Clear(); } }
public WaypointProperties waypointProperties; // Points to attached Waypoint Properties script /// <summary> /// Waypoint class object constructor /// </summary> /// <param name="myDrone"> This is the drone that the new waypoint should belong to (remember that you still need to add the waypoint to the path using this drone's methods) </param> /// <param name="position"> This is the 3d location at which the new waypoint gameObject should be placed. </param> public Waypoint(Drone myDrone, Vector3 position, bool takeoffWaypoint = false) { // Linking this waypoint to its drone referenceDrone = myDrone; // Setting up all the related gameObject parameters GameObject baseObject = (GameObject)WorldProperties.worldObject.GetComponent <WorldProperties>().waypointBaseObject; gameObjectPointer = Object.Instantiate(baseObject, position, Quaternion.identity); gameObjectPointer.GetComponent <VRTK_InteractableObject>().ignoredColliders[0] = GameObject.Find("controller_right").GetComponent <SphereCollider>(); //Ignoring Collider from Controller so that WayPoint Zone is used waypointProperties = gameObjectPointer.GetComponent <WaypointProperties>(); waypointProperties.classPointer = this; // Connect the gameObject back to the classObject gameObjectPointer.tag = "waypoint"; gameObjectPointer.name = baseObject.name; gameObjectPointer.transform.localScale = WorldProperties.actualScale / 100; gameObjectPointer.transform.parent = WorldProperties.worldObject.transform; WorldProperties.AddClipShader(gameObjectPointer.transform); }