コード例 #1
0
ファイル: OVRManager.cs プロジェクト: Dieathan/ICT302_MGU
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        //Debug.Log("Unity v" + Application.unityVersion + ", " +
        //		  "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
        //		  "OVRPlugin v" + OVRPlugin.version + ", " +
        //		  "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        //isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
        enableMixedReality = false;                     // we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        bool loadMrcConfig   = LoadMixedRealityCaptureConfigurationFileFromCmd();
        bool createMrcConfig = CreateMixedRealityCaptureConfigurationFileFromCmd();

        if (loadMrcConfig || createMrcConfig)
        {
            OVRMixedRealityCaptureSettings mrcSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
            mrcSettings.ReadFrom(this);
            if (loadMrcConfig)
            {
                mrcSettings.CombineWithConfigurationFile();
                mrcSettings.ApplyTo(this);
            }
            if (createMrcConfig)
            {
                mrcSettings.WriteToConfigurationFile();
            }
            ScriptableObject.Destroy(mrcSettings);
        }

        if (MixedRealityEnabledFromCmd())
        {
            enableMixedReality = true;
        }

        if (enableMixedReality)
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            if (UseDirectCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.Direct;
            }
            if (UseExternalCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.External;
            }
            Debug.Log("OVR: CompositionMethod : " + compositionMethod);
        }
#endif

        Initialize();

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

        // Disable the occlusion mesh by default until open issues with the preview window are resolved.
        OVRPlugin.occlusionMesh = false;
    }
コード例 #2
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Utilities v" + OVRPlugin.wrapperVersion + ", " +
                  "OVRPlugin v" + OVRPlugin.version + ", " +
                  "SDK v" + OVRPlugin.nativeSDKVersion + ".");

#if !UNITY_EDITOR
        if (IsUnityAlphaOrBetaVersion())
        {
            Debug.LogWarning(UnityAlphaOrBetaVersionWarningMessage);
        }
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        var supportedTypes =
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D11.ToString() + ", " +
            UnityEngine.Rendering.GraphicsDeviceType.Direct3D12.ToString();

        if (!supportedTypes.Contains(SystemInfo.graphicsDeviceType.ToString()))
        {
            Debug.LogWarning("VR rendering requires one of the following device types: (" + supportedTypes + "). Your graphics device: " + SystemInfo.graphicsDeviceType.ToString());
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        if (currPlatform == RuntimePlatform.Android ||
            // currPlatform == RuntimePlatform.LinuxPlayer ||
            currPlatform == RuntimePlatform.OSXEditor ||
            currPlatform == RuntimePlatform.OSXPlayer ||
            currPlatform == RuntimePlatform.WindowsEditor ||
            currPlatform == RuntimePlatform.WindowsPlayer)
        {
            isSupportedPlatform = true;
        }
        else
        {
            isSupportedPlatform = false;
        }
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // Turn off chromatic aberration by default to save texture bandwidth.
        chromatic = false;
#endif

#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
        enableMixedReality = false;                     // we should never start the standalone game in MxR mode, unless the command-line parameter is provided
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        bool loadMrcConfig   = LoadMixedRealityCaptureConfigurationFileFromCmd();
        bool createMrcConfig = CreateMixedRealityCaptureConfigurationFileFromCmd();

        if (loadMrcConfig || createMrcConfig)
        {
            OVRMixedRealityCaptureSettings mrcSettings = ScriptableObject.CreateInstance <OVRMixedRealityCaptureSettings>();
            mrcSettings.ReadFrom(this);
            if (loadMrcConfig)
            {
                mrcSettings.CombineWithConfigurationFile();
                mrcSettings.ApplyTo(this);
            }
            if (createMrcConfig)
            {
                mrcSettings.WriteToConfigurationFile();
            }
            ScriptableObject.Destroy(mrcSettings);
        }

        if (MixedRealityEnabledFromCmd())
        {
            enableMixedReality = true;
        }

        if (enableMixedReality)
        {
            Debug.Log("OVR: Mixed Reality mode enabled");
            if (UseDirectCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.Direct;
            }
            if (UseExternalCompositionFromCmd())
            {
                compositionMethod = CompositionMethod.External;
            }
            Debug.Log("OVR: CompositionMethod : " + compositionMethod);
        }
#endif

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        if (enableAdaptiveResolution && !OVRManager.IsAdaptiveResSupportedByEngine())
        {
            enableAdaptiveResolution = false;
            UnityEngine.Debug.LogError("Your current Unity Engine " + Application.unityVersion + " might have issues to support adaptive resolution, please disable it under OVRManager");
        }
#endif

        Initialize();

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        // Force OcculusionMesh on all the time, you can change the value to false if you really need it be off for some reasons,
        // be aware there are performance drops if you don't use occlusionMesh.
        OVRPlugin.occlusionMesh = true;
#endif
    }
コード例 #3
0
 /// <summary>
 ///      Creates a new CompositeIndicator such that the result will be the product of the left to the right
 /// </summary>
 /// <remarks>
 ///      value = left*right
 /// </remarks>
 /// <param name="left">The left indicator</param>
 /// <param name="right">The right indicator</param>
 /// <param name="method">What method to composite the two indicators.</param>
 /// <returns>The product of the left to the right indicators</returns>
 public static CompositeIndicator Times(this IndicatorBase left, IndicatorBase right, CompositionMethod method = CompositionMethod.OnBothUpdated)
 {
     if (AreDoubleScalar(left, right))
     {
         return(new CompositeIndicator(left, right, (l, r) => l.Current.Value * r.Current.Value, method));
     }
     return(new CompositeIndicator(left, right, (l, r) => l.Current * r.Current, method));
 }
コード例 #4
0
 /// <summary>
 ///      Creates a new CompositeIndicator such that the result will be the product of the left to the right
 /// </summary>
 /// <remarks>
 ///      value = left * right
 /// </remarks>
 /// <param name="left">The left indicator</param>
 /// <param name="right">The right indicator</param>
 /// <param name="name">The name of this indicator</param>
 /// <param name="method">What method to composite the two indicators.</param>
 /// <returns>The product of the left to the right indicators</returns>
 public static CompositeIndicator Times(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
 {
     if (AreDoubleScalar(left, right))
     {
         return(new CompositeIndicator(left, right, (l, r) => l.Current.Value * r.Current.Value, method));
     }
     return(new CompositeIndicator(name, left, right, (l, r) => (IndicatorResult)(l.Current * r.Current), method));
 }
コード例 #5
0
        /// <summary>
        ///      Creates a new CompositeIndicator such that the result will be the ratio of the left to the right
        /// </summary>
        /// <remarks>
        ///      value = left/right
        /// </remarks>
        /// <param name="left">The left indicator</param>
        /// <param name="right">The right indicator</param>
        /// <param name="name">The name of this indicator</param>
        /// <param name="method">What method to composite the two indicators.</param>
        /// <returns>The ratio of the left to the right indicator</returns>
        public static CompositeIndicator Over(this IUpdatable left, IUpdatable right, string name, CompositionMethod method = CompositionMethod.OnBothUpdated)
        {
            if (AreDoubleScalar(left, right))
            {
                return(new CompositeIndicator(left, right, (l, r) => r.Current == Constants.Zero ? new IndicatorResult(Constants.Zero, IndicatorStatus.MathError) : new IndicatorResult(l.Current.Value / r.Current.Value), method));
            }

            return(new CompositeIndicator(name, left, right, (l, r) => r.Current == Constants.Zero ? new IndicatorResult(Constants.Zero, IndicatorStatus.MathError) : new IndicatorResult(l.Current / r.Current), method));
        }
コード例 #6
0
        /// <summary>
        ///      Creates a new CompositeIndicator such that the result will be the difference of the left and right
        /// </summary>
        /// <remarks>
        ///      value = left - right
        /// </remarks>
        /// <param name="left">The left indicator</param>
        /// <param name="right">The right indicator</param>
        /// <param name="method">What method to composite the two indicators.</param>
        /// <returns>The difference of the left and right indicators</returns>
        public static CompositeIndicator Minus(this IUpdatable left, IUpdatable right, CompositionMethod method = CompositionMethod.OnBothUpdated)
        {
            if (AreDoubleScalar(left, right))
            {
                return(new CompositeIndicator(left, right, (l, r) => l.Current.Value - r.Current.Value, method));
            }

            return(new CompositeIndicator(left, right, (l, r) => l.Current - r.Current, method));
        }
コード例 #7
0
        /// <summary>
        ///      Creates a new CompositeIndicator such that the result will be average of a first indicator weighted by a second one
        /// </summary>
        /// <param name="value">Indicator that will be averaged</param>
        /// <param name="weight">Indicator that provides the average weights</param>
        /// <param name="period">Average period</param>
        /// <param name="method">What method to composite the two indicators.</param>
        /// <returns>Indicator that results of the average of first by weights given by second</returns>
        public static CompositeIndicator WeightedBy <TWeight>(this IUpdatable value, TWeight weight, int period, CompositionMethod method = CompositionMethod.OnBothUpdated)
            where TWeight : IUpdatable
        {
            var x           = new WindowIdentity(period);
            var y           = new WindowIdentity(period);
            var numerator   = new Sum("Sum_xy", period);
            var denominator = new Sum("Sum_y", period);

            value.Updated += (time, consolidated) => {
                x.Update(time, consolidated);
                if (x.Samples == y.Samples)
                {
                    numerator.Update(time, consolidated * y.Current[0, C]);
                }
            };

            weight.Updated += (time, consolidated) => {
                y.Update(time, consolidated);
                if (x.Samples == y.Samples)
                {
                    numerator.Update(time, consolidated * x.Current[0, C]);
                }

                denominator.Update(time, consolidated);
            };

            value.Resetted += sender => weight.Reset();

            return(numerator.Over((IUpdatable)denominator, method));
        }
コード例 #8
0
ファイル: Property.cs プロジェクト: slung/fuzzyselector
 public Property(string name, CompositionMethod compositionMethod, double start, double end, List<Term> terms)
     : this(name, compositionMethod, terms)
 {
     this.start = start;
     this.end = end;
 }
コード例 #9
0
ファイル: Property.cs プロジェクト: slung/fuzzyselector
 public Property(string name, CompositionMethod compositionMethod, List<Term> terms)
 {
     this.name = name;
     this.compositionMethod = compositionMethod;
     this.terms = new List<Term>(terms);
 }