Esempio n. 1
0
 public Colour256(Colour32 colour)
 {
     this.R = (double)colour.R / Colour32.MaxValue;
     this.G = (double)colour.G / Colour32.MaxValue;
     this.B = (double)colour.B / Colour32.MaxValue;
     this.A = (double)colour.A / Colour32.MaxValue;
 }
Esempio n. 2
0
        public static Colour32 Lerp(Colour32 a, Colour32 b, double t)
        {
            t = Clamp(t, 0.0D, 1.0D);

            return(new Colour32(
                       (byte)(a.R + (b.R - a.R) * t),
                       (byte)(a.G + (b.G - a.G) * t),
                       (byte)(a.B + (b.B - a.B) * t),
                       (byte)(a.A + (b.A - a.A) * t)
                       ));

            //return Lerp((Colour256)a, (Colour256)b, t);
        }
Esempio n. 3
0
        public static Colour32 Combine(Colour32 a, Colour32 b)
        {
            Colour256 c0 = a;
            Colour256 c1 = b;

            double a01 = (1D - c0.A) * c1.A + c0.A;

            return(new Colour256(
                       ((1D - c0.A) * c1.A * c1.R + c0.A * c0.R) / a01,
                       ((1D - c0.A) * c1.A * c1.G + c0.A * c0.G) / a01,
                       ((1D - c0.A) * c1.A * c1.B + c0.A * c0.B) / a01,
                       a01
                       ));
        }
Esempio n. 4
0
        public static Image ConvertToImage(Voxel v)
        {
            Bitmap bm = new Bitmap(v.Size.x, v.Size.y);

            for (int y = 0; y < v.Size.y; y++)
            {
                for (int x = 0; x < v.Size.x; x++)
                {
                    Colour32 col = v[x, y, 0];

                    bm.SetPixel(x, y, Color.FromArgb(col.A, col.R, col.G, col.B));
                }
            }

            return(bm);
        }
Esempio n. 5
0
        public static Voxel CreateFromImage(Bitmap image)
        {
            Voxel voxel = new Voxel(new int3(image.Width, image.Height, 1));

            for (int y = 0; y < image.Height; y++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    Color    pix = image.GetPixel(x, y);
                    Colour32 col = new Colour32(pix.R, pix.G, pix.B, pix.A);

                    voxel[x, y, 0] = col;//image.GetPixel(x, y);
                }
            }

            return(voxel);
        }
Esempio n. 6
0
        public static Voxel GenerateDebug(int3 size)
        {
            Voxel voxel = new Voxel(size);

            for (int z = 0; z < size.z; z++)
            {
                for (int y = 0; y < size.y; y++)
                {
                    for (int x = 0; x < size.x; x++)
                    {
                        Colour256 col256 = new Colour256(
                            r: x / ((double)size.x - 1),
                            g: 1.0D - (y / ((double)size.y - 1)),
                            b: z / ((double)size.z - 1),
                            a: 1.0D//(z % 2.0F == 0 ? 1.0D : 0.0D)

                            );

                        if (x % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }
                        if (y % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }
                        if (z % 2 == 0)
                        {
                            col256.A = 0.0D;
                        }

                        Colour32 col32 = (Colour32)col256;

                        voxel[x, y, z] = col256;
                    }
                }
            }

            return(voxel);
        }
Esempio n. 7
0
        protected internal override void FixedUpdate()
        {
            //Angle += DegPerSec * Time.FixedDeltaTime;
            Quaternion rot = Quaternion.CreateFromAxisAngle((Vector3)RotationAxis, (float)(Angle * 0.0174533D));

            this.Malleable.Rotation = rot;

            Vector3D sunDir = this.Malleable.Forward;

            double SunAltitude = 1D;
            bool   negative    = sunDir.Y < 0;

            SunAltitude = Math.Abs(sunDir.Y);

            if (!negative)
            {
                this.Colour = RayMath.Lerp(SunSetColour, SunDayColour, Math.Sqrt(SunAltitude * 2));
            }
            else
            {
                this.Colour = RayMath.Lerp(SunSetColour, NightColour, SunAltitude * 10);
            }
        }
Esempio n. 8
0
 public Sphere() : base()
 {
     Main   = this;
     Colour = new Colour32(EngineInitializer.r.Next(256), EngineInitializer.r.Next(256), EngineInitializer.r.Next(256), 255);
 }