コード例 #1
0
        private int[] GetTotalColor_Recursive(int[] totals, ParticleEffect particleEffect)
        {
            foreach (var particle in particleEffect.ChildParticleEffects)
            {
                //Check for children, and recursively get colors from them
                if (particle.ChildParticleEffects != null)
                {
                    totals = GetTotalColor_Recursive(totals, particle);
                }

                //Get colors from this texture part
                if (particle.IsTextureType())
                {
                    totals[0] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_48);
                    totals[1] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_52);
                    totals[2] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_56);
                    totals[3] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_60);
                    totals[4] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_80);
                    totals[5] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_84);
                    totals[6] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_88);
                    totals[7] += Xv2ColorConverter.ConvertColor(particle.Type_Texture.F_92);
                    totals[8]++;
                }
            }

            return(totals);
        }
コード例 #2
0
        private byte[] GetAverageColor()
        {
            //Gets average color for Color1 & Color2
            //0-3 = color1
            //4-7 = color2
            //8 = count
            int[] totals = new int[9];

            //Get the totals
            foreach (var particle in ParticleEffectsView)
            {
                if (particle.Selected)
                {
                    //Check for children, and recursively get colors from them
                    if (particle.ParticleEffect.ChildParticleEffects != null)
                    {
                        totals = GetTotalColor_Recursive(totals, particle.ParticleEffect);
                    }

                    //Get colors from this texture part
                    if (particle.ParticleEffect.IsTextureType())
                    {
                        totals[0] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_48);
                        totals[1] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_52);
                        totals[2] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_56);
                        totals[3] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_60);
                        totals[4] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_80);
                        totals[5] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_84);
                        totals[6] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_88);
                        totals[7] += Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_92);
                        totals[8]++;
                    }
                }
            }

            //Convert the totals into the averages
            if (totals[8] == 0)
            {
                MessageBox.Show(this, "No color information was found. Setting defaults.", "Get Average Color", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(new byte[8] {
                    255, 255, 255, 255, 255, 255, 255, 255
                });
            }
            byte[] avgs = new byte[8];
            avgs[0] = (byte)(totals[0] / totals[8]);
            avgs[1] = (byte)(totals[1] / totals[8]);
            avgs[2] = (byte)(totals[2] / totals[8]);
            avgs[3] = (byte)(totals[3] / totals[8]);
            avgs[4] = (byte)(totals[4] / totals[8]);
            avgs[5] = (byte)(totals[5] / totals[8]);
            avgs[6] = (byte)(totals[6] / totals[8]);
            avgs[7] = (byte)(totals[7] / totals[8]);

            return(avgs);
        }
コード例 #3
0
        public static void ShiftColors(ObservableCollection <EmpParticleEffect> particles, byte[] colorShift, bool ignoreAlpha)
        {
            foreach (var particle in particles)
            {
                if (particle.Selected)
                {
                    //Children check
                    if (particle.ParticleEffect.ChildParticleEffects != null)
                    {
                        ShiftColors_Recursive(particle.ParticleEffect.ChildParticleEffects, colorShift, ignoreAlpha);
                    }

                    //Shift colors
                    if (particle.ParticleEffect.IsTextureType())
                    {
                        //Convert float colors to byte
                        byte R_1 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_48);
                        byte G_1 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_52);
                        byte B_1 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_56);
                        byte A_1 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_60);
                        byte R_2 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_80);
                        byte G_2 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_84);
                        byte B_2 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_88);
                        byte A_2 = Xv2ColorConverter.ConvertColor(particle.ParticleEffect.Type_Texture.F_92);

                        //Shift the byte colors
                        R_1 -= colorShift[0];
                        G_1 -= colorShift[1];
                        B_1 -= colorShift[2];
                        if (!ignoreAlpha)
                        {
                            A_1 -= colorShift[3];
                        }
                        R_2 -= colorShift[4];
                        G_2 -= colorShift[5];
                        B_2 -= colorShift[6];
                        if (!ignoreAlpha)
                        {
                            A_2 -= colorShift[7];
                        }

                        //Convert byte colors back to floats
                        particle.ParticleEffect.Type_Texture.F_48 = Xv2ColorConverter.ConvertColor(R_1);
                        particle.ParticleEffect.Type_Texture.F_52 = Xv2ColorConverter.ConvertColor(G_1);
                        particle.ParticleEffect.Type_Texture.F_56 = Xv2ColorConverter.ConvertColor(B_1);
                        particle.ParticleEffect.Type_Texture.F_60 = Xv2ColorConverter.ConvertColor(A_1);
                        particle.ParticleEffect.Type_Texture.F_80 = Xv2ColorConverter.ConvertColor(R_2);
                        particle.ParticleEffect.Type_Texture.F_84 = Xv2ColorConverter.ConvertColor(G_2);
                        particle.ParticleEffect.Type_Texture.F_88 = Xv2ColorConverter.ConvertColor(B_2);
                        particle.ParticleEffect.Type_Texture.F_92 = Xv2ColorConverter.ConvertColor(A_2);
                    }
                }
            }
        }