public void createPathPoint(Transform pos) { point = new Point(pos); wp = new WaypointUpdateParameters(); Gb = new GimballParameters(); Rc = new RecCamParameters(); wp.gimbal_parameters = Gb; wp.reccam_parameters = Rc; wp.gimbal_parameters.id_pointer = Id; wp.reccam_parameters.id_pointer = Id; }
public void createPathPointWithPoint(Point pos, int gbId, int rcId) { point = pos; gbId = 0; rcId = 0; wp = new WaypointUpdateParameters(); Gb = new GimballParameters(); Rc = new RecCamParameters(); wp.gimbal_parameters = Gb; wp.reccam_parameters = Rc; Gb.id_pointer = gbId; Rc.id_pointer = rcId; }
public void copyPoint(Point secondPoint, GimballParameters gbParam, RecCamParameters rcParam, Transform transf) { point.PointTransf1 = transf; point.Speed = secondPoint.Speed; if (gbParam != null) { Gb.poi_or_angles = gbParam.poi_or_angles; Gb.mode = gbParam.mode; Rc.resolution = rcParam.resolution; // ## Necesitamos saber resoluciones mínimas y/o máximas Rc.brightness = rcParam.brightness; } point.setPointType(secondPoint.getPointType()); point.id = secondPoint.Id; point.SegmentsTop = secondPoint.SegmentsTop; point.SegmentsRight = secondPoint.SegmentsRight; point.Poi1 = secondPoint.Poi; }
/// <summary> /// This function assigns the reccam parameters saved to a waypoint /// </summary> /// <param name="rc"> The reccamparameters to assign</param> /// <param name="point">Waypoint that will get reccam parameters assigned</param> void reSetRecCamGuis(RecCamParameters rc, PathPoint point) { //This switch is based on messagecodes RCamCommandType for (int i = 0; i < rc.reccam_parameters.Count; i++) { switch (rc.reccam_parameters[i].array[0]) { case 6: point.Rc.active = true; point.Rc.switchToRec = 1; break; case 7: point.Rc.active = true; point.Rc.switchToRec = 0; break; case 9: point.Rc.active = true; point.Rc.switchToRec = 1; break; case 10: point.Rc.active = false; break; case 11: point.Rc.active = true; point.Rc.switchToRec = 0; break; case 12: point.Rc.active = true; point.Rc.switchToRec = 0; break; case 17: //This switch is based on RCamConfigParameter switch (rc.reccam_parameters[i].array[1]) { case 0: point.Rc.resolution = (rc.reccam_parameters[i].array[2]); break; case 1: point.Rc.megaPixels = rc.reccam_parameters[i].array[2]; break; case 2: point.Rc.autoManualWB = rc.reccam_parameters[i].array[2]; break; case 54: point.Rc.WBTint = rc.reccam_parameters[i].array[2]; break; case 3: point.Rc.ISO = rc.reccam_parameters[i].array[2]; break; case 4: point.Rc.sharpness = rc.reccam_parameters[i].array[2]; break; case 5: point.Rc.contrast = new byte[] { rc.reccam_parameters[i].array[2], rc.reccam_parameters[i].array[3], rc.reccam_parameters[i].array[4], rc.reccam_parameters[i].array[5] }; break; case 6: point.Rc.AE = rc.reccam_parameters[i].array[2]; break; case 12: point.Rc.AF = 1; break; case 14: point.Rc.saturation = new byte[] { rc.reccam_parameters[i].array[2], rc.reccam_parameters[i].array[3], rc.reccam_parameters[i].array[4], rc.reccam_parameters[i].array[5] }; break; case 15: point.Rc.brightness = new byte[] { rc.reccam_parameters[i].array[2], rc.reccam_parameters[i].array[3], rc.reccam_parameters[i].array[4], rc.reccam_parameters[i].array[5] }; break; case 17: point.Rc.photoQuality = rc.reccam_parameters[i].array[2]; break; case 19: point.Rc.upsideDown = rc.reccam_parameters[i].array[2]; break; case 21: point.Rc.irisAperture = rc.reccam_parameters[i].array[2]; break; case 36: point.Rc.burstMode = rc.reccam_parameters[i].array[2]; break; case 64: point.Rc.burstSpeed = rc.reccam_parameters[i].array[2]; break; default: break; } break; case 32: point.Rc.active = true; point.Rc.switchToRec = 0; break; case 33: point.Rc.active = false; break; default: break; } } point.Rc.edited = true; }
/// <summary> /// This is the main fucntion that loads the map and the plan waypoints /// </summary> /// <param name="path"></param> void LoadMap(string path) { //We load the main path if (ownPath == null) { ownPath = Path.Instance; } //laod the metadata string json = System.IO.File.ReadAllText(path); MapMetadata metadata = JsonUtility.FromJson <MapMetadata>(json); UnityEngine.Debug.Log("Loading map"); BinaryFormatter bFormatter = new BinaryFormatter(); //if (!AskForMap()) // return; FileStream file; //If it is a pointcloud we load a pointcloud map, and if it isn't a collada if (metadata.Map_type == (byte)MapMetadata.MapType.PointCloud) { file = File.OpenRead(Application.persistentDataPath + "/PersistentData/Maps/" + MissionManager.guid + ".dpl.map"); } else { file = File.OpenRead(Application.persistentDataPath + "/PersistentData/Maps/" + MissionManager.guid + ".dae.map"); } //var xmlWriter = new XmlTextWriter(file, Encoding.UTF8); //xmlWriter. XmlDocument doc = new XmlDocument(); string aux; GameObject auxGameObject = new GameObject(); UnityEngine.Debug.Log(MissionManager.invMatrix); //An empty box and a 3d model are the same if (metadata.Map_type == (byte)MapMetadata.MapType.EmptyBox) { using (StreamReader reader = new StreamReader(file)) { aux = reader.ReadToEnd(); } doc.LoadXml(aux); ColladaImporter importer = new ColladaImporter(ref auxGameObject); StartCoroutine(importer.getMesh(doc, cullBackShader)); } else if (metadata.Map_type == (byte)MapMetadata.MapType.Model3D) { using (StreamReader reader = new StreamReader(file)) { aux = reader.ReadToEnd(); } doc.LoadXml(aux); ColladaImporter importer = new ColladaImporter(ref auxGameObject); StartCoroutine(importer.getMesh(doc, shader)); }//But pointclouds are loaded different else { //MapLoader used in mapalignment uses this exact function and they are already explained there createBaseTriangle(); byte[] pclBytes = File.ReadAllBytes(Application.persistentDataPath + "/PersistentData/Maps/" + MissionManager.guid + ".dpl.map"); GameObject daeModel = new GameObject(); daeModel.name = "DaeModel"; daeModel.transform.parent = auxGameObject.transform; LoadPointCloud(pclBytes, ref daeModel); //SavedPointCloud pointCloud = JsonUtility.FromJson<SavedPointCloud>(aux); // //for (int i = 0; i < pointCloud.PointCloud.Count; i++) //{ // // GameObject gameObject = Instantiate(pcPrefab, auxGameObject.transform); // gameObject.GetComponent<MeshFilter>().sharedMesh = new Mesh(); // gameObject.GetComponent<MeshFilter>().sharedMesh.name = "cmesh" + i.ToString(); // gameObject.GetComponent<MeshFilter>().mesh.vertices = pointCloud.PointCloud[i].vertex; // int[] indices = new int[pointCloud.PointCloud[i].vertex.Length]; // Color[] colors = new Color[indices.Length]; // for (int j = 0; j < pointCloud.PointCloud[i].vertex.Length; j++) // { // indices[j] = j; // colors[j] = new Color(pointCloud.PointCloud[i].colors[j].x, pointCloud.PointCloud[i].colors[j].y, pointCloud.PointCloud[i].colors[j].z, 1); // } // gameObject.GetComponent<MeshFilter>().mesh.colors = colors; // gameObject.GetComponent<MeshFilter>().mesh.RecalculateNormals(); // gameObject.GetComponent<MeshFilter>().mesh.SetIndices(indices, MeshTopology.Triangles, 0, true); // gameObject.GetComponent<MeshFilter>().mesh.RecalculateBounds(); // Matrix4x4 auxMat = pointCloud.PointCloud[i].matrix; // gameObject.transform.rotation = auxMat.rotation; // gameObject.transform.position = new Vector3(auxMat.m03, auxMat.m13, auxMat.m23); // // //} } //Once the maps are loaded, we start with the waypoints. First a mission is loaded auxGameObject.name = "DaemodelChild"; string mapJson = File.ReadAllText(Application.persistentDataPath + "/PersistentData/Missions/" + MissionManager.guid + ".json.mission"); Map map = JsonUtility.FromJson <Map>(mapJson); Path waypointPath = Path.Instance; //sphereParentGO.transform.position = auxGameObject.transform.position; //If this isn't a new plan, we load the plan selected previously if (MissionManager.planIndex != -1) { //Here we get a plan from all the paths saved in missionmanager waypointPath = map.Paths[MissionManager.planIndex]; ownPath.setPath(waypointPath); //And give them the default parameters previously selected MissionManager.planDefaultHeight = waypointPath.FlightParams.height; MissionManager.planDefaultSpeed = waypointPath.FlightParams.speed; MissionManager.planDefaultDuration = waypointPath.FlightParams.duration; //Here we instantiate the waypoints for (int i = 0; i < waypointPath.Count(); i++) { //waypointPath.GetPoint(i).PointPosition = new Vector3(waypointPath.GetPoint(i).PointPosition.x, waypointPath.GetPoint(i).PointPosition.z, waypointPath.GetPoint(i).PointPosition.y); GameObject auxPoint = Instantiate(pointGO, waypointPath.GetPoint(i).PointPosition, Quaternion.Euler(0, 0, 0), sphereParentGO.transform); //assign them the transform to the script waypointPath.GetPoint(i).PointTransf = auxPoint.transform; auxPoint.SetActive(true); //Scale it TransformSphere(topCam, auxPoint); //And if it is the first one, we assign it the yellow colour, and to the last one, the green colour. The rest use the normal waypoint colour if (i == 0) { auxPoint.transform.GetChild(0).GetComponent <Renderer>().sharedMaterial = homeNotSelectedMaterial; //auxPoint.transform.GetChild(1).GetComponent<Renderer>().sharedMaterial.color = Color.white; } else if (i != waypointPath.Count() - 1) { auxPoint.transform.GetChild(0).GetComponent <Renderer>().sharedMaterial = waypointNotSelectedMaterial; // auxPoint.transform.GetChild(1).GetComponent<Renderer>().sharedMaterial.color = Color.white; //auxPoint.transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = whiteOutlineMaterial; //auxPoint.transform.GetChild(1).GetComponent<Renderer>().sharedMaterial = whiteOutlineMaterial; } else { //auxPoint.transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = landingMaterial; //auxPoint.transform.GetChild(1).GetComponent<Renderer>().sharedMaterial = landingMaterial; auxPoint.transform.GetChild(0).GetComponent <Renderer>().sharedMaterial = landingNotSelectedMaterial; //auxPoint.transform.GetChild(1).GetComponent<Renderer>().sharedMaterial.color = Color.white; } //We assign the monobehaviour that contains the point parameters auxPoint.AddComponent <PathPoint>().createPathPointWithPoint(waypointPath.GetPoint(i), 0, 0); } //here we create the middlepoints that the curve contains for (int i = 0; i < waypointPath.Count() - 1; i++) { lineMat.SetPass(0); if (topCam != null) { CatmullRomSpline.DisplayCatmullRomSpline2(waypointPath, i, ref waypointPath.middlePointsTop, topCam.orthographicSize / 2.0f, true, topCam); } if (frontCam != null) { CatmullRomSpline.DisplayCatmullRomSpline(waypointPath, i, ref waypointPath.middlePointsRight, frontCam.orthographicSize / 2.0f, true, frontCam); } } //This script is also used on recording, where we don't want points of interests. We adjust the path to the adjustmnets doen in model alignment and exit if (GeneralSceneManager.sceneState == GeneralSceneManager.SceneState.Recording) { sphereParentGO.transform.position = new Vector3(map.unityToAnchors.m03 * 0.001f, map.unityToAnchors.m23 * 0.001f, map.unityToAnchors.m13 * 0.001f); sphereParentGO.transform.localScale = new Vector3(map.unityToAnchors.m00 * 0.001f, map.unityToAnchors.m11 * 0.001f, map.unityToAnchors.m22 * 0.001f); return; } //If not we create the points of interest poisCreated = new List <GameObject>(); for (int i = 0; i < waypointPath.wpParametersCount(); i++) { //for each waypoint of interest that the path contains, we assign it to the respective waypoint GimballParameters auxGimballUpdateParameters = waypointPath.getGbUpdateParameter(i); Point auxPoint = waypointPath.GetPoint(auxGimballUpdateParameters.id_pointer); auxPoint.PointTransf.gameObject.GetComponent <PathPoint>().Wp.gimbal_parameters = auxGimballUpdateParameters; //And now depending on the type of point of interest, one behaviour is assigned. It can be a look at point, look at the curve, //locked in yaw only while looking in a direction or looking in a direction without locks switch (auxGimballUpdateParameters.mode) { case 0: GameObject newpoi; //First we search for a POI System.Predicate <GameObject> predicate = (GameObject p) => { return(p.transform.position == auxGimballUpdateParameters.poi_or_angles); }; //If one POI has been placed at least if (poisCreated.Count > 0) { //we find if the POI was already there, just in case multiple waypoints share the same POI newpoi = poisCreated.Find(predicate); if (newpoi == null) { newpoi = Instantiate(poi, auxGimballUpdateParameters.poi_or_angles, Quaternion.Euler(new Vector3(0, 0, 0))); poisCreated.Add(newpoi); newpoi.AddComponent <POI>(); } } else { newpoi = Instantiate(poi, auxGimballUpdateParameters.poi_or_angles, Quaternion.Euler(new Vector3(0, 0, 0))); poisCreated.Add(newpoi); newpoi.AddComponent <POI>(); } //We create a new line that points from the POI to the waypoint. The poi object already has one, but if there is more than one waypoint //related to the POI, we need to create more lines GameObject newLine = newpoi.transform.GetChild(2).gameObject; if (i > 0) { newLine = Instantiate(poi.transform.GetChild(2).gameObject, newpoi.transform.position, Quaternion.Euler(new Vector3(0, 0, 0)), newpoi.transform); } //All of this calculate the rotation, position and size of the line Vector3 centerPos = new Vector3(auxPoint.PointTransf.position.x + newpoi.transform.position.x, auxPoint.PointTransf.position.y + newpoi.transform.position.y, auxPoint.PointTransf.position.z + newpoi.transform.position.z) / 2f; float scaleX = Mathf.Abs((auxPoint.PointTransf.position - newpoi.transform.position).magnitude); newLine.transform.localScale = new Vector3(scaleX, 3f, 3f); //Esto es para rotar las imagenes de las camaras que tienen cada Waypoint Transform cube = auxPoint.PointTransf.Find("CubeTop"); cube.gameObject.SetActive(true); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from = new Vector2(-1, 0); Vector3 aux2 = newpoi.transform.position - auxPoint.PointTransf.position; Vector2 to = new Vector2(aux2.x, aux2.z).normalized; float angle = Vector2.SignedAngle(from, to); Transform cube2 = auxPoint.PointTransf.Find("CubeFront"); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from2 = new Vector2(-1, 0); Vector3 aux3 = newpoi.transform.position - auxPoint.PointTransf.position; Vector2 to2 = new Vector2(aux3.x, aux3.y).normalized; float angle2 = Vector2.SignedAngle(from2, to2); //float angle = Mathf.Acos(distance2 / distance); //item.transform.Rotate(new Vector3(0, 1, 0), Vector2.Angle(from, to)); cube.transform.rotation = Quaternion.Euler(new Vector3(0, -angle, 0)); cube2.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle2)); cube.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; cube2.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; auxPoint.PointTransf.GetComponent <PathPoint>().Poi = newpoi.transform; newpoi.GetComponent <POI>().addPoint(auxPoint.PointTransf.GetComponent <PathPoint>(), newLine); //UnityEngine.Debug.Log(newpoi.GetComponent<POI>().Referenced.Count); float sineC = (auxPoint.PointTransf.position.y - newpoi.transform.position.y) / scaleX; newLine.transform.rotation = Quaternion.Euler(0, -angle, Mathf.Asin(sineC) * Mathf.Rad2Deg); newLine.transform.position = newpoi.transform.position; var rotation = Quaternion.Euler(0, -angle, Mathf.Asin(sineC) * Mathf.Rad2Deg).eulerAngles; auxPoint.PointTransf.GetComponent <PathPoint>().GimbalRotation = new Vector3(rotation.z, rotation.y, rotation.x + 90); auxPoint.PointTransf.GetComponent <PathPoint>().getGimballMode = 0; TransformSphere(topCam, newpoi); break; case 1: //This is the case where the direction will always point to the curve float angle3 = 0; float angle4 = 0; int middlePointsIndexTop = 0; int middlePointsIndexRight = 0; //We iterate through the array to see the closest point from the curve to the waypoint. The signal that indicates this mode is activated is a green camera looking at that point on the waypoint. for (i = 0; i < waypointPath.Count(); i++) { if (waypointPath.GetPoint(i) == auxPoint) { break; } middlePointsIndexTop += waypointPath.GetPoint(i).SegmentsTop; middlePointsIndexRight += waypointPath.GetPoint(i).SegmentsRight; } //If this is the last point, there is no curve to look at anymore if (middlePointsIndexRight >= waypointPath.middlePointsRight.Count) { break; } //Now from here we calculate the rotation of the camera mentioned above Vector3 pointRight = waypointPath.middlePointsRight[middlePointsIndexRight]; Vector3 pointTop = waypointPath.middlePointsTop[middlePointsIndexTop]; //Esto es para rotar las imagenes de las camaras que tienen cada Waypoint Transform cube3 = auxPoint.PointTransf.Find("CubeTop"); cube3.gameObject.SetActive(true); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from3 = new Vector2(-1, 0); Vector3 aux4 = pointTop - auxPoint.PointTransf.position; Vector2 to3 = new Vector2(aux4.x, aux4.z).normalized; angle3 = Vector2.SignedAngle(from3, to3); Transform cube4 = auxPoint.PointTransf.Find("CubeFront"); cube4.gameObject.SetActive(true); cube3.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.green; cube4.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.green; //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from4 = new Vector2(-1, 0); Vector3 aux5 = pointRight - auxPoint.PointTransf.position; Vector2 to4 = new Vector2(aux5.x, aux5.y).normalized; angle4 = Vector2.SignedAngle(from4, to4); //float angle = Mathf.Acos(distance2 / distance); //item.transform.Rotate(new Vector3(0, 1, 0), Vector2.Angle(from, to)); cube3.transform.rotation = Quaternion.Euler(new Vector3(0, -angle3, 0)); cube4.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle4)); //UnityEngine.Debug.Log(newpoi.GetComponent<POI>().Referenced.Count); break; case 2: //This mode is for a direction with the yaw? locked //We only show a line in this mode, so even if we instantiate a poi, is not shown GameObject newpoi2 = Instantiate(poi, auxGimballUpdateParameters.poi_or_angles + auxPoint.PointTransf.position, Quaternion.Euler(new Vector3(0, 0, 0))); //UnityEngine.Debug.Log(" POI POS: " + auxGimballUpdateParameters.poi_or_angles + " ITEM POS: " + auxPoint.PointTransf.position); /* * if (Input.mousePosition.x < Camera.main.pixelWidth / 2) * { * newpoi.transform.position = new Vector3(newpoi.transform.position.x, 0, newpoi.transform.position.z); * * } * else * { * newpoi.transform.position = new Vector3(newpoi.transform.position.x, newpoi.transform.position.y, 1); * * }*/ newpoi2.SetActive(true); newpoi2.transform.GetChild(0).gameObject.SetActive(false); newpoi2.transform.GetChild(1).gameObject.SetActive(false); newpoi2.AddComponent <POI>(); newpoi2.GetComponent <POI>().Direction = true; float angle5 = 0; float angle6 = 0; float sineC5 = 0; //from now on, we isntantiate a line and calculate position and direction GameObject newLine2 = newpoi2.transform.GetChild(2).gameObject; if (i > 0) { newLine2 = Instantiate(poi.transform.GetChild(2).gameObject, newpoi2.transform.position, Quaternion.Euler(new Vector3(0, 0, 90)), newpoi2.transform); } newLine2.transform.GetChild(0).GetComponent <Renderer>().material.color = Color.grey; newLine2.transform.GetChild(0).gameObject.layer = 10; //Que tamaño tendra float scaleX5 = Mathf.Abs((auxPoint.PointTransf.position - newpoi2.transform.position).magnitude); newLine2.transform.localScale = new Vector3(scaleX5, 3f, 3f); //Esto es para rotar las imagenes de las camaras que tienen cada Waypoint Transform cube5 = auxPoint.PointTransf.Find("CubeTop"); cube5.gameObject.SetActive(false); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from5 = new Vector2(-1, 0); Vector3 aux6 = newpoi2.transform.position - auxPoint.PointTransf.position; Vector2 to5 = new Vector2(aux6.x, aux6.z).normalized; if (i == 0) { angle5 = Vector2.SignedAngle(from5, to5); } Transform cube6 = auxPoint.PointTransf.Find("CubeFront"); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from6 = new Vector2(-1, 0); Vector3 aux7 = newpoi2.transform.position - auxPoint.PointTransf.position; Vector2 to6 = new Vector2(aux7.x, aux7.y).normalized; if (i == 0) { angle6 = Vector2.SignedAngle(from6, to6); } //float angle = Mathf.Acos(distance2 / distance); //item.transform.Rotate(new Vector3(0, 1, 0), Vector2.Angle(from, to)); cube5.transform.rotation = Quaternion.Euler(new Vector3(0, -angle5, 0)); cube6.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle6)); cube5.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; cube6.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; auxPoint.PointTransf.GetComponent <PathPoint>().Poi = newpoi2.transform; newpoi2.GetComponent <POI>().addPoint(auxPoint.PointTransf.GetComponent <PathPoint>(), newLine2); //UnityEngine.Debug.Log(newpoi.GetComponent<POI>().Referenced.Count); sineC5 = (auxPoint.PointTransf.transform.position.y - newpoi2.transform.position.y) / scaleX5; newLine2.transform.rotation = Quaternion.Euler(0, -angle5, Mathf.Asin(sineC5) * Mathf.Rad2Deg); newLine2.transform.position = auxPoint.PointTransf.transform.position; var rotation2 = Quaternion.Euler(0, -angle5, Mathf.Asin(sineC5) * Mathf.Rad2Deg).eulerAngles; break; case 3: //Same as above without locking yaw GameObject newpoi3 = Instantiate(poi, auxGimballUpdateParameters.poi_or_angles + auxPoint.PointTransf.position, Quaternion.Euler(new Vector3(0, 0, 0))); newpoi3.transform.GetChild(0).gameObject.SetActive(false); newpoi3.transform.GetChild(1).gameObject.SetActive(false); newpoi3.AddComponent <POI>(); newpoi3.GetComponent <POI>().Direction = true; float angle7 = 0; float angle8 = 0; float sineC7 = 0; //Creamos una nueva linea que apunta del waypoint al POI GameObject newLine3 = newpoi3.transform.GetChild(2).gameObject; //newLine3 = Instantiate(poi.transform.GetChild(2).gameObject, newpoi3.transform.position, Quaternion.Euler(new Vector3(0, 0, 0)), newpoi3.transform); newLine3.transform.GetChild(0).GetComponent <Renderer>().material.color = Color.gray; //Que tamaño tendra float scaleX7 = Mathf.Abs((auxPoint.PointTransf.position - newpoi3.transform.position).magnitude); newLine3.transform.localScale = new Vector3(scaleX7, 3f, 3f); //Esto es para rotar las imagenes de las camaras que tienen cada Waypoint Transform cube7 = auxPoint.PointTransf.Find("CubeTop"); cube7.gameObject.SetActive(true); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from7 = new Vector2(-1, 0); Vector3 aux8 = newpoi3.transform.position - auxPoint.PointTransf.position; Vector2 to7 = new Vector2(aux8.x, aux8.z).normalized; if (i == 0) { angle7 = Vector2.SignedAngle(from7, to7); } Transform cube8 = auxPoint.PointTransf.Find("CubeFront"); //float distance = Vector3.Distance(item.transform.position, newpoi.transform.position); //float distance2 = Vector3.Distance(cube.position, item.transform.position) * 2; Vector2 from8 = new Vector2(-1, 0); Vector3 aux9 = newpoi3.transform.position - auxPoint.PointTransf.position; Vector2 to8 = new Vector2(aux8.x, aux8.y).normalized; if (i == 0) { angle2 = Vector2.SignedAngle(from8, to8); } //float angle = Mathf.Acos(distance2 / distance); //item.transform.Rotate(new Vector3(0, 1, 0), Vector2.Angle(from, to)); cube7.transform.rotation = Quaternion.Euler(new Vector3(0, -angle7, 0)); cube8.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle8)); cube7.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; cube8.GetChild(0).GetComponent <MeshRenderer>().material.color = Color.white; auxPoint.PointTransf.GetComponent <PathPoint>().Poi = newpoi3.transform; newpoi3.GetComponent <POI>().addPoint(auxPoint.PointTransf.GetComponent <PathPoint>(), newLine3); //UnityEngine.Debug.Log(newpoi.GetComponent<POI>().Referenced.Count); sineC7 = (auxPoint.PointTransf.position.y - newpoi3.transform.position.y) / scaleX7; newLine3.transform.rotation = Quaternion.Euler(0, -angle7, Mathf.Asin(sineC7) * Mathf.Rad2Deg); newLine3.transform.position = auxPoint.PointTransf.transform.position; break; default: break; } } //This assigns reccam parameters to the waypoints that had them for (int i = 0; i < waypointPath.rcParametersCount(); i++) { RecCamParameters auxRcUpdateParameters = waypointPath.getRcUpdateParameter(i); reSetRecCamGuis(auxRcUpdateParameters, waypointPath.GetPoint(auxRcUpdateParameters.id_pointer).PointTransf.gameObject.GetComponent <PathPoint>()); } if (poiEditorPanel != null) { poiEditorPanel.GetComponent <POIEditor>().Deactivate(); } //activate every panel. If we saved a path, there has to be enough points to make sure this can be done if (editPointButton != null) { editPointButton.interactable = true; editPOIButton.interactable = true; previewButton.interactable = true; CurveButton.interactable = true; } } else //We assign an index to the new path { if (waypointPath != null) { MissionManager.planIndex = map.Paths.Count; } } //importedGO.name = "DaeModel"; }
/// <summary> /// Set camera parameters to the ones the waypoint clicked contains /// </summary> /// <param name="rc"></param> void reSetRecCamGuis(RecCamParameters rc) { if (!rc.active) { configParametersButton.gameObject.SetActive(false); activeCameraToggle.isOn = false; return; } else { configParametersButton.gameObject.SetActive(true); activeCameraToggle.isOn = true; } if (rc.switchToRec == 0) { changeToPhotoButton.gameObject.SetActive(false); changeToVideoButton.gameObject.SetActive(true); videoParametersPanel.SetActive(false); photoParametersPanel.SetActive(true); activeCameraToggle.transform.GetChild(1).GetComponent <Text>().text = "Take Photo"; imageStateRecording.sprite = photoSprite; } else { changeToVideoButton.gameObject.SetActive(false); changeToPhotoButton.gameObject.SetActive(true); photoParametersPanel.SetActive(false); videoParametersPanel.SetActive(true); activeCameraToggle.transform.GetChild(1).GetComponent <Text>().text = "Recording"; imageStateRecording.sprite = videoSprite; } switch (rc.resolution) { case 22: resolutionDropDown.value = 0; break; case 23: resolutionDropDown.value = 1; break; case 24: resolutionDropDown.value = 2; break; case 25: resolutionDropDown.value = 3; break; case 26: resolutionDropDown.value = 4; break; case 35: resolutionDropDown.value = 5; break; case 41: resolutionDropDown.value = 6; break; case 47: resolutionDropDown.value = 7; break; default: break; } megapixels.value = rc.megaPixels; brightness.value = (float)BitConverter.ToInt32(rc.brightness, 0); if (rc.autoManualWB == 0) { whiteBalance.isOn = true; } else { whiteBalance.isOn = false; } tintWB.value = rc.WBTint; RCamConfigISO isoPointParam = (RCamConfigISO)rc.ISO; switch (isoPointParam) { case RCamConfigISO.RCAM_ISO_AUTO: Iso.transform.GetChild(0).GetComponent <Text>().text = "Auto"; break; case RCamConfigISO.RCAM_ISO_100: Iso.transform.GetChild(0).GetComponent <Text>().text = "100"; break; case RCamConfigISO.RCAM_ISO_125: Iso.transform.GetChild(0).GetComponent <Text>().text = "125"; break; case RCamConfigISO.RCAM_ISO_160: Iso.transform.GetChild(0).GetComponent <Text>().text = "160"; break; case RCamConfigISO.RCAM_ISO_200: Iso.transform.GetChild(0).GetComponent <Text>().text = "200"; break; case RCamConfigISO.RCAM_ISO_250: Iso.transform.GetChild(0).GetComponent <Text>().text = "250"; break; case RCamConfigISO.RCAM_ISO_320: Iso.transform.GetChild(0).GetComponent <Text>().text = "320"; break; case RCamConfigISO.RCAM_ISO_400: Iso.transform.GetChild(0).GetComponent <Text>().text = "400"; break; case RCamConfigISO.RCAM_ISO_500: Iso.transform.GetChild(0).GetComponent <Text>().text = "500"; break; case RCamConfigISO.RCAM_ISO_640: Iso.transform.GetChild(0).GetComponent <Text>().text = "640"; break; case RCamConfigISO.RCAM_ISO_800: Iso.transform.GetChild(0).GetComponent <Text>().text = "800"; break; case RCamConfigISO.RCAM_ISO_1000: Iso.transform.GetChild(0).GetComponent <Text>().text = "1000"; break; case RCamConfigISO.RCAM_ISO_1250: Iso.transform.GetChild(0).GetComponent <Text>().text = "1250"; break; case RCamConfigISO.RCAM_ISO_1600: Iso.transform.GetChild(0).GetComponent <Text>().text = "1600"; break; case RCamConfigISO.RCAM_ISO_2000: Iso.transform.GetChild(0).GetComponent <Text>().text = "2000"; break; case RCamConfigISO.RCAM_ISO_2500: Iso.transform.GetChild(0).GetComponent <Text>().text = "2500"; break; case RCamConfigISO.RCAM_ISO_3200: Iso.transform.GetChild(0).GetComponent <Text>().text = "3200"; break; case RCamConfigISO.RCAM_ISO_4000: Iso.transform.GetChild(0).GetComponent <Text>().text = "4000"; break; case RCamConfigISO.RCAM_ISO_5000: Iso.transform.GetChild(0).GetComponent <Text>().text = "5000"; break; case RCamConfigISO.RCAM_ISO_6400: Iso.transform.GetChild(0).GetComponent <Text>().text = "6400"; break; case RCamConfigISO.RCAM_ISO_8000: Iso.transform.GetChild(0).GetComponent <Text>().text = "8000"; break; case RCamConfigISO.RCAM_ISO_10000: Iso.transform.GetChild(0).GetComponent <Text>().text = "100000"; break; case RCamConfigISO.RCAM_ISO_12800: Iso.transform.GetChild(0).GetComponent <Text>().text = "12800"; break; case RCamConfigISO.RCAM_ISO_16000: Iso.transform.GetChild(0).GetComponent <Text>().text = "16000"; break; case RCamConfigISO.RCAM_ISO_20000: Iso.transform.GetChild(0).GetComponent <Text>().text = "20000"; break; case RCamConfigISO.RCAM_ISO_25600: Iso.transform.GetChild(0).GetComponent <Text>().text = "25600"; break; default: break; } sharpness.value = rc.sharpness; contrast.value = (float)BitConverter.ToInt32(rc.contrast, 0); AE.value = rc.AE; saturation.value = (float)BitConverter.ToInt32(rc.saturation, 0); photoQuality.value = rc.photoQuality; if (rc.upsideDown == 3) { upsideDownCamera.isOn = true; } else { upsideDownCamera.isOn = false; } RCamConfigIris irisValueFromButton = (RCamConfigIris)rc.irisAperture; switch (irisValueFromButton) { case RCamConfigIris.RCAM_IRIS_F0_7: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F0.7"; break; case RCamConfigIris.RCAM_IRIS_F0_8: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F0.8"; break; case RCamConfigIris.RCAM_IRIS_F0_9: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F0.9"; break; case RCamConfigIris.RCAM_IRIS_F1: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1"; break; case RCamConfigIris.RCAM_IRIS_F1_1: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1.1"; break; case RCamConfigIris.RCAM_IRIS_F1_2: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1.2"; break; case RCamConfigIris.RCAM_IRIS_F1_4: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1.4"; break; case RCamConfigIris.RCAM_IRIS_F1_6: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1.6"; break; case RCamConfigIris.RCAM_IRIS_F1_8: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F1.8"; break; case RCamConfigIris.RCAM_IRIS_F2: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F2"; break; case RCamConfigIris.RCAM_IRIS_F2_2: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F2.2"; break; case RCamConfigIris.RCAM_IRIS_F2_5: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F2.5"; break; case RCamConfigIris.RCAM_IRIS_F2_8: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F2.8"; break; case RCamConfigIris.RCAM_IRIS_F3_2: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F3.2"; break; case RCamConfigIris.RCAM_IRIS_F3_5: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F3.5"; break; case RCamConfigIris.RCAM_IRIS_F4: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F4"; break; case RCamConfigIris.RCAM_IRIS_F4_5: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F4.5"; break; case RCamConfigIris.RCAM_IRIS_F5: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F5"; break; case RCamConfigIris.RCAM_IRIS_F5_6: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F5.6"; break; case RCamConfigIris.RCAM_IRIS_F6_3: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F6.3"; break; case RCamConfigIris.RCAM_IRIS_F7_1: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F7.1"; break; case RCamConfigIris.RCAM_IRIS_F8: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F8"; break; case RCamConfigIris.RCAM_IRIS_F9: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F9"; break; case RCamConfigIris.RCAM_IRIS_F10: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F10"; break; case RCamConfigIris.RCAM_IRIS_F11: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F11"; break; case RCamConfigIris.RCAM_IRIS_F13: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F13"; break; case RCamConfigIris.RCAM_IRIS_F14: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F14"; break; case RCamConfigIris.RCAM_IRIS_F16: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F16"; break; case RCamConfigIris.RCAM_IRIS_F18: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F18"; break; case RCamConfigIris.RCAM_IRIS_F20: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F20"; break; case RCamConfigIris.RCAM_IRIS_F22: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F22"; break; case RCamConfigIris.RCAM_IRIS_F25: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F25"; break; case RCamConfigIris.RCAM_IRIS_F29: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F29"; break; case RCamConfigIris.RCAM_IRIS_F32: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F32"; break; case RCamConfigIris.RCAM_IRIS_F36: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F36"; break; case RCamConfigIris.RCAM_IRIS_F40: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F40"; break; case RCamConfigIris.RCAM_IRIS_F45: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F45"; break; case RCamConfigIris.RCAM_IRIS_F51: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F51"; break; case RCamConfigIris.RCAM_IRIS_F57: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F57"; break; case RCamConfigIris.RCAM_IRIS_F64: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F64"; break; case RCamConfigIris.RCAM_IRIS_F72: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F72"; break; case RCamConfigIris.RCAM_IRIS_F80: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F80"; break; case RCamConfigIris.RCAM_IRIS_F90: irisaperture.transform.GetChild(0).GetComponent <Text>().text = "F90"; break; default: break; } if (rc.burstMode == 1) { burstMode.isOn = true; } else { burstMode.isOn = false; } burstSpeed.value = rc.burstSpeed; if (rc.AF == 0) { AF.isOn = false; } else { AF.isOn = true; } }
public void updateParamRc(int pos, RecCamParameters param) { rcam_update_parameters[pos] = param; }
public void addNewParamRcAtBeggining(RecCamParameters param) { rcam_update_parameters.Insert(0, param); }
public void addNewParamRc(RecCamParameters param) { rcam_update_parameters.Add(param); }