Exemple #1
0
 /// <summary>
 /// On selection, sets up the target properties and notify the object.
 /// </summary>
 void OnEnable()
 {
     // Get the target object.
     _targetObject = (CameraSetup)serializedObject.targetObject;
     // Notify the object that it has been selected.
     _targetObject.Selected();
 }
Exemple #2
0
        /// <summary>
        /// Creates or resets a camera setup object as a child of the given transform.
        /// </summary>
        /// <param name="parentTransform"></param> The parent transform.
        /// <returns></returns> The camera setup object.
        public static CameraSetup CreateOrResetCameraSetup(Transform parentTransform = null)
        {
            CameraSetup existingSetup = GeneralToolkit.GetOrCreateChildComponent <CameraSetup>(parentTransform);

            existingSetup.Reset();
            return(existingSetup);
        }
 /// <summary>
 /// Sets the image URLs for the given camera setup.
 /// </summary>
 /// <param name="cameraSetup"></param> The camera setup.
 public void SetImageURLs(CameraSetup cameraSetup)
 {
     for (int iter = 0; iter < cameraSetup.cameraModels.Length; iter++)
     {
         cameraSetup.cameraModels[iter].imageURL = Path.Combine(colorDirectory, cameraSetup.cameraModels[iter].imageName);
     }
 }
        /// <summary>
        /// Saves additional information related to acquisition, with the given values.
        /// </summary>
        /// <param name="cameraSetup"></param> The camera setup containing the acquisition information.
        public void SaveCOLIBRIVRAdditionalInformation(CameraSetup cameraSetup)
        {
            // Determine the camera model, or initialize a new one if there is none.
            CameraModel cameraParams;

            if (cameraSetup.cameraModels != null)
            {
                cameraParams = cameraSetup.cameraModels[0];
            }
            else
            {
                cameraParams = CameraModel.CreateCameraModel();
            }
            // Get the initial viewing position.
            Vector3 initialViewingPos = cameraSetup.initialViewingPosition;

            // Store this information in the additional information file.
            GeneralToolkit.CreateOrClear(PathType.File, additionalInfoFile);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("# COLIBRI VR additional information:");
            stringBuilder.AppendLine("#   INITIAL_VIEWING_POSITION");
            string line = initialViewingPos.x + " " + initialViewingPos.y + " " + initialViewingPos.z;

            stringBuilder.AppendLine(line);
            File.WriteAllText(additionalInfoFile, stringBuilder.ToString());
            // Delete any temporary camera model.
            if (cameraSetup.cameraModels == null)
            {
                DestroyImmediate(cameraParams.gameObject);
            }
        }
 /// <summary>
 /// Reads the stored additional information.
 /// </summary>
 /// <param name="cameraSetup"></param> The camera setup to modify with the parsed information.
 public void ReadCOLIBRIVRAdditionalInformation(CameraSetup cameraSetup)
 {
     string[] lines = File.ReadAllLines(additionalInfoFile);
     foreach (string line in lines)
     {
         if (!line.StartsWith("#"))
         {
             string[] split = line.Split(' ');
             if (split.Length > 2)
             {
                 Vector3 newInitialViewingPosition = new Vector3(GeneralToolkit.ParseFloat(split[0]), GeneralToolkit.ParseFloat(split[1]), GeneralToolkit.ParseFloat(split[2]));
                 cameraSetup.SetAdditionalParameters(newInitialViewingPosition);
             }
         }
     }
 }
Exemple #6
0
 /// <summary>
 /// On reset, reset the object's properties.
 /// </summary>
 public virtual void Reset()
 {
     renderingCaller = GeneralToolkit.GetParentOfType <Rendering.Rendering>(transform);
     if (renderingCaller != null)
     {
         processingCaller = renderingCaller.processing;
     }
     else
     {
         processingCaller = GeneralToolkit.GetParentOfType <Processing.Processing>(transform);
     }
     if (processingCaller != null)
     {
         dataHandler = processingCaller.dataHandler;
         cameraSetup = processingCaller.cameraSetup;
     }
 }
        /// <summary>
        /// Saves additional information related to acquisition, with the given values.
        /// </summary>
        /// <param name="cameraSetup"></param> The camera setup containing the acquisition information.
        public void SaveAdditionalSetupInformation(CameraSetup cameraSetup)
        {
            // Determine the camera model, or initialize a new one if there is none.
            CameraModel cameraParams;

            if (cameraSetup.cameraModels != null && cameraSetup.cameraModels.Length > 0)
            {
                cameraParams = cameraSetup.cameraModels[0];
            }
            else
            {
                cameraParams = CameraModel.CreateCameraModel();
            }
            // Store the initial viewing position.
            Vector3 initialViewingPos = cameraSetup.initialViewingPosition;

            GeneralToolkit.CreateOrClear(PathType.File, additionalInfoFile);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("# Additional setup information:");
            stringBuilder.AppendLine("#   INITIAL_VIEWING_POSITION");
            string line = GeneralToolkit.ToString(initialViewingPos.x) + " " + GeneralToolkit.ToString(initialViewingPos.y) + " " + GeneralToolkit.ToString(initialViewingPos.z);

            stringBuilder.AppendLine(line);
            // Store the minimum/maximum distance range
            stringBuilder.AppendLine("#   Distance ranges with one line of data per camera:");
            stringBuilder.AppendLine("#   CAMERA_ID DISTANCE_RANGE_MIN DISTANCE_RANGE_MAX");
            foreach (CameraModel camera in cameraSetup.cameraModels)
            {
                Vector2 distanceRange = camera.distanceRange;
                stringBuilder.AppendLine(GeneralToolkit.ToString(camera.cameraReferenceIndex) + " " + GeneralToolkit.ToString(distanceRange.x) + " " + GeneralToolkit.ToString(distanceRange.y));
            }
            // Save the file.
            File.WriteAllText(additionalInfoFile, stringBuilder.ToString());
            // Delete any temporary camera model.
            if (cameraSetup.cameraModels == null)
            {
                DestroyImmediate(cameraParams.gameObject);
            }
        }
        /// <summary>
        /// Reads the stored additional information.
        /// </summary>
        /// <param name="cameraSetup"></param> The camera setup to modify with the parsed information.
        public void ReadCOLIBRIVRAdditionalInformation(CameraSetup cameraSetup)
        {
            string[] lines = File.ReadAllLines(additionalInfoFile);
            for (int i = 0; i < lines.Length; ++i)
            {
                if (lines[i].Contains("INITIAL_VIEWING_POSITION"))
                {
                    string[] split = lines[++i].Split(' ');
                    if (split.Length == 3)
                    {
                        Vector3 newInitialViewingPosition = new Vector3(GeneralToolkit.ParseFloat(split[0]), GeneralToolkit.ParseFloat(split[1]), GeneralToolkit.ParseFloat(split[2]));
                        cameraSetup.SetAdditionalParameters(newInitialViewingPosition);
                    }
                    continue;
                }

                if (lines[i].Contains("DISTANCE_RANGE"))
                {
                    while (i + 1 < lines.Length && !lines[i + 1].StartsWith("#"))
                    {
                        string[] split = lines[++i].Split(' ');
                        if (split.Length == 3)
                        {
                            int     cameraReferenceIndex = GeneralToolkit.ParseInt(split[0]);
                            Vector2 newDistanceRange     = new Vector2(GeneralToolkit.ParseFloat(split[1]), GeneralToolkit.ParseFloat(split[2]));
                            // Find the referenced camera and set its distance range
                            foreach (CameraModel camera in cameraSetup.cameraModels)
                            {
                                if (camera.cameraReferenceIndex == cameraReferenceIndex)
                                {
                                    camera.distanceRange = newDistanceRange;
                                }
                            }
                        }
                    }
                }
            }
        }