Inheritance: MonoBehaviour
Exemple #1
0
        /// <summary>
        /// Multiplies a range of alpha values with a certain factor.
        /// </summary>
        public void ScaleAlphas(float factor, int index, int numVertices)
        {
            if (index < 0 || index >= _numVertices)
            {
                throw new IndexOutOfRangeException("Invalid vertex index");
            }

            if (factor == 1.0f)
            {
                return;
            }

            int minAlpha = _premultipliedAlpha ? (int)(MinAlpha * 255.0f) : 0;

            for (int i = index; i < index + numVertices; ++i)
            {
                VertexColor vertexColor = _vertexColors[i];
                byte        newAlpha    = Convert.ToByte(MathUtil.Clamp(vertexColor.A * factor, minAlpha, 255));

                if (_premultipliedAlpha)
                {
                    vertexColor      = VertexColorHelper.UnmultiplyAlpha(vertexColor);
                    vertexColor.A    = newAlpha;
                    _vertexColors[i] = VertexColorHelper.PremultiplyAlpha(vertexColor);
                }
                else
                {
                    _vertexColors[i] = VertexColorHelper.CreateVertexColor(vertexColor.R, vertexColor.G, vertexColor.B, newAlpha);
                }
            }
        }
Exemple #2
0
 public void CompareVertexColor(VertexColor expected, VertexColor v2)
 {
     if (expected.R != v2.R || expected.B != v2.B || expected.G != v2.G || expected.A != v2.A)
     {
         Assert.Fail("Excepted: " + expected.R + " " + expected.G + " " + expected.B + " " + expected.A + " " +
                     " actual: " + v2.R + " " + v2.G + " " + v2.B + " " + v2.A);
     }
 }
Exemple #3
0
 public Vertex(ushort word1, ushort word2)
 {
     _x       = (byte)(word1 & 0xFF);
     _y       = (byte)((word1 >> 8) & 0xFF);
     _z       = (byte)(word2 & 0xFF);
     _color   = (VertexColor)((word2 >> 8) & 3);
     _intense = ((word2 >> 10) & 1) == 1;
 }
Exemple #4
0
 public void Execute(int index)
 {
     outputVertices[index] = new VertexColor
     {
         pos  = vertices[index],
         norm = normals[index],
         col  = colors[index],
     };
 }
        public override void UpdateEntity(uint entity)
        {
            CPosition  position  = (CPosition)positions[entity];
            CDimension dimension = (CDimension)dimensions[entity];
            CTransform transform = (CTransform)transforms[entity];
            CColor     color     = (CColor)colors[entity];

            transformData[entity] = CreateVertexTransform(position, dimension, transform);
            colorData[entity]     = new VertexColor(color.Color);
        }
Exemple #6
0
        public static VertexColor CreateVertexColor(byte r, byte g, byte b, byte a)
        {
            VertexColor vertexColor = new VertexColor();

            vertexColor.R = r;
            vertexColor.G = g;
            vertexColor.B = b;
            vertexColor.A = a;

            return(vertexColor);
        }
Exemple #7
0
        private static VertexColor GetVertexColorFromStream(Stream s, int vtStart)
        {
            var normal = new VertexColor();

            s.Position = vtStart + 12;
            normal.R   = s.ReadByte() / 255.0F;
            normal.G   = s.ReadByte() / 255.0F;
            normal.B   = s.ReadByte() / 255.0F;
            normal.A   = s.ReadByte() / 255.0F;
            return(normal);
        }
        public static VertexColor CreateVertexColor(byte r, byte g, byte b, byte a)
        {
            VertexColor vertexColor = new VertexColor();

            vertexColor.R = r;
            vertexColor.G = g;
            vertexColor.B = b;
            vertexColor.A = a;

            return vertexColor;
        }
        public static VertexColor CreateVertexColor(uint color, float alpha)
        {
            VertexColor vertexColor = new VertexColor();

            vertexColor.R = ColorUtil.GetR(color);
            vertexColor.G = ColorUtil.GetG(color);
            vertexColor.B = ColorUtil.GetB(color);

            vertexColor.A = (byte)(alpha * 255.0f + 0.5f);

            return vertexColor;
        }
Exemple #10
0
        public static VertexColor CreateVertexColor(uint color, float alpha)
        {
            VertexColor vertexColor = new VertexColor();

            vertexColor.R = ColorUtil.GetR(color);
            vertexColor.G = ColorUtil.GetG(color);
            vertexColor.B = ColorUtil.GetB(color);

            vertexColor.A = (byte)(alpha * 255.0f + 0.5f);

            return(vertexColor);
        }
Exemple #11
0
        /// <summary>
        /// Updates the color of a vertex. The method always expects non-premultiplied alpha values.
        /// </summary>
        public void SetColor(int atIndex, uint color, float alpha)
        {
            if (atIndex < 0 || atIndex >= _numVertices)
            {
                throw new IndexOutOfRangeException("Invalid vertex index");
            }

            alpha = MathUtil.Clamp(alpha, _premultipliedAlpha ? MinAlpha : 0.0f, 1.0f);

            VertexColor vertexColor = VertexColorHelper.CreateVertexColor(color, alpha);

            _vertexColors[atIndex] = _premultipliedAlpha ? VertexColorHelper.PremultiplyAlpha(vertexColor) : vertexColor;
        }
        public static VertexColor PremultiplyAlpha(VertexColor color)
        {
            float alpha = color.A / 255.0f;

            if (alpha == 1.0f)
            {
                return(color);
            }
            return(CreateVertexColor(
                       (byte)(color.R * alpha + 0.5f),
                       (byte)(color.G * alpha + 0.5f),
                       (byte)(color.B * alpha + 0.5f),
                       color.A));
        }
        public void ChangeColor(IVertex vertex, VertexColor newColor)
        {
            var oldColor = vertex.Color;

            System.Action redo = () =>
            {
                vertex.Color = newColor;
            };
            System.Action undo = () =>
            {
                vertex.Color = oldColor;
            };

            UndoRedoManager.Instance.AddAndExecute(new SimpleOperation(redo, undo));
        }
Exemple #14
0
        /// <summary>
        /// Writes the given RGB and alpha values to the specified vertices.
        /// </summary>
        public void Colorize(uint color, float alpha, int vertexId, int numVertices)
        {
            if (numVertices < 0 || vertexId + numVertices > _numVertices)
            {
                numVertices = _numVertices - vertexId;
            }

            alpha = MathUtil.Clamp(alpha, _premultipliedAlpha ? MinAlpha : 0.0f, 1.0f);
            VertexColor vertexColor = VertexColorHelper.CreateVertexColor(color, alpha);
            VertexColor col         = _premultipliedAlpha ? VertexColorHelper.PremultiplyAlpha(vertexColor) : vertexColor;

            for (int i = vertexId; i < numVertices; i++)
            {
                _vertexColors[i] = col;
            }
        }
Exemple #15
0
        /// <summary>
        /// Returns the RGB color of a vertex (without premultiplied alpha).
        /// </summary>
        public uint GetColor(int index)
        {
            if (index < 0 || index >= _numVertices)
            {
                throw new IndexOutOfRangeException("Invalid vertex index");
            }

            VertexColor vertexColor = _vertexColors[index];

            if (_premultipliedAlpha)
            {
                vertexColor = VertexColorHelper.UnmultiplyAlpha(vertexColor);
            }

            return(ColorUtil.GetRGB(vertexColor.R, vertexColor.G, vertexColor.B));
        }
        public static VertexColor UnmultiplyAlpha(VertexColor color)
        {
            float alpha = color.A / 255.0f;

            if (alpha == 0.0f || alpha == 1.0f)
            {
                return(color);
            }
            // 0.5f is added to prevent rounding issues, see
            // http://stackoverflow.com/questions/25703304/why-does-a-division-result-differ-based-on-the-cast-type
            return(VertexColorHelper.CreateVertexColor(
                       (byte)(color.R / alpha + 0.5f),
                       (byte)(color.G / alpha + 0.5f),
                       (byte)(color.B / alpha + 0.5f),
                       color.A));
        }
        public static VertexColor PremultiplyAlpha(VertexColor color)
        {
            float alpha = color.A / 255.0f;

            if (alpha == 1.0f)
            {
                return color;
            }
            else
            {
                return VertexColorHelper.CreateVertexColor(
                    (byte)(color.R * alpha + 0.5f),
                    (byte)(color.G * alpha + 0.5f),
                    (byte)(color.B * alpha + 0.5f),
                    color.A);
            }
        }
        public static VertexColor UnmultiplyAlpha(VertexColor color)
        {
            float alpha = color.A / 255.0f;

            if (alpha == 0.0f || alpha == 1.0f)
            {
                return color;
            }
            else
            {
                // 0.5f is added to prevent rounding issues, see 
                // http://stackoverflow.com/questions/25703304/why-does-a-division-result-differ-based-on-the-cast-type
                return VertexColorHelper.CreateVertexColor(
                    (byte)(color.R / alpha + 0.5f),
                    (byte)(color.G / alpha + 0.5f),
                    (byte)(color.B / alpha + 0.5f),
                    color.A);
            }
        }
            public override void Parse(string line)
            {
                string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                var x = parts[0].ParseInvariantFloat();
                var y = parts[1].ParseInvariantFloat();
                var z = parts[2].ParseInvariantFloat();

                var r = parts[3].ParseInvariantDec();
                var g = parts[4].ParseInvariantDec();
                var b = parts[5].ParseInvariantDec();

                var vertex = new Vertex(x, y, z);

                _vertexDataStore.AddVertex(vertex);

                var vcol = new VertexColor(r, g, b);

                _vertexColorDataStore.AddColor(vcol);
            }
 public VertexColor(int index) : base(dataSize, index)
 {
     inst = this;
 }
        public void Read(Reader reader)
        {
            offset = Pointer.Current(reader);
            if (geo.Type == 4 || geo.Type == 5 || geo.Type == 6)
            {
                // Optimized
                num_vertices_actual = reader.ReadUInt32();
                num_vertices        = reader.ReadUInt32();
                num_uvs             = reader.ReadUInt32();
                unk3 = reader.ReadUInt32();
            }
            else
            {
                num_vertices        = geo.num_triangles[index] * 3;
                num_uvs             = (num_vertices + 3) >> 2;
                num_vertices_actual = num_vertices;
            }
            VisualMaterial vm = geo.visualMaterials[index];
            bool           hasUv0 = true, hasUv1 = false, hasNormals = false;
            uint           num_textures = 1;

            if (vm != null && vm.num_textures_in_material > 0)
            {
                hasUv0       = false;
                num_textures = vm.num_textures_in_material;
                for (int i = 0; i < vm.num_textures_in_material; i++)
                {
                    switch (vm.textures[i].uvFunction)
                    {
                    case 4: hasNormals = true; break;

                    case 1: hasUv1 = true; break;

                    case 0: hasUv0 = true; break;
                    }
                }
            }
            vertices = new Vertex[num_vertices];
            for (int i = 0; i < num_vertices; i++)
            {
                vertices[i] = new Vertex(reader);
            }
            if (geo.Type == 1 && Settings.s.game == Settings.Game.R3)
            {
                uvUnoptimized = new UVUnoptimized[num_vertices];
                for (int i = 0; i < uvUnoptimized.Length; i++)
                {
                    uvUnoptimized[i] = new UVUnoptimized(reader);
                }
            }
            else
            {
                if (hasUv0)
                {
                    uv0 = new TexCoord[num_uvs];
                    for (int i = 0; i < uv0.Length; i++)
                    {
                        uv0[i] = new TexCoord(reader);
                    }
                }
                if (hasUv1)
                {
                    uv1 = new TexCoord[num_uvs];
                    for (int i = 0; i < uv1.Length; i++)
                    {
                        uv1[i] = new TexCoord(reader);
                    }
                }
                if (hasNormals)
                {
                    normals = new Normal[num_vertices];
                    for (int i = 0; i < normals.Length; i++)
                    {
                        normals[i] = new Normal(reader);
                    }
                }
                if ((geo.flags & 0x100) != 0)
                {
                    uv_unk = new TexCoord[num_uvs];
                    for (int i = 0; i < uv_unk.Length; i++)
                    {
                        uv_unk[i] = new TexCoord(reader);
                    }
                }
            }
            colors = new VertexColor[num_textures][];             // Seem to be in a color-like format? 7F 7F 7F 80, repeated 4 times
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = new VertexColor[num_uvs];
                for (int j = 0; j < colors[i].Length; j++)
                {
                    colors[i][j] = new VertexColor(reader);
                }
            }
            if (geo.isSinus != 0)
            {
                sinusState = new VectorForSinusEffect[num_uvs];
                for (int i = 0; i < sinusState.Length; i++)
                {
                    sinusState[i] = new VectorForSinusEffect(reader);
                }
            }
            if ((index < geo.num_elements - 1 && Pointer.Current(reader) != geo.off_elements_array[index + 1]) ||
                (index == geo.num_elements - 1 && Pointer.Current(reader) != geo.off_uint1))
            {
                UnityEngine.Debug.LogWarning("B " + geo.Offset + " - " + offset + " - " + hasUv0 + " - " + hasUv1 + " - " + hasNormals);
            }
            else
            {
                //UnityEngine.Debug.LogWarning("G " + geo.Offset + " - " + offset + " - " + hasUv0 + " - " + hasUv1 + " - " + hasUv4);
            }

            /*normals = new Vertex[num_vertices];
             * for (int i = 0; i < num_vertices; i++) {
             *      normals[i] = new Vertex(reader);
             * }*/
        }
 public static bool IsOpaqueWhite(VertexColor color)
 {
     return color.A == 255 && color.R == 255 && color.G == 255 && color.B == 255;
 }
Exemple #23
0
 public static bool IsOpaqueWhite(VertexColor color)
 {
     return(color.A == 255 && color.R == 255 && color.G == 255 && color.B == 255);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="dirPath">マテリアルを読み込むために必要。</param>
        /// <returns></returns>
        public static Obj LoadObjWithMaterial(string[] data, string dirPath)
        {
            var obj = new Obj(data.Length / 3);

            foreach (var line in data)
            {
                string[] parts = line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length > 0)
                {
                    switch (parts[0])
                    {
                    case "usemtl":
                        obj.CurrentMtl = parts[1];
                        break;

                    case "mtllib":
                        obj.MtlFileList.Add(parts[1]);
                        break;

                    case "v":
                        var v = Vertex.LoadFromStringArray(parts);
                        obj.VertexList.Add(v);
                        v.Index = obj.VertexList.Count;

                        if (parts.Length == 7)
                        {
                            var vc = VertexColor.LoadFromStringArray(parts);
                            obj.VertexColorList.Add(vc);
                            vc.Index = obj.VertexColorList.Count;
                        }

                        break;

                    case "f":
                        var f = Face.LoadFromStringArray(parts);
                        f.UseMtl = obj.CurrentMtl;
                        obj.FaceList.Add(f);
                        break;

                    case "vt":
                        var uv = Uv.LoadFromStringArray(parts);
                        obj.UvList.Add(uv);
                        uv.Index = obj.UvList.Count;
                        break;

                    case "vn":
                        var vn = NormalVector.LoadFromStringArray(parts);
                        obj.NormalVectorList.Add(vn);
                        vn.Index = obj.NormalVectorList.Count;
                        break;
                    }
                }
            }

            if (obj.VertexColorList.Count != 0)
            {
                obj.ColorType = ColorType.VertexColor;
            }

            var hasTexture = obj.FaceList.FirstOrDefault()?.IsTextureEnable ?? false;

            if (hasTexture)
            {
                obj.ColorType = ColorType.TextureColor;
            }

            foreach (var mtlFile in obj.MtlFileList)
            {
                var lines = File.ReadAllLines(Path.Combine(dirPath, mtlFile));
                var mtl   = MtlLoader.LoadMtl(lines);
                obj.MtlList.Add(mtl);
            }

            return(obj);
        }
Exemple #25
0
 /// <summary>
 /// Конструктор с возможностью задания цвета вершины.
 /// </summary>
 /// <param name="color">Цвет вершины.</param>
 public DataVertex(VertexColor color)
 {
     Color = color;
 }
Exemple #26
0
        private void createAdjAndOut()
        {
            AMatrix = new int[Vertices.Count, Vertices.Count];
            Graph.fillAdjacencyMatrix(Vertices.Count, Edges, AMatrix);
            listBox.Items.Clear();
            listBox1.Items.Clear();
            string        freqSrt = textBox1.Text;
            List <double> freq    = new List <double>();

            string[] sizes = freqSrt.Split(' ', '\t');
            foreach (var i in sizes)
            {
                string str = "";
                if (i.Contains("."))
                {
                    str = i.Replace('.', ',');
                }
                else
                {
                    str = i;
                }

                double m = Convert.ToDouble(str);
                freq.Add(m);
            }

            List <VertexColor> graph = new List <VertexColor>();

            //степени вершин
            for (int i2 = 0; i2 < Vertices.Count; i2++)
            {
                VertexColor item = new VertexColor(i2, 0, 0);
                for (int j2 = 0; j2 < Vertices.Count; j2++)
                {
                    if (AMatrix[i2, j2] == 1)
                    {
                        item.stepen++;
                    }
                }
                graph.Add(item);
            }
            graph = graph.OrderBy(z => z.stepen).ToList();

            List <string> wordList = new List <string>();

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            // список возможных слов для неполного графа (длина до m-2)
            for (int i = 1; i <= (graph.Count - 2); i++)
            {
                List <string> local = getStringList(i, new string[] { "0", "1" });
                foreach (var str in local)
                {
                    wordList.Add(str);
                }
            }

            //находим несмежные вершины (нумерация с 0)
            int n1 = graph[0].number;
            int n2 = graph[1].number;

            IEnumerable <string> myEnumerable          = wordList;
            IEnumerable <IEnumerable <string> > result =
                GetCombinations <string>(myEnumerable, (graph.Count - 1));

            List <List <string> > wRepeatCodeCombinations = new List <List <string> >();

            foreach (var code in result)
            {
                bool hasRepeat = AreAnyDuplicates(code);
                if (!hasRepeat)
                {
                    if (!wRepeatCodeCombinations.Contains(code))
                    {
                        ;
                    }
                    wRepeatCodeCombinations.Add(code.ToList());
                }
            }

            List <List <string> > prefixCodes = new List <List <string> >();

            // check prefix
            foreach (var code in wRepeatCodeCombinations)
            {
                bool checkPrefixCode = CheckPrefixCode(code);
                if (checkPrefixCode)
                {
                    // вставляем элемент для n вершины (для исходного графа)
                    string str1 = code[n1];
                    code.Insert(n2, str1);
                    prefixCodes.Add(code);
                }
            }

            List <List <int> > spectrMatrix = new List <List <int> >();

            foreach (var code in prefixCodes)
            {
                List <int> dItem = new List <int>();
                foreach (string str in code)
                {
                    dItem.Add(str.Length);
                }
                spectrMatrix.Add(dItem);
            }

            List <int> indexToRemove = new List <int>();

            for (int i = 0; i < spectrMatrix.Count; i++)
            {
                for (int j = i + 1; j < spectrMatrix.Count; j++)
                {
                    int m = MajorizesOrMatches(spectrMatrix[i], spectrMatrix[j]);
                    if (m == 1)
                    {
                        if (!indexToRemove.Contains(i))
                        {
                            indexToRemove.Add(i);
                        }
                    }
                    if (m == 2)
                    {
                        if (!indexToRemove.Contains(j))
                        {
                            indexToRemove.Add(j);
                        }
                    }
                }
            }

            var indexToRemove1 = indexToRemove.OrderByDescending(x => x);

            foreach (var ind1 in indexToRemove1)
            {
                prefixCodes.RemoveAt(ind1);
                spectrMatrix.RemoveAt(ind1);
            }


            int    ind        = 0;
            double globalCost = 1000000000;

            foreach (var spectr in spectrMatrix)
            {
                double cost = 0;
                for (int i = 0; i < spectr.Count; i++)
                {
                    cost += spectr[i] * freq[i];
                }
                if (cost < globalCost)
                {
                    globalCost = cost;
                    ind        = spectrMatrix.IndexOf(spectr);
                }
            }
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            mTime.Text = elapsedTime;

            mCost.Text = globalCost.ToString();
            string sp = "";
            var    s  = spectrMatrix[ind];

            foreach (var m in s)
            {
                sp += m.ToString() + " ";
            }
            mSpectrum.Text = sp;

            foreach (var d in spectrMatrix)
            {
                string str = "";
                foreach (int m in d)
                {
                    str += m + " ";
                }
                listBox.Items.Add(str);
            }

            foreach (var code in prefixCodes)
            {
                string str = "";
                foreach (var c in code)
                {
                    str += c + ", ";
                }
                listBox1.Items.Add(str);
            }
        }
 public static UnityEngine.Color AsColor(this VertexColor v)
 {
     return(new UnityEngine.Color(v.R, v.G, v.B));
 }
Exemple #28
0
 public DataVertex(VertexColor color, VertexType type, double cost)
 {
     Color           = color;
     Type            = type;
     this.vertexCost = cost;
 }
Exemple #29
0
 /// <summary>
 /// Конструктор с возможностью задания цвета и типа вершины.
 /// </summary>
 /// <param name="color">Цвет вершины.</param>
 /// <param name="type">Тип вершины.</param>
 public DataVertex(VertexColor color, VertexType type)
 {
     Color = color;
     Type  = type;
 }
Exemple #30
0
            internal void Write(BinaryWriterEx bw, List <LayoutMember> layout, float uvFactor)
            {
                foreach (LayoutMember member in layout)
                {
                    if (member.Semantic == LayoutSemantic.Position)
                    {
                        if (member.Type == LayoutType.Float3)
                        {
                            bw.WriteVector3(Position);
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            bw.WriteVector3(Position);
                            bw.WriteSingle(0);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.BoneWeights)
                    {
                        if (member.Type == LayoutType.Byte4A)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteSByte((sbyte)Math.Round(BoneWeights[i] * 127));
                            }
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteByte((byte)Math.Round(BoneWeights[i] * 255));
                            }
                        }
                        else if (member.Type == LayoutType.UVPair)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteInt16((short)Math.Round(BoneWeights[i] * 32767));
                            }
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteInt16((short)Math.Round(BoneWeights[i] * 32767));
                            }
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.BoneIndices)
                    {
                        if (member.Type == LayoutType.Byte4B)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteByte((byte)BoneIndices[i]);
                            }
                        }
                        else if (member.Type == LayoutType.ShortBoneIndices)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteUInt16((ushort)BoneIndices[i]);
                            }
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                bw.WriteByte((byte)BoneIndices[i]);
                            }
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.Normal)
                    {
                        if (member.Type == LayoutType.Float3)
                        {
                            bw.WriteVector3(Normal);
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            bw.WriteVector3(Normal);
                            bw.WriteSingle(NormalW);
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            WriteByteNormVector3(bw, Normal);
                            bw.WriteByte((byte)NormalW);
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            WriteByteNormVector3(bw, Normal);
                            bw.WriteByte((byte)NormalW);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            WriteByteNormVector3(bw, Normal);
                            bw.WriteByte((byte)NormalW);
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            WriteShortNormVector3(bw, Normal);
                            bw.WriteInt16((short)NormalW);
                        }
                        else if (member.Type == LayoutType.Short4toFloat4B)
                        {
                            WriteUShortNormVector3(bw, Normal);
                            bw.WriteInt16((short)NormalW);
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            WriteByteNormVector3(bw, Normal);
                            bw.WriteByte((byte)NormalW);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.UV)
                    {
                        Vector3 uv = uvQueue.Dequeue() * uvFactor;
                        if (member.Type == LayoutType.Float2)
                        {
                            bw.WriteSingle(uv.X);
                            bw.WriteSingle(uv.Y);
                        }
                        else if (member.Type == LayoutType.Float3)
                        {
                            bw.WriteVector3(uv);
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            bw.WriteSingle(uv.X);
                            bw.WriteSingle(uv.Y);

                            uv = uvQueue.Dequeue() * uvFactor;
                            bw.WriteSingle(uv.X);
                            bw.WriteSingle(uv.Y);
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.Short2toFloat2)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.UV)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.UVPair)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));

                            uv = uvQueue.Dequeue() * uvFactor;
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                        }
                        else if (member.Type == LayoutType.Short4toFloat4B)
                        {
                            bw.WriteInt16((short)Math.Round(uv.X));
                            bw.WriteInt16((short)Math.Round(uv.Y));
                            bw.WriteInt16((short)Math.Round(uv.Z));
                            bw.WriteInt16(0);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.Tangent)
                    {
                        Vector4 tangent = tangentQueue.Dequeue();
                        if (member.Type == LayoutType.Float4)
                        {
                            bw.WriteVector4(tangent);
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            WriteByteNormVector4(bw, tangent);
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            WriteByteNormVector4(bw, tangent);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            WriteByteNormVector4(bw, tangent);
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            WriteShortNormVector4(bw, tangent);
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            WriteByteNormVector4(bw, tangent);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.Bitangent)
                    {
                        if (member.Type == LayoutType.Byte4A)
                        {
                            WriteByteNormVector4(bw, Bitangent);
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            WriteByteNormVector4(bw, Bitangent);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            WriteByteNormVector4(bw, Bitangent);
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            WriteByteNormVector4(bw, Bitangent);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.VertexColor)
                    {
                        VertexColor color = colorQueue.Dequeue();
                        if (member.Type == LayoutType.Float4)
                        {
                            color.WriteFloatRGBA(bw);
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            color.WriteByteARGB(bw);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            color.WriteByteRGBA(bw);
                        }
                        else
                        {
                            throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else
                    {
                        throw new NotImplementedException($"Write not implemented for {member.Type} {member.Semantic}.");
                    }
                }
            }
Exemple #31
0
            internal void Read(BinaryReaderEx br, List <LayoutMember> layout, float uvFactor)
            {
                foreach (LayoutMember member in layout)
                {
                    if (member.Semantic == LayoutSemantic.Position)
                    {
                        if (member.Type == LayoutType.Float3)
                        {
                            Position = br.ReadVector3();
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            Position = br.ReadVector3();
                            br.AssertSingle(0);
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.BoneWeights)
                    {
                        if (member.Type == LayoutType.Byte4A)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneWeights[i] = br.ReadSByte() / 127f;
                            }
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneWeights[i] = br.ReadByte() / 255f;
                            }
                        }
                        else if (member.Type == LayoutType.UVPair)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneWeights[i] = br.ReadInt16() / 32767f;
                            }
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneWeights[i] = br.ReadInt16() / 32767f;
                            }
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }

                        UsesBoneWeights = true;
                    }
                    else if (member.Semantic == LayoutSemantic.BoneIndices)
                    {
                        if (member.Type == LayoutType.Byte4B)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneIndices[i] = br.ReadByte();
                            }
                        }
                        else if (member.Type == LayoutType.ShortBoneIndices)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneIndices[i] = br.ReadUInt16();
                            }
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                BoneIndices[i] = br.ReadByte();
                            }
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }

                        UsesBoneIndices = true;
                    }
                    else if (member.Semantic == LayoutSemantic.Normal)
                    {
                        if (member.Type == LayoutType.Float3)
                        {
                            Normal = br.ReadVector3();
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            Normal = br.ReadVector3();
                            float w = br.ReadSingle();
                            NormalW = (int)w;
                            if (w != NormalW)
                            {
                                throw new InvalidDataException($"Float4 Normal W was not a whole number: {w}");
                            }
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            Normal  = ReadByteNormVector3(br);
                            NormalW = br.ReadByte();
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            Normal  = ReadByteNormVector3(br);
                            NormalW = br.ReadByte();
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            Normal  = ReadByteNormVector3(br);
                            NormalW = br.ReadByte();
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            Normal  = ReadShortNormVector3(br);
                            NormalW = br.ReadInt16();
                        }
                        else if (member.Type == LayoutType.Short4toFloat4B)
                        {
                            Normal  = ReadUShortNormVector3(br);
                            NormalW = br.ReadInt16();
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            Normal  = ReadByteNormVector3(br);
                            NormalW = br.ReadByte();
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.UV)
                    {
                        if (member.Type == LayoutType.Float2)
                        {
                            UVs.Add(new Vector3(br.ReadVector2(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Float3)
                        {
                            UVs.Add(br.ReadVector3() / uvFactor);
                        }
                        else if (member.Type == LayoutType.Float4)
                        {
                            UVs.Add(new Vector3(br.ReadVector2(), 0) / uvFactor);
                            UVs.Add(new Vector3(br.ReadVector2(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Short2toFloat2)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.UV)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.UVPair)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), 0) / uvFactor);
                        }
                        else if (member.Type == LayoutType.Short4toFloat4B)
                        {
                            UVs.Add(new Vector3(br.ReadInt16(), br.ReadInt16(), br.ReadInt16()) / uvFactor);
                            br.AssertInt16(0);
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.Tangent)
                    {
                        if (member.Type == LayoutType.Float4)
                        {
                            Tangents.Add(br.ReadVector4());
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            Tangents.Add(ReadByteNormVector4(br));
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            Tangents.Add(ReadByteNormVector4(br));
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            Tangents.Add(ReadByteNormVector4(br));
                        }
                        else if (member.Type == LayoutType.Short4toFloat4A)
                        {
                            Tangents.Add(ReadShortNormVector4(br));
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            Tangents.Add(ReadByteNormVector4(br));
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.Bitangent)
                    {
                        if (member.Type == LayoutType.Byte4A)
                        {
                            Bitangent = ReadByteNormVector4(br);
                        }
                        else if (member.Type == LayoutType.Byte4B)
                        {
                            Bitangent = ReadByteNormVector4(br);
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            Bitangent = ReadByteNormVector4(br);
                        }
                        else if (member.Type == LayoutType.Byte4E)
                        {
                            Bitangent = ReadByteNormVector4(br);
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else if (member.Semantic == LayoutSemantic.VertexColor)
                    {
                        if (member.Type == LayoutType.Float4)
                        {
                            Colors.Add(VertexColor.ReadFloatRGBA(br));
                        }
                        else if (member.Type == LayoutType.Byte4A)
                        {
                            Colors.Add(VertexColor.ReadByteARGB(br));
                        }
                        else if (member.Type == LayoutType.Byte4C)
                        {
                            Colors.Add(VertexColor.ReadByteRGBA(br));
                        }
                        else
                        {
                            throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                        }
                    }
                    else
                    {
                        throw new NotImplementedException($"Read not implemented for {member.Type} {member.Semantic}.");
                    }
                }
            }
Exemple #32
0
 void Awake()
 {
     vertexColor = GetComponentInChildren<VertexColor>();
     alive = false;
     busy = false;
 }
Exemple #33
0
		public void Set(IVertex item, VertexColor color)
		{
			items[item] = color;
		}
Exemple #34
0
        public void countHuffman()
        {
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            AMatrix = new int[Vertices.Count, Vertices.Count];
            Graph.fillAdjacencyMatrix(Vertices.Count, Edges, AMatrix);
            string        freqSrt = textBox1.Text;
            List <double> freq1   = new List <double>();

            string[] sizes = freqSrt.Split(' ', '\t');
            foreach (var i in sizes)
            {
                string str11 = "";
                if (i.Contains("."))
                {
                    str11 = i.Replace('.', ',');
                }
                else
                {
                    str11 = i;
                }

                double m = Convert.ToDouble(str11);
                freq1.Add(m);
            }

            List <VertexColor> graph = new List <VertexColor>();

            //степени вершин
            for (int i2 = 0; i2 < Vertices.Count; i2++)
            {
                VertexColor item = new VertexColor(i2, 0, 0);
                for (int j2 = 0; j2 < Vertices.Count; j2++)
                {
                    if (AMatrix[i2, j2] == 1)
                    {
                        item.stepen++;
                    }
                }
                graph.Add(item);
            }

            graph = graph.OrderBy(z => z.stepen).ToList();

            //находим несмежные вершины (нумерация с 0)
            int n1 = graph[0].number; // во внисчмание не берем при построении преф кода
            int n2 = graph[1].number;

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            List <double> freq = new List <double>();

            foreach (var d in freq1)
            {
                freq.Add(d);
            }

            freq[n2] += freq[n1];
            List <Element> q = new List <Element>();

            for (int i = 0; i < freq.Count; i++)
            {
                Element el = new Element();
                el.key   = i;
                el.value = freq[i];
                q.Add(el);
            }
            q.Remove(q[n1]);

            //freq.RemoveAt(n1);

            List <HuffmanNode> nodeList = new List <HuffmanNode>();

            foreach (var el in q)
            {
                nodeList.Add(new HuffmanNode(el.key.ToString(), el.value));
            }

            nodeList.Sort();

            GetTreeFromList(nodeList);
            SetCodeToTheTree("", nodeList[0]);
            Dictionary <int, string> prefCode = new Dictionary <int, string>();

            PrintfLeafAndCodes(nodeList[0], prefCode);
            var prefCode1 = prefCode.OrderBy(x => x.Key);

            List <string> code = new List <string>();

            foreach (var item in prefCode1)
            {
                code.Add(item.Value);
            }
            code.Insert(n1, code[n2 - 1]);

            List <int> spectr = new List <int>();

            foreach (var item in code)
            {
                spectr.Add(item.Length);
            }

            double cost = 0;

            for (int i = 0; i < spectr.Count; i++)
            {
                cost += freq1[i] * spectr[i];
            }

            hCost.Text = cost.ToString();

            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            hTime.Text = elapsedTime;
            string str = "";

            foreach (var d in spectr)
            {
                str += d + " ";
            }
            listBox2.Items.Add(str);

            string str1 = "";

            foreach (var m in code)
            {
                str1 += m + ", ";
            }
            listBox3.Items.Add(str1);
        }
        public IVertex AddVertex(double x, double y, int index, string name, string title, VertexColor color)
        {
            var existingVertex = FindVertexByIndex(index);

            if (existingVertex != null)
            {
                return(existingVertex);
            }
            var v = new Vertex(x, y, index)
            {
                Name  = name,
                Title = title,
                Color = color
            };

            return(Add(v, true));
        }
Exemple #36
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (Type != null)
                {
                    hashCode = hashCode * 59 + Type.GetHashCode();
                }

                if (Visible != null)
                {
                    hashCode = hashCode * 59 + Visible.GetHashCode();
                }

                if (LegendGroup != null)
                {
                    hashCode = hashCode * 59 + LegendGroup.GetHashCode();
                }

                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }

                if (UId != null)
                {
                    hashCode = hashCode * 59 + UId.GetHashCode();
                }

                if (Ids != null)
                {
                    hashCode = hashCode * 59 + Ids.GetHashCode();
                }

                if (CustomData != null)
                {
                    hashCode = hashCode * 59 + CustomData.GetHashCode();
                }

                if (Meta != null)
                {
                    hashCode = hashCode * 59 + Meta.GetHashCode();
                }

                if (MetaArray != null)
                {
                    hashCode = hashCode * 59 + MetaArray.GetHashCode();
                }

                if (HoverLabel != null)
                {
                    hashCode = hashCode * 59 + HoverLabel.GetHashCode();
                }

                if (Stream != null)
                {
                    hashCode = hashCode * 59 + Stream.GetHashCode();
                }

                if (UiRevision != null)
                {
                    hashCode = hashCode * 59 + UiRevision.GetHashCode();
                }

                if (X != null)
                {
                    hashCode = hashCode * 59 + X.GetHashCode();
                }

                if (Y != null)
                {
                    hashCode = hashCode * 59 + Y.GetHashCode();
                }

                if (Z != null)
                {
                    hashCode = hashCode * 59 + Z.GetHashCode();
                }

                if (I != null)
                {
                    hashCode = hashCode * 59 + I.GetHashCode();
                }

                if (J != null)
                {
                    hashCode = hashCode * 59 + J.GetHashCode();
                }

                if (K != null)
                {
                    hashCode = hashCode * 59 + K.GetHashCode();
                }

                if (Text != null)
                {
                    hashCode = hashCode * 59 + Text.GetHashCode();
                }

                if (TextArray != null)
                {
                    hashCode = hashCode * 59 + TextArray.GetHashCode();
                }

                if (HoverText != null)
                {
                    hashCode = hashCode * 59 + HoverText.GetHashCode();
                }

                if (HoverTextArray != null)
                {
                    hashCode = hashCode * 59 + HoverTextArray.GetHashCode();
                }

                if (HoverTemplate != null)
                {
                    hashCode = hashCode * 59 + HoverTemplate.GetHashCode();
                }

                if (HoverTemplateArray != null)
                {
                    hashCode = hashCode * 59 + HoverTemplateArray.GetHashCode();
                }

                if (DelaunaYAxis != null)
                {
                    hashCode = hashCode * 59 + DelaunaYAxis.GetHashCode();
                }

                if (AlphaHull != null)
                {
                    hashCode = hashCode * 59 + AlphaHull.GetHashCode();
                }

                if (Intensity != null)
                {
                    hashCode = hashCode * 59 + Intensity.GetHashCode();
                }

                if (IntensityMode != null)
                {
                    hashCode = hashCode * 59 + IntensityMode.GetHashCode();
                }

                if (Color != null)
                {
                    hashCode = hashCode * 59 + Color.GetHashCode();
                }

                if (VertexColor != null)
                {
                    hashCode = hashCode * 59 + VertexColor.GetHashCode();
                }

                if (FaceColor != null)
                {
                    hashCode = hashCode * 59 + FaceColor.GetHashCode();
                }

                if (CAuto != null)
                {
                    hashCode = hashCode * 59 + CAuto.GetHashCode();
                }

                if (CMin != null)
                {
                    hashCode = hashCode * 59 + CMin.GetHashCode();
                }

                if (CMax != null)
                {
                    hashCode = hashCode * 59 + CMax.GetHashCode();
                }

                if (CMid != null)
                {
                    hashCode = hashCode * 59 + CMid.GetHashCode();
                }

                if (ColorScale != null)
                {
                    hashCode = hashCode * 59 + ColorScale.GetHashCode();
                }

                if (AutoColorScale != null)
                {
                    hashCode = hashCode * 59 + AutoColorScale.GetHashCode();
                }

                if (ReverseScale != null)
                {
                    hashCode = hashCode * 59 + ReverseScale.GetHashCode();
                }

                if (ShowScale != null)
                {
                    hashCode = hashCode * 59 + ShowScale.GetHashCode();
                }

                if (ColorBar != null)
                {
                    hashCode = hashCode * 59 + ColorBar.GetHashCode();
                }

                if (ColorAxis != null)
                {
                    hashCode = hashCode * 59 + ColorAxis.GetHashCode();
                }

                if (Opacity != null)
                {
                    hashCode = hashCode * 59 + Opacity.GetHashCode();
                }

                if (FlatShading != null)
                {
                    hashCode = hashCode * 59 + FlatShading.GetHashCode();
                }

                if (Contour != null)
                {
                    hashCode = hashCode * 59 + Contour.GetHashCode();
                }

                if (LightPosition != null)
                {
                    hashCode = hashCode * 59 + LightPosition.GetHashCode();
                }

                if (Lighting != null)
                {
                    hashCode = hashCode * 59 + Lighting.GetHashCode();
                }

                if (HoverInfo != null)
                {
                    hashCode = hashCode * 59 + HoverInfo.GetHashCode();
                }

                if (HoverInfoArray != null)
                {
                    hashCode = hashCode * 59 + HoverInfoArray.GetHashCode();
                }

                if (ShowLegend != null)
                {
                    hashCode = hashCode * 59 + ShowLegend.GetHashCode();
                }

                if (XCalendar != null)
                {
                    hashCode = hashCode * 59 + XCalendar.GetHashCode();
                }

                if (YCalendar != null)
                {
                    hashCode = hashCode * 59 + YCalendar.GetHashCode();
                }

                if (ZCalendar != null)
                {
                    hashCode = hashCode * 59 + ZCalendar.GetHashCode();
                }

                if (Scene != null)
                {
                    hashCode = hashCode * 59 + Scene.GetHashCode();
                }

                if (IdsSrc != null)
                {
                    hashCode = hashCode * 59 + IdsSrc.GetHashCode();
                }

                if (CustomDataSrc != null)
                {
                    hashCode = hashCode * 59 + CustomDataSrc.GetHashCode();
                }

                if (MetaSrc != null)
                {
                    hashCode = hashCode * 59 + MetaSrc.GetHashCode();
                }

                if (XSrc != null)
                {
                    hashCode = hashCode * 59 + XSrc.GetHashCode();
                }

                if (YSrc != null)
                {
                    hashCode = hashCode * 59 + YSrc.GetHashCode();
                }

                if (ZSrc != null)
                {
                    hashCode = hashCode * 59 + ZSrc.GetHashCode();
                }

                if (ISrc != null)
                {
                    hashCode = hashCode * 59 + ISrc.GetHashCode();
                }

                if (JSrc != null)
                {
                    hashCode = hashCode * 59 + JSrc.GetHashCode();
                }

                if (KSrc != null)
                {
                    hashCode = hashCode * 59 + KSrc.GetHashCode();
                }

                if (TextSrc != null)
                {
                    hashCode = hashCode * 59 + TextSrc.GetHashCode();
                }

                if (HoverTextSrc != null)
                {
                    hashCode = hashCode * 59 + HoverTextSrc.GetHashCode();
                }

                if (HoverTemplateSrc != null)
                {
                    hashCode = hashCode * 59 + HoverTemplateSrc.GetHashCode();
                }

                if (IntensitySrc != null)
                {
                    hashCode = hashCode * 59 + IntensitySrc.GetHashCode();
                }

                if (VertexColorSrc != null)
                {
                    hashCode = hashCode * 59 + VertexColorSrc.GetHashCode();
                }

                if (FaceColorSrc != null)
                {
                    hashCode = hashCode * 59 + FaceColorSrc.GetHashCode();
                }

                if (HoverInfoSrc != null)
                {
                    hashCode = hashCode * 59 + HoverInfoSrc.GetHashCode();
                }

                return(hashCode);
            }
        }
Exemple #37
0
 public Vertex(ushort word1, ushort word2)
 {
     _x = (byte)(word1 & 0xFF);
     _y = (byte)((word1 >> 8) & 0xFF);
     _z = (byte)(word2 & 0xFF);
     _color = (VertexColor)((word2 >> 8) & 3);
     _intense = ((word2 >> 10) & 1) == 1;
 }
Exemple #38
0
        public bool Equals([AllowNull] Mesh3D other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Type == other.Type && Type != null && other.Type != null && Type.Equals(other.Type)) &&
                   (Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (LegendGroup == other.LegendGroup && LegendGroup != null && other.LegendGroup != null && LegendGroup.Equals(other.LegendGroup)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (UId == other.UId && UId != null && other.UId != null && UId.Equals(other.UId)) &&
                   (Equals(Ids, other.Ids) || Ids != null && other.Ids != null && Ids.SequenceEqual(other.Ids)) &&
                   (Equals(CustomData, other.CustomData) || CustomData != null && other.CustomData != null && CustomData.SequenceEqual(other.CustomData)) &&
                   (Meta == other.Meta && Meta != null && other.Meta != null && Meta.Equals(other.Meta)) &&
                   (Equals(MetaArray, other.MetaArray) || MetaArray != null && other.MetaArray != null && MetaArray.SequenceEqual(other.MetaArray)) &&
                   (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) &&
                   (Stream == other.Stream && Stream != null && other.Stream != null && Stream.Equals(other.Stream)) &&
                   (UiRevision == other.UiRevision && UiRevision != null && other.UiRevision != null && UiRevision.Equals(other.UiRevision)) &&
                   (Equals(X, other.X) || X != null && other.X != null && X.SequenceEqual(other.X)) &&
                   (Equals(Y, other.Y) || Y != null && other.Y != null && Y.SequenceEqual(other.Y)) &&
                   (Equals(Z, other.Z) || Z != null && other.Z != null && Z.SequenceEqual(other.Z)) &&
                   (Equals(I, other.I) || I != null && other.I != null && I.SequenceEqual(other.I)) &&
                   (Equals(J, other.J) || J != null && other.J != null && J.SequenceEqual(other.J)) &&
                   (Equals(K, other.K) || K != null && other.K != null && K.SequenceEqual(other.K)) &&
                   (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) &&
                   (Equals(TextArray, other.TextArray) || TextArray != null && other.TextArray != null && TextArray.SequenceEqual(other.TextArray)) &&
                   (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) &&
                   (Equals(HoverTextArray, other.HoverTextArray) || HoverTextArray != null && other.HoverTextArray != null && HoverTextArray.SequenceEqual(other.HoverTextArray)) &&
                   (HoverTemplate == other.HoverTemplate && HoverTemplate != null && other.HoverTemplate != null && HoverTemplate.Equals(other.HoverTemplate)) &&
                   (Equals(HoverTemplateArray, other.HoverTemplateArray) ||
                    HoverTemplateArray != null && other.HoverTemplateArray != null && HoverTemplateArray.SequenceEqual(other.HoverTemplateArray)) &&
                   (DelaunaYAxis == other.DelaunaYAxis && DelaunaYAxis != null && other.DelaunaYAxis != null && DelaunaYAxis.Equals(other.DelaunaYAxis)) &&
                   (AlphaHull == other.AlphaHull && AlphaHull != null && other.AlphaHull != null && AlphaHull.Equals(other.AlphaHull)) &&
                   (Equals(Intensity, other.Intensity) || Intensity != null && other.Intensity != null && Intensity.SequenceEqual(other.Intensity)) &&
                   (IntensityMode == other.IntensityMode && IntensityMode != null && other.IntensityMode != null && IntensityMode.Equals(other.IntensityMode)) &&
                   (Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color)) &&
                   (Equals(VertexColor, other.VertexColor) || VertexColor != null && other.VertexColor != null && VertexColor.SequenceEqual(other.VertexColor)) &&
                   (Equals(FaceColor, other.FaceColor) || FaceColor != null && other.FaceColor != null && FaceColor.SequenceEqual(other.FaceColor)) &&
                   (CAuto == other.CAuto && CAuto != null && other.CAuto != null && CAuto.Equals(other.CAuto)) &&
                   (CMin == other.CMin && CMin != null && other.CMin != null && CMin.Equals(other.CMin)) &&
                   (CMax == other.CMax && CMax != null && other.CMax != null && CMax.Equals(other.CMax)) &&
                   (CMid == other.CMid && CMid != null && other.CMid != null && CMid.Equals(other.CMid)) &&
                   (ColorScale == other.ColorScale && ColorScale != null && other.ColorScale != null && ColorScale.Equals(other.ColorScale)) &&
                   (AutoColorScale == other.AutoColorScale && AutoColorScale != null && other.AutoColorScale != null && AutoColorScale.Equals(other.AutoColorScale)) &&
                   (ReverseScale == other.ReverseScale && ReverseScale != null && other.ReverseScale != null && ReverseScale.Equals(other.ReverseScale)) &&
                   (ShowScale == other.ShowScale && ShowScale != null && other.ShowScale != null && ShowScale.Equals(other.ShowScale)) &&
                   (ColorBar == other.ColorBar && ColorBar != null && other.ColorBar != null && ColorBar.Equals(other.ColorBar)) &&
                   (ColorAxis == other.ColorAxis && ColorAxis != null && other.ColorAxis != null && ColorAxis.Equals(other.ColorAxis)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (FlatShading == other.FlatShading && FlatShading != null && other.FlatShading != null && FlatShading.Equals(other.FlatShading)) &&
                   (Contour == other.Contour && Contour != null && other.Contour != null && Contour.Equals(other.Contour)) &&
                   (LightPosition == other.LightPosition && LightPosition != null && other.LightPosition != null && LightPosition.Equals(other.LightPosition)) &&
                   (Lighting == other.Lighting && Lighting != null && other.Lighting != null && Lighting.Equals(other.Lighting)) &&
                   (HoverInfo == other.HoverInfo && HoverInfo != null && other.HoverInfo != null && HoverInfo.Equals(other.HoverInfo)) &&
                   (Equals(HoverInfoArray, other.HoverInfoArray) || HoverInfoArray != null && other.HoverInfoArray != null && HoverInfoArray.SequenceEqual(other.HoverInfoArray)) &&
                   (ShowLegend == other.ShowLegend && ShowLegend != null && other.ShowLegend != null && ShowLegend.Equals(other.ShowLegend)) &&
                   (XCalendar == other.XCalendar && XCalendar != null && other.XCalendar != null && XCalendar.Equals(other.XCalendar)) &&
                   (YCalendar == other.YCalendar && YCalendar != null && other.YCalendar != null && YCalendar.Equals(other.YCalendar)) &&
                   (ZCalendar == other.ZCalendar && ZCalendar != null && other.ZCalendar != null && ZCalendar.Equals(other.ZCalendar)) &&
                   (Scene == other.Scene && Scene != null && other.Scene != null && Scene.Equals(other.Scene)) &&
                   (IdsSrc == other.IdsSrc && IdsSrc != null && other.IdsSrc != null && IdsSrc.Equals(other.IdsSrc)) &&
                   (CustomDataSrc == other.CustomDataSrc && CustomDataSrc != null && other.CustomDataSrc != null && CustomDataSrc.Equals(other.CustomDataSrc)) &&
                   (MetaSrc == other.MetaSrc && MetaSrc != null && other.MetaSrc != null && MetaSrc.Equals(other.MetaSrc)) &&
                   (XSrc == other.XSrc && XSrc != null && other.XSrc != null && XSrc.Equals(other.XSrc)) &&
                   (YSrc == other.YSrc && YSrc != null && other.YSrc != null && YSrc.Equals(other.YSrc)) &&
                   (ZSrc == other.ZSrc && ZSrc != null && other.ZSrc != null && ZSrc.Equals(other.ZSrc)) &&
                   (ISrc == other.ISrc && ISrc != null && other.ISrc != null && ISrc.Equals(other.ISrc)) &&
                   (JSrc == other.JSrc && JSrc != null && other.JSrc != null && JSrc.Equals(other.JSrc)) &&
                   (KSrc == other.KSrc && KSrc != null && other.KSrc != null && KSrc.Equals(other.KSrc)) &&
                   (TextSrc == other.TextSrc && TextSrc != null && other.TextSrc != null && TextSrc.Equals(other.TextSrc)) &&
                   (HoverTextSrc == other.HoverTextSrc && HoverTextSrc != null && other.HoverTextSrc != null && HoverTextSrc.Equals(other.HoverTextSrc)) &&
                   (HoverTemplateSrc == other.HoverTemplateSrc && HoverTemplateSrc != null && other.HoverTemplateSrc != null && HoverTemplateSrc.Equals(other.HoverTemplateSrc)) &&
                   (IntensitySrc == other.IntensitySrc && IntensitySrc != null && other.IntensitySrc != null && IntensitySrc.Equals(other.IntensitySrc)) &&
                   (VertexColorSrc == other.VertexColorSrc && VertexColorSrc != null && other.VertexColorSrc != null && VertexColorSrc.Equals(other.VertexColorSrc)) &&
                   (FaceColorSrc == other.FaceColorSrc && FaceColorSrc != null && other.FaceColorSrc != null && FaceColorSrc.Equals(other.FaceColorSrc)) &&
                   (HoverInfoSrc == other.HoverInfoSrc && HoverInfoSrc != null && other.HoverInfoSrc != null && HoverInfoSrc.Equals(other.HoverInfoSrc)));
        }