Beispiel #1
0
 public static int[] getShades(short colix)
 {
     colix &= NuGraphics3D.OPAQUE_MASK;
     int[] shades = ashades[colix];
     if (shades == null)
     {
         shades = ashades[colix] = Shade3D.getShades(argbs[colix], false);
     }
     return(shades);
 }
Beispiel #2
0
 public static int[] getShadesGreyscale(short colix)
 {
     colix &= NuGraphics3D.OPAQUE_MASK;
     if (ashadesGreyscale == null)
     {
         ashadesGreyscale = new int[ashades.Length][];
     }
     int[] shadesGreyscale = ashadesGreyscale[colix];
     if (shadesGreyscale == null)
     {
         shadesGreyscale = ashadesGreyscale[colix] = Shade3D.getShades(argbs[colix], true);
     }
     return(shadesGreyscale);
 }
Beispiel #3
0
        public static int[] getShades(int rgb, bool greyScale)
        {
            int[] shades = new int[shadeMax];

            int red = (rgb >> 16) & 0xFF;
            int grn = (rgb >> 8) & 0xFF;
            int blu = rgb & 0xFF;

            float ambientRange = 1 - ambientFraction;

            shades[shadeNormal] = Shade3D.rgb(red, grn, blu);
            for (int i = 0; i < shadeNormal; ++i)
            {
                float fraction = ambientFraction + ambientRange * i / shadeNormal;
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                shades[i] = Shade3D.rgb((int)(red * fraction + 0.5f), (int)(grn * fraction + 0.5f), (int)(blu * fraction + 0.5f));
            }

            int   nSteps   = shadeMax - shadeNormal - 1;
            float redRange = (255 - red) * intenseFraction;
            float grnRange = (255 - grn) * intenseFraction;
            float bluRange = (255 - blu) * intenseFraction;

            for (int i = 1; i <= nSteps; ++i)
            {
                //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                shades[shadeNormal + i] = Shade3D.rgb(red + (int)(redRange * i / nSteps + 0.5f), grn + (int)(grnRange * i / nSteps + 0.5f), blu + (int)(bluRange * i / nSteps + 0.5f));
            }
            if (greyScale)
            {
                for (int i = shadeMax; --i >= 0;)
                {
                    shades[i] = NuGraphics3D.calcGreyscaleRgbFromRgb(shades[i]);
                }
            }
            return(shades);
        }