Exemplo n.º 1
0
        static CCGraphics()
        {
            SinLut = new float[sinCosLength];
            CosLut = new float[sinCosLength];

            for (var i = 0; i < sinCosLength; i++)
            {
                SinLut[i] = CCMath.Sin(i * CCMath.DEG_TO_RAD * sinCosPrecision);
                CosLut[i] = CCMath.Cos(i * CCMath.DEG_TO_RAD * sinCosPrecision);
            }

            // Unity has a built-in shader that is useful for drawing
            // simple colored things.
            var shader = Shader.Find("Hidden/Internal-Colored");

            colorMaterial = new Material(shader)
            {
                hideFlags = HideFlags.HideAndDontSave
            };
            // Turn on alpha blending
            colorMaterial.SetInt(SrcBlend, (int)Rendering.BlendMode.SrcAlpha);
            colorMaterial.SetInt(DstBlend, (int)Rendering.BlendMode.OneMinusSrcAlpha);
            // Turn backface culling off
            colorMaterial.SetInt(Cull, (int)Rendering.CullMode.Off);
            // Turn off depth writes
            colorMaterial.SetInt(ZWrite, 0);
        }
        public override float Interpolate(float theBlend)
        {
            switch (mode)
            {
            case CCInterpolationMode.IN:
                return(1 - CCMath.Cos(theBlend * CCMath.HALF_PI));

            case CCInterpolationMode.OUT:
                return(CCMath.Sin(theBlend * CCMath.HALF_PI));
            }
            return((CCMath.Cos(CCMath.PI + CCMath.PI * theBlend) + 1) / 2);
        }