using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace CSGBuilder {
    [Serializable()]
    class Scale : Transformation, ISerializable {
        // A skálázási faktorok
        private double lx, ly, lz;

        #region Properties
        public double Lx {
            get { return lx; }
            set { lx = value; }
        }

        public double Ly {
            get { return ly; }
            set { ly = value; }
        }

        public double Lz {
            get { return lz; }
            set { lz = value; }
        }
        #endregion

        public Scale(double lx, double ly, double lz) {
            this.lx = lx;
            this.ly = ly;
            this.lz = lz;
            SetMatrix();
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
            base.GetObjectData(info, context);
            info.AddValue("Lx", lx);
            info.AddValue("Ly", ly);
            info.AddValue("Lz", lz);
        }

        public Scale(SerializationInfo info, StreamingContext context) : base(info, context) {
            lx = info.GetDouble("Lx");
            ly = info.GetDouble("Ly");
            lz = info.GetDouble("Lz");
        }

        // Elkészíti a transzformációs mátrixot
        public override void SetMatrix() {
            TrMatrix = new Matrix(4, 4);
            TrMatrix.LoadIdentity();
            TrMatrix[0, 0] = lx;
            TrMatrix[1, 1] = ly;
            TrMatrix[2, 2] = lz;
        }

        public override string ToString() {
            return "Scale(" + lx.ToString("F3") + ", " + ly.ToString("F3") + ", " + lz.ToString("F3") + ")";
        }

        public override string Type() {
            return "Scale";
        }

    }
}
