Esempio n. 1
0
        public override void SetGamma(float value)
        {
            //copy from WindowsPlatformFunctionality

            RAMP   gamma;
            IntPtr hWnd = GetDesktopWindow();
            IntPtr hdc  = GetDC(hWnd);

            if (GetDeviceGammaRamp(hdc, out gamma) != 0)
            {
                for (int n = 0; n < 256; n++)
                {
                    ushort g = (ushort)(255 * (ushort)(255.0f * MathEx.Pow((float)n / 255.0f, 1.0f / value)));
                    gamma.red[n]   = g;
                    gamma.green[n] = g;
                    gamma.blue[n]  = g;
                }
                if (SetDeviceGammaRamp(hdc, ref gamma) == 0)
                {
                    //Error
                    //ReleaseDC(hWnd, hdc);
                    //return;
                }
            }

            ReleaseDC(hWnd, hdc);


            //// it seems it works, but it's cross-platform?

            //var wp = new WindowsPlatformFunctionality();
            //wp.SetGamma( value );
        }
        protected override void OnGetLocalPosition(Random random, out Vector3 result)
        {
            var u        = random.NextFloat();
            var v        = random.NextFloat();
            var theta    = u * 2.0f * MathEx.PI;
            var phi      = MathEx.Acos(2.0f * v - 1.0f);
            var r        = MathEx.Pow(random.NextFloat(), 1.0f / 3.0f);       //var r = Math.Cbrt( random.NextFloat() );
            var sinTheta = MathEx.Sin(theta);
            var cosTheta = MathEx.Cos(theta);
            var sinPhi   = MathEx.Sin(phi);
            var cosPhi   = MathEx.Cos(phi);
            var x        = r * sinPhi * cosTheta;
            var y        = r * sinPhi * sinTheta;
            var z        = r * cosPhi;

            result = new Vector3F(x, y, z) * Radius;
        }
Esempio n. 3
0
 /// <summary>
 /// Returns the vector which contains the components of the first specified vector raised to power of the numbers which are equal to the corresponding components of the second specified vector.
 /// </summary>
 /// <param name="x">The first vector.</param>
 /// <param name="y">The second vector.</param>
 /// <returns>The vector which contains the components of the first specified vector raised to power of
 /// the numbers which are equal to the corresponding components of the second specified vector.</returns>
 public static Vector2F Pow(Vector2F x, Vector2F y)
 {
     return(new Vector2F(MathEx.Pow(x.X, y.X), MathEx.Pow(x.Y, y.Y)));
 }
Esempio n. 4
0
 /// <summary>
 /// Returns the vector which contains the components of the first specified vector raised to power of the numbers which are equal to the corresponding components of the second specified vector.
 /// </summary>
 /// <param name="x">The first vector.</param>
 /// <param name="y">The second vector.</param>
 /// <returns>The vector which contains the components of the first specified vector raised to power of
 /// the numbers which are equal to the corresponding components of the second specified vector.</returns>
 public static Vector4F Pow(Vector4F x, Vector4F y)
 {
     return(new Vector4F(MathEx.Pow(x.X, y.X), MathEx.Pow(x.Y, y.Y), MathEx.Pow(x.Z, y.Z), MathEx.Pow(x.W, y.W)));
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the vector which contains the components of the first specified vector raised to power of the numbers which are equal to the corresponding components of the second specified vector.
 /// </summary>
 /// <param name="x">The first vector.</param>
 /// <param name="y">The second vector.</param>
 /// <returns>The vector which contains the components of the first specified vector raised to power of
 /// the numbers which are equal to the corresponding components of the second specified vector.</returns>
 public static Vector3F Pow(Vector3F x, Vector3F y)
 {
     return(new Vector3F(MathEx.Pow(x.X, y.X), MathEx.Pow(x.Y, y.Y), MathEx.Pow(x.Z, y.Z)));
 }