コード例 #1
0
        /// <summary>
        /// Attempt to load maps from the alignment profile retrieved from the UserSettings
        /// fallback maps are used in the event that the maps cannot be loaded.
        /// The '_loadState' member of this instance is modified accordingly.
        /// </summary>
        public void LoadMaps()
        {
            AlignmentProfile profile = null;

            if (metaContext != null && metaContext.ContainsModule <AlignmentProfile>())
            {
                profile = metaContext.Get <AlignmentProfile>();
            }

            if (profile != null && profile.ProfileMapPathsValid(_MapsDir))
            {
                string[] filenames = new[]
                {
                    profile.MaskMapPathLeft,
                    profile.MaskMapPathRight,
                    profile.DistortionMapPathLeft,
                    profile.DistortionMapPathRight
                };

                for (int i = 0; i < 4; ++i)
                {
                    var fileData = File.ReadAllBytes(_MapsDir + filenames[i]);
                    //Important to get the right filtering

                    if (!_fileAlignmentTextures[i])
                    {
                        _fileAlignmentTextures[i] = new Texture2D(2, 2, TextureFormat.ARGB32, false);
                    }

                    _fileAlignmentTextures[i].hideFlags  = HideFlags.HideAndDontSave;
                    _fileAlignmentTextures[i].filterMode = FilterMode.Point;
                    _fileAlignmentTextures[i].wrapMode   = TextureWrapMode.Clamp;
                    _fileAlignmentTextures[i].LoadImage(fileData); //..this will auto-resize the texture dimensions.
                }

                //Assign the file alignment textures to the correct variables
                _activeMaskMaps[0]       = _fileAlignmentTextures[0];
                _activeMaskMaps[1]       = _fileAlignmentTextures[1];
                _activeDistortionMaps[0] = _fileAlignmentTextures[2];
                _activeDistortionMaps[1] = _fileAlignmentTextures[3];
                _loadState = LoadState.HasLoadedFinal;
            }
            else
            {
                for (int i = 0; i < 2; ++i)
                {
                    _activeDistortionMaps[i] = _fallbackDistortionMaps[i];
                    _activeMaskMaps[i]       = _fallbackMaskMaps[i];
                }

                //The purpose of the following is to put this instance into a state where it may
                // attempt to load maps again.
                //The user-aligned maps may not be available at this time because Unity is currently not playing.
                //Therefor the fallback maps may be used in place of them.
                _loadState = (metaContext == null) ? LoadState.HasLoadedProxy : LoadState.LoadFailed;
            }
        }
コード例 #2
0
        /// <summary>
        /// Attempts to load the camera positions from the alignment profile stored in the metacontext.
        /// </summary>
        private void _LoadCameraPositions()
        {
            if (LeftCamera != null && RightCamera != null)
            {
                AlignmentProfile profile = null;
                if (metaContext != null && metaContext.ContainsModule <AlignmentProfile>())
                {
                    profile = metaContext.Get <AlignmentProfile>();
                }

                if (profile != null)
                {
                    LeftCamera.localPosition  = profile.EyePositionLeft;
                    RightCamera.localPosition = profile.EyePositionRight;
                }
                else
                {
                    LeftCamera.localPosition  = _defaultLeftCameraPos;
                    RightCamera.localPosition = _defaultRightCameraPos;
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Sets a flag to load the camera positions from the alignment profile provided in the parameter at a later time.
 /// </summary>
 /// <param name="newProfile">the profile</param>
 public void OnAlignmentUpdate(AlignmentProfile newProfile)
 {
     //This is a hack in order to load transformations at a later time during Unity's main thread of execution.
     _alignmentUpdateOccured = true;
 }
コード例 #4
0
 public void OnAlignmentUpdate(AlignmentProfile newProfile)
 {
     //Reset the load-state to load the new maps
     _loadState = LoadState.NotLoaded;
 }