Esempio n. 1
0
        /// <summary>
        /// Add new regions
        /// </summary>
        /// <param name="location"></param>
        public void Add(PointF point)
        {
            var light = new StructLights();

            light.Position = new K3DPosition(point.X, point.Y, 0f);
            Lights.Add(light);

            Added?.Invoke(this, light);
        }
Esempio n. 2
0
        /// <summary>
        /// Load existing light
        /// </summary>
        /// <param name="buffer"></param>
        public void Load(byte[] buffer)
        {
            try
            {
                using (BinaryReader b = new BinaryReader(new MemoryStream(buffer)))
                {
                    Direction.X = b.ReadSingle();
                    Direction.Y = b.ReadSingle();
                    Direction.Z = b.ReadSingle();
                    Specular    = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());
                    Diffuse     = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());
                    Ambient     = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());

                    var lightCount = b.ReadInt32();

                    for (int i = 0; i < lightCount; i++)
                    {
                        var light = new StructLights();
                        light.Position.X  = b.ReadSingle();
                        light.Position.Y  = b.ReadSingle();
                        light.Position.Z  = b.ReadSingle();
                        light.Height      = b.ReadSingle();
                        light.Direction.X = b.ReadSingle();
                        light.Direction.Y = b.ReadSingle();
                        light.Direction.Z = b.ReadSingle();
                        light.Specular    = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());
                        light.Diffuse     = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());
                        light.Ambient     = new KColor(b.ReadByte(), b.ReadByte(), b.ReadByte(), b.ReadByte());
                        light.LightType   = (LightsType)b.ReadInt32();
                        Lights.Add(light);
                    }
                }

                XLog.WriteLine(Levels.Good, "Ok");
            }
            catch (Exception exception)
            {
                Blank();
                XLog.WriteLine(Levels.Error, "Failed");
                XLog.WriteLine(Levels.Fatal, "NflManager::Load<Exception> -> {0}", exception);
            }
        }